summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorBradley T. Hughes <bradley.hughes@nokia.com>2009-04-16 08:24:47 (GMT)
committerBradley T. Hughes <bradley.hughes@nokia.com>2009-04-16 08:24:47 (GMT)
commitee1e6222114028c2ff181f972e32f15011723b5f (patch)
treecac3620d648f1a7c6668c7bb3795cb0f4295baf9 /src/gui
parentcbec6d9481bf8f55834eafac4eca53f85206b240 (diff)
parentd43d33eb3121519d0025ad433d5c186365c47ef6 (diff)
downloadQt-ee1e6222114028c2ff181f972e32f15011723b5f.zip
Qt-ee1e6222114028c2ff181f972e32f15011723b5f.tar.gz
Qt-ee1e6222114028c2ff181f972e32f15011723b5f.tar.bz2
Merge branch 'master' of git@scm.dev.nokia.troll.no:qt/qt into windows-7-multitouch
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/accessible/qaccessible_mac.mm122
-rw-r--r--src/gui/accessible/qaccessiblewidget.cpp13
-rw-r--r--src/gui/dialogs/qfiledialog.cpp16
-rw-r--r--src/gui/dialogs/qfiledialog_mac.mm2
-rw-r--r--src/gui/dialogs/qfilesystemmodel.cpp5
-rw-r--r--src/gui/embedded/qkbd_defaultmap_qws_p.h52
-rw-r--r--src/gui/embedded/qkbd_qws_p.h52
-rw-r--r--src/gui/embedded/qkbdlinuxinput_qws.cpp4
-rw-r--r--src/gui/embedded/qkbdpc101_qws.cpp485
-rw-r--r--src/gui/embedded/qkbdpc101_qws.h95
-rw-r--r--src/gui/embedded/qkbdtty_qws.cpp4
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp580
-rw-r--r--src/gui/graphicsview/qgraphicsitem_p.h61
-rw-r--r--src/gui/graphicsview/qgraphicsproxywidget.cpp8
-rw-r--r--src/gui/graphicsview/qgraphicsscene.cpp408
-rw-r--r--src/gui/graphicsview/qgraphicsscene_p.h7
-rw-r--r--src/gui/graphicsview/qgraphicsview.cpp301
-rw-r--r--src/gui/graphicsview/qgraphicsview_p.h7
-rw-r--r--src/gui/graphicsview/qgraphicswidget.cpp63
-rw-r--r--src/gui/graphicsview/qgraphicswidget_p.h2
-rw-r--r--src/gui/image/qicon.cpp2
-rw-r--r--src/gui/image/qimage.cpp18
-rw-r--r--src/gui/image/qpixmap.cpp18
-rw-r--r--src/gui/inputmethod/qmacinputcontext_mac.cpp20
-rw-r--r--src/gui/inputmethod/qmacinputcontext_p.h5
-rw-r--r--src/gui/inputmethod/qwininputcontext_win.cpp10
-rw-r--r--src/gui/itemviews/qabstractitemview.cpp3
-rw-r--r--src/gui/itemviews/qheaderview.cpp30
-rw-r--r--src/gui/itemviews/qheaderview_p.h9
-rw-r--r--src/gui/itemviews/qsortfilterproxymodel.cpp3
-rw-r--r--src/gui/itemviews/qtreeview.cpp1
-rw-r--r--src/gui/kernel/qapplication_x11.cpp6
-rw-r--r--src/gui/kernel/qcocoaapplication_mac.mm22
-rw-r--r--src/gui/kernel/qcocoaapplicationdelegate_mac.mm22
-rw-r--r--src/gui/kernel/qcocoamenuloader_mac.mm22
-rw-r--r--src/gui/kernel/qcocoapanel_mac.mm13
-rw-r--r--src/gui/kernel/qcocoaview_mac.mm70
-rw-r--r--src/gui/kernel/qcocoaview_mac_p.h1
-rw-r--r--src/gui/kernel/qcocoawindow_mac.mm33
-rw-r--r--src/gui/kernel/qcocoawindowdelegate_mac.mm22
-rw-r--r--src/gui/kernel/qcursor.h2
-rw-r--r--src/gui/kernel/qcursor_mac.mm16
-rw-r--r--src/gui/kernel/qkeymapper_mac.cpp15
-rw-r--r--src/gui/kernel/qmacdefines_mac.h2
-rw-r--r--src/gui/kernel/qt_mac_p.h3
-rw-r--r--src/gui/kernel/qwidget.cpp50
-rw-r--r--src/gui/kernel/qwidget_mac.mm31
-rw-r--r--src/gui/math3d/math3d.pri5
-rw-r--r--src/gui/math3d/qfixedpt.cpp711
-rw-r--r--src/gui/math3d/qfixedpt.h551
-rw-r--r--src/gui/math3d/qgenericmatrix.h22
-rw-r--r--src/gui/math3d/qmath3dglobal.h102
-rw-r--r--src/gui/math3d/qmath3dutil.cpp194
-rw-r--r--src/gui/math3d/qmath3dutil_p.h96
-rw-r--r--src/gui/math3d/qmatrix4x4.cpp379
-rw-r--r--src/gui/math3d/qmatrix4x4.h177
-rw-r--r--src/gui/math3d/qquaternion.cpp105
-rw-r--r--src/gui/math3d/qquaternion.h56
-rw-r--r--src/gui/math3d/qvector2d.cpp39
-rw-r--r--src/gui/math3d/qvector2d.h37
-rw-r--r--src/gui/math3d/qvector3d.cpp38
-rw-r--r--src/gui/math3d/qvector3d.h44
-rw-r--r--src/gui/math3d/qvector4d.cpp43
-rw-r--r--src/gui/math3d/qvector4d.h49
-rw-r--r--src/gui/painting/qbezier.cpp24
-rw-r--r--src/gui/painting/qcolor.cpp4
-rw-r--r--src/gui/painting/qdrawhelper.cpp6
-rw-r--r--src/gui/painting/qmatrix.cpp63
-rw-r--r--src/gui/painting/qmatrix.h20
-rw-r--r--src/gui/painting/qpaintengine_d3d.cpp6
-rw-r--r--src/gui/painting/qpaintengine_raster.cpp138
-rw-r--r--src/gui/painting/qpaintengine_raster_p.h2
-rw-r--r--src/gui/painting/qpaintengine_x11.cpp5
-rw-r--r--src/gui/painting/qpainter.cpp47
-rw-r--r--src/gui/painting/qpainterpath.cpp10
-rw-r--r--src/gui/painting/qpathclipper.cpp36
-rw-r--r--src/gui/painting/qprinter.cpp4
-rw-r--r--src/gui/painting/qstroker.cpp12
-rw-r--r--src/gui/painting/qtessellator.cpp2
-rw-r--r--src/gui/painting/qtransform.cpp224
-rw-r--r--src/gui/painting/qtransform.h30
-rw-r--r--src/gui/painting/qwindowsurface.cpp7
-rw-r--r--src/gui/styles/gtksymbols.cpp9
-rw-r--r--src/gui/styles/qgtkstyle.cpp17
-rw-r--r--src/gui/styles/qwindowsmobilestyle.cpp3
-rw-r--r--src/gui/styles/qwindowsvistastyle.cpp23
-rw-r--r--src/gui/styles/qwindowsvistastyle_p.h1
-rw-r--r--src/gui/styles/qwindowsxpstyle.cpp4
-rw-r--r--src/gui/text/qfontengine_mac.mm110
-rw-r--r--src/gui/text/qfontengine_p.h3
-rw-r--r--src/gui/widgets/qabstractbutton.cpp9
-rw-r--r--src/gui/widgets/qabstractbutton.h3
-rw-r--r--src/gui/widgets/qcocoamenu_mac.mm41
-rw-r--r--src/gui/widgets/qcombobox.cpp37
-rw-r--r--src/gui/widgets/qcombobox_p.h1
-rw-r--r--src/gui/widgets/qdialogbuttonbox.cpp3
-rw-r--r--src/gui/widgets/qmaccocoaviewcontainer_mac.mm22
-rw-r--r--src/gui/widgets/qmacnativewidget_mac.mm22
-rw-r--r--src/gui/widgets/qmainwindow.cpp2
-rw-r--r--src/gui/widgets/qmainwindowlayout_mac.mm44
-rw-r--r--src/gui/widgets/qmenu.cpp4
-rw-r--r--src/gui/widgets/qplaintextedit.cpp7
-rw-r--r--src/gui/widgets/qtabbar.cpp90
-rw-r--r--src/gui/widgets/qtabbar_p.h33
-rw-r--r--src/gui/widgets/qtoolbar.cpp11
105 files changed, 2647 insertions, 3876 deletions
diff --git a/src/gui/accessible/qaccessible_mac.mm b/src/gui/accessible/qaccessible_mac.mm
index b6412c2..68efb8f 100644
--- a/src/gui/accessible/qaccessible_mac.mm
+++ b/src/gui/accessible/qaccessible_mac.mm
@@ -72,55 +72,36 @@ typedef NSString * const QAXRoleType;
#define QAXApplicationRole NSAccessibilityApplicationRole
#define QAXButtonRole NSAccessibilityButtonRole
#define QAXCancelAction NSAccessibilityCancelAction
-#define QAXCancelAction NSAccessibilityCancelAction
#define QAXCheckBoxRole NSAccessibilityCheckBoxRole
#define QAXChildrenAttribute NSAccessibilityChildrenAttribute
-#define QAXChildrenAttribute NSAccessibilityChildrenAttribute
-#define QAXChildrenAttribute NSAccessibilityChildrenAttribute
#define QAXCloseButtonAttribute NSAccessibilityCloseButtonAttribute
#define QAXCloseButtonAttribute NSAccessibilityCloseButtonAttribute
#define QAXColumnRole NSAccessibilityColumnRole
#define QAXConfirmAction NSAccessibilityConfirmAction
-#define QAXConfirmAction NSAccessibilityConfirmAction
#define QAXContentsAttribute NSAccessibilityContentsAttribute
-#define QAXContentsAttribute NSAccessibilityContentsAttribute
-#define QAXDecrementAction NSAccessibilityDecrementAction
#define QAXDecrementAction NSAccessibilityDecrementAction
#define QAXDecrementArrowSubrole NSAccessibilityDecrementArrowSubrole
#define QAXDecrementPageSubrole NSAccessibilityDecrementPageSubrole
#define QAXDescriptionAttribute NSAccessibilityDescriptionAttribute
-#define QAXDescriptionAttribute NSAccessibilityDescriptionAttribute
-#define QAXDescriptionAttribute NSAccessibilityDescriptionAttribute
-#define QAXDescriptionAttribute NSAccessibilityDescriptionAttribute
-#define QAXEnabledAttribute NSAccessibilityEnabledAttribute
#define QAXEnabledAttribute NSAccessibilityEnabledAttribute
#define QAXExpandedAttribute NSAccessibilityExpandedAttribute
#define QAXFocusedAttribute NSAccessibilityFocusedAttribute
-#define QAXFocusedAttribute NSAccessibilityFocusedAttribute
-#define QAXFocusedAttribute NSAccessibilityFocusedAttribute
#define QAXFocusedUIElementChangedNotification NSAccessibilityFocusedUIElementChangedNotification
#define QAXFocusedWindowChangedNotification NSAccessibilityFocusedWindowChangedNotification
#define QAXGroupRole NSAccessibilityGroupRole
#define QAXGrowAreaAttribute NSAccessibilityGrowAreaAttribute
-#define QAXGrowAreaAttribute NSAccessibilityGrowAreaAttribute
#define QAXGrowAreaRole NSAccessibilityGrowAreaRole
#define QAXHelpAttribute NSAccessibilityHelpAttribute
-#define QAXHelpAttribute NSAccessibilityHelpAttribute
-#define QAXHelpAttribute NSAccessibilityHelpAttribute
#define QAXHorizontalOrientationValue NSAccessibilityHorizontalOrientationValue
#define QAXHorizontalScrollBarAttribute NSAccessibilityHorizontalScrollBarAttribute
-#define QAXHorizontalScrollBarAttribute NSAccessibilityHorizontalScrollBarAttribute
-#define QAXIncrementAction NSAccessibilityIncrementAction
#define QAXIncrementAction NSAccessibilityIncrementAction
#define QAXIncrementArrowSubrole NSAccessibilityIncrementArrowSubrole
#define QAXIncrementPageSubrole NSAccessibilityIncrementPageSubrole
#define QAXIncrementorRole NSAccessibilityIncrementorRole
#define QAXLinkedUIElementsAttribute NSAccessibilityLinkedUIElementsAttribute
-#define QAXLinkedUIElementsAttribute NSAccessibilityLinkedUIElementsAttribute
#define QAXListRole NSAccessibilityListRole
#define QAXMainAttribute NSAccessibilityMainAttribute
#define QAXMaxValueAttribute NSAccessibilityMaxValueAttribute
-#define QAXMaxValueAttribute NSAccessibilityMaxValueAttribute
#define QAXMenuBarRole NSAccessibilityMenuBarRole
#define QAXMenuButtonRole NSAccessibilityMenuButtonRole
#define QAXMenuClosedNotification NSAccessibilityMenuClosedNotification
@@ -128,151 +109,90 @@ typedef NSString * const QAXRoleType;
#define QAXMenuOpenedNotification NSAccessibilityMenuOpenedNotification
#define QAXMenuRole NSAccessibilityMenuRole
#define QAXMinValueAttribute NSAccessibilityMinValueAttribute
-#define QAXMinValueAttribute NSAccessibilityMinValueAttribute
#define QAXMinimizeButtonAttribute NSAccessibilityMinimizeButtonAttribute
-#define QAXMinimizeButtonAttribute NSAccessibilityMinimizeButtonAttribute
-#define QAXMinimizedAttribute NSAccessibilityMinimizedAttribute
#define QAXMinimizedAttribute NSAccessibilityMinimizedAttribute
#define QAXNextContentsAttribute NSAccessibilityNextContentsAttribute
-#define QAXNextContentsAttribute NSAccessibilityNextContentsAttribute
-#define QAXOrientationAttribute NSAccessibilityOrientationAttribute
-#define QAXOrientationAttribute NSAccessibilityOrientationAttribute
#define QAXOrientationAttribute NSAccessibilityOrientationAttribute
#define QAXParentAttribute NSAccessibilityParentAttribute
#define QAXPickAction NSAccessibilityPickAction
-#define QAXPickAction NSAccessibilityPickAction
#define QAXPopUpButtonRole NSAccessibilityPopUpButtonRole
#define QAXPositionAttribute NSAccessibilityPositionAttribute
-#define QAXPositionAttribute NSAccessibilityPositionAttribute
-#define QAXPressAction NSAccessibilityPressAction
#define QAXPressAction NSAccessibilityPressAction
#define QAXPreviousContentsAttribute NSAccessibilityPreviousContentsAttribute
-#define QAXPreviousContentsAttribute NSAccessibilityPreviousContentsAttribute
-#define QAXPreviousContentsAttribute NSAccessibilityPreviousContentsAttribute
#define QAXProgressIndicatorRole NSAccessibilityProgressIndicatorRole
#define QAXRadioButtonRole NSAccessibilityRadioButtonRole
#define QAXRoleAttribute NSAccessibilityRoleAttribute
-#define QAXRoleAttribute NSAccessibilityRoleAttribute
#define QAXRoleDescriptionAttribute NSAccessibilityRoleDescriptionAttribute
#define QAXRowRole NSAccessibilityRowRole
#define QAXRowsAttribute NSAccessibilityRowsAttribute
-#define QAXRowsAttribute NSAccessibilityRowsAttribute
-#define QAXScrollAreaRole NSAccessibilityScrollAreaRole
-#define QAXScrollAreaRole NSAccessibilityScrollAreaRole
#define QAXScrollAreaRole NSAccessibilityScrollAreaRole
#define QAXScrollBarRole NSAccessibilityScrollBarRole
#define QAXSelectedAttribute NSAccessibilitySelectedAttribute
#define QAXSelectedChildrenAttribute NSAccessibilitySelectedChildrenAttribute
#define QAXSelectedRowsAttribute NSAccessibilitySelectedRowsAttribute
-#define QAXSelectedRowsAttribute NSAccessibilitySelectedRowsAttribute
-#define QAXSizeAttribute NSAccessibilitySizeAttribute
#define QAXSizeAttribute NSAccessibilitySizeAttribute
#define QAXSliderRole NSAccessibilitySliderRole
#define QAXSplitGroupRole NSAccessibilitySplitGroupRole
#define QAXSplitterRole NSAccessibilitySplitterRole
-#define QAXSplitterRole NSAccessibilitySplitterRole
-#define QAXSplitterRole NSAccessibilitySplitterRole
-#define QAXSplittersAttribute NSAccessibilitySplittersAttribute
#define QAXSplittersAttribute NSAccessibilitySplittersAttribute
#define QAXStaticTextRole NSAccessibilityStaticTextRole
-#define QAXStaticTextRole NSAccessibilityStaticTextRole
-#define QAXSubroleAttribute NSAccessibilitySubroleAttribute
#define QAXSubroleAttribute NSAccessibilitySubroleAttribute
#define QAXSubroleAttribute NSAccessibilitySubroleAttribute
#define QAXTabGroupRole NSAccessibilityTabGroupRole
-#define QAXTabGroupRole NSAccessibilityTabGroupRole
#define QAXTableRole NSAccessibilityTableRole
#define QAXTabsAttribute NSAccessibilityTabsAttribute
-#define QAXTabsAttribute NSAccessibilityTabsAttribute
#define QAXTextFieldRole NSAccessibilityTextFieldRole
-#define QAXTextFieldRole NSAccessibilityTextFieldRole
-#define QAXTitleAttribute NSAccessibilityTitleAttribute
-#define QAXTitleAttribute NSAccessibilityTitleAttribute
#define QAXTitleAttribute NSAccessibilityTitleAttribute
-#define QAXTitleAttribute NSAccessibilityTitleAttribute
-#define QAXTitleUIElementAttribute NSAccessibilityTitleUIElementAttribute
#define QAXTitleUIElementAttribute NSAccessibilityTitleUIElementAttribute
#define QAXToolbarButtonAttribute NSAccessibilityToolbarButtonAttribute
-#define QAXToolbarButtonAttribute NSAccessibilityToolbarButtonAttribute
#define QAXToolbarRole NSAccessibilityToolbarRole
#define QAXTopLevelUIElementAttribute NSAccessibilityTopLevelUIElementAttribute
-#define QAXTopLevelUIElementAttribute NSAccessibilityTopLevelUIElementAttribute
-#define QAXTopLevelUIElementAttribute NSAccessibilityTopLevelUIElementAttribute
-#define QAXUnknownRole NSAccessibilityUnknownRole
#define QAXUnknownRole NSAccessibilityUnknownRole
#define QAXValueAttribute NSAccessibilityValueAttribute
-#define QAXValueAttribute NSAccessibilityValueAttribute
-#define QAXValueAttribute NSAccessibilityValueAttribute
-#define QAXValueAttribute NSAccessibilityValueAttribute
#define QAXValueChangedNotification NSAccessibilityValueChangedNotification
#define QAXValueIndicatorRole NSAccessibilityValueIndicatorRole
#define QAXVerticalOrientationValue NSAccessibilityVerticalOrientationValue
#define QAXVerticalScrollBarAttribute NSAccessibilityVerticalScrollBarAttribute
-#define QAXVerticalScrollBarAttribute NSAccessibilityVerticalScrollBarAttribute
#define QAXVisibleRowsAttribute NSAccessibilityVisibleRowsAttribute
-#define QAXVisibleRowsAttribute NSAccessibilityVisibleRowsAttribute
-#define QAXWindowAttribute NSAccessibilityWindowAttribute
-#define QAXWindowAttribute NSAccessibilityWindowAttribute
#define QAXWindowAttribute NSAccessibilityWindowAttribute
#define QAXWindowCreatedNotification NSAccessibilityWindowCreatedNotification
#define QAXWindowMovedNotification NSAccessibilityWindowMovedNotification
#define QAXWindowRole NSAccessibilityWindowRole
#define QAXZoomButtonAttribute NSAccessibilityZoomButtonAttribute
-#define QAXZoomButtonAttribute NSAccessibilityZoomButtonAttribute
#else
typedef CFStringRef const QAXRoleType;
#define QAXApplicationRole kAXApplicationRole
#define QAXButtonRole kAXButtonRole
#define QAXCancelAction kAXCancelAction
-#define QAXCancelAction kAXCancelAction
#define QAXCheckBoxRole kAXCheckBoxRole
#define QAXChildrenAttribute kAXChildrenAttribute
-#define QAXChildrenAttribute kAXChildrenAttribute
-#define QAXChildrenAttribute kAXChildrenAttribute
-#define QAXCloseButtonAttribute kAXCloseButtonAttribute
#define QAXCloseButtonAttribute kAXCloseButtonAttribute
#define QAXColumnRole kAXColumnRole
#define QAXConfirmAction kAXConfirmAction
-#define QAXConfirmAction kAXConfirmAction
#define QAXContentsAttribute kAXContentsAttribute
-#define QAXContentsAttribute kAXContentsAttribute
-#define QAXDecrementAction kAXDecrementAction
#define QAXDecrementAction kAXDecrementAction
#define QAXDecrementArrowSubrole kAXDecrementArrowSubrole
#define QAXDecrementPageSubrole kAXDecrementPageSubrole
#define QAXDescriptionAttribute kAXDescriptionAttribute
-#define QAXDescriptionAttribute kAXDescriptionAttribute
-#define QAXDescriptionAttribute kAXDescriptionAttribute
-#define QAXDescriptionAttribute kAXDescriptionAttribute
-#define QAXEnabledAttribute kAXEnabledAttribute
#define QAXEnabledAttribute kAXEnabledAttribute
#define QAXExpandedAttribute kAXExpandedAttribute
#define QAXFocusedAttribute kAXFocusedAttribute
-#define QAXFocusedAttribute kAXFocusedAttribute
-#define QAXFocusedAttribute kAXFocusedAttribute
#define QAXFocusedUIElementChangedNotification kAXFocusedUIElementChangedNotification
#define QAXFocusedWindowChangedNotification kAXFocusedWindowChangedNotification
#define QAXGroupRole kAXGroupRole
#define QAXGrowAreaAttribute kAXGrowAreaAttribute
-#define QAXGrowAreaAttribute kAXGrowAreaAttribute
#define QAXGrowAreaRole kAXGrowAreaRole
#define QAXHelpAttribute kAXHelpAttribute
-#define QAXHelpAttribute kAXHelpAttribute
-#define QAXHelpAttribute kAXHelpAttribute
#define QAXHorizontalOrientationValue kAXHorizontalOrientationValue
#define QAXHorizontalScrollBarAttribute kAXHorizontalScrollBarAttribute
-#define QAXHorizontalScrollBarAttribute kAXHorizontalScrollBarAttribute
-#define QAXIncrementAction kAXIncrementAction
#define QAXIncrementAction kAXIncrementAction
#define QAXIncrementArrowSubrole kAXIncrementArrowSubrole
#define QAXIncrementPageSubrole kAXIncrementPageSubrole
#define QAXIncrementorRole kAXIncrementorRole
#define QAXLinkedUIElementsAttribute kAXLinkedUIElementsAttribute
-#define QAXLinkedUIElementsAttribute kAXLinkedUIElementsAttribute
#define QAXListRole kAXListRole
#define QAXMainAttribute kAXMainAttribute
#define QAXMaxValueAttribute kAXMaxValueAttribute
-#define QAXMaxValueAttribute kAXMaxValueAttribute
#define QAXMenuBarRole kAXMenuBarRole
#define QAXMenuButtonRole kAXMenuButtonRole
#define QAXMenuClosedNotification kAXMenuClosedNotification
@@ -280,97 +200,55 @@ typedef CFStringRef const QAXRoleType;
#define QAXMenuOpenedNotification kAXMenuOpenedNotification
#define QAXMenuRole kAXMenuRole
#define QAXMinValueAttribute kAXMinValueAttribute
-#define QAXMinValueAttribute kAXMinValueAttribute
#define QAXMinimizeButtonAttribute kAXMinimizeButtonAttribute
-#define QAXMinimizeButtonAttribute kAXMinimizeButtonAttribute
-#define QAXMinimizedAttribute kAXMinimizedAttribute
#define QAXMinimizedAttribute kAXMinimizedAttribute
#define QAXNextContentsAttribute kAXNextContentsAttribute
-#define QAXNextContentsAttribute kAXNextContentsAttribute
-#define QAXOrientationAttribute kAXOrientationAttribute
-#define QAXOrientationAttribute kAXOrientationAttribute
#define QAXOrientationAttribute kAXOrientationAttribute
#define QAXParentAttribute kAXParentAttribute
#define QAXPickAction kAXPickAction
-#define QAXPickAction kAXPickAction
#define QAXPopUpButtonRole kAXPopUpButtonRole
#define QAXPositionAttribute kAXPositionAttribute
-#define QAXPositionAttribute kAXPositionAttribute
-#define QAXPressAction kAXPressAction
#define QAXPressAction kAXPressAction
#define QAXPreviousContentsAttribute kAXPreviousContentsAttribute
-#define QAXPreviousContentsAttribute kAXPreviousContentsAttribute
-#define QAXPreviousContentsAttribute kAXPreviousContentsAttribute
#define QAXProgressIndicatorRole kAXProgressIndicatorRole
#define QAXRadioButtonRole kAXRadioButtonRole
#define QAXRoleAttribute kAXRoleAttribute
-#define QAXRoleAttribute kAXRoleAttribute
#define QAXRoleDescriptionAttribute kAXRoleDescriptionAttribute
#define QAXRowRole kAXRowRole
#define QAXRowsAttribute kAXRowsAttribute
-#define QAXRowsAttribute kAXRowsAttribute
-#define QAXScrollAreaRole kAXScrollAreaRole
-#define QAXScrollAreaRole kAXScrollAreaRole
#define QAXScrollAreaRole kAXScrollAreaRole
#define QAXScrollBarRole kAXScrollBarRole
#define QAXSelectedAttribute kAXSelectedAttribute
#define QAXSelectedChildrenAttribute kAXSelectedChildrenAttribute
#define QAXSelectedRowsAttribute kAXSelectedRowsAttribute
-#define QAXSelectedRowsAttribute kAXSelectedRowsAttribute
-#define QAXSizeAttribute kAXSizeAttribute
#define QAXSizeAttribute kAXSizeAttribute
#define QAXSliderRole kAXSliderRole
#define QAXSplitGroupRole kAXSplitGroupRole
#define QAXSplitterRole kAXSplitterRole
-#define QAXSplitterRole kAXSplitterRole
-#define QAXSplitterRole kAXSplitterRole
-#define QAXSplittersAttribute kAXSplittersAttribute
#define QAXSplittersAttribute kAXSplittersAttribute
#define QAXStaticTextRole kAXStaticTextRole
-#define QAXStaticTextRole kAXStaticTextRole
-#define QAXSubroleAttribute kAXSubroleAttribute
#define QAXSubroleAttribute kAXSubroleAttribute
-#define QAXSubroleAttribute kAXSubroleAttribute
-#define QAXTabGroupRole kAXTabGroupRole
#define QAXTabGroupRole kAXTabGroupRole
#define QAXTableRole kAXTableRole
#define QAXTabsAttribute kAXTabsAttribute
-#define QAXTabsAttribute kAXTabsAttribute
-#define QAXTextFieldRole kAXTextFieldRole
#define QAXTextFieldRole kAXTextFieldRole
#define QAXTitleAttribute kAXTitleAttribute
-#define QAXTitleAttribute kAXTitleAttribute
-#define QAXTitleAttribute kAXTitleAttribute
-#define QAXTitleAttribute kAXTitleAttribute
#define QAXTitleUIElementAttribute kAXTitleUIElementAttribute
-#define QAXTitleUIElementAttribute kAXTitleUIElementAttribute
-#define QAXToolbarButtonAttribute kAXToolbarButtonAttribute
#define QAXToolbarButtonAttribute kAXToolbarButtonAttribute
#define QAXToolbarRole kAXToolbarRole
#define QAXTopLevelUIElementAttribute kAXTopLevelUIElementAttribute
-#define QAXTopLevelUIElementAttribute kAXTopLevelUIElementAttribute
-#define QAXTopLevelUIElementAttribute kAXTopLevelUIElementAttribute
#define QAXUnknownRole kAXUnknownRole
-#define QAXUnknownRole kAXUnknownRole
-#define QAXValueAttribute kAXValueAttribute
-#define QAXValueAttribute kAXValueAttribute
-#define QAXValueAttribute kAXValueAttribute
#define QAXValueAttribute kAXValueAttribute
#define QAXValueChangedNotification kAXValueChangedNotification
#define QAXValueIndicatorRole kAXValueIndicatorRole
#define QAXVerticalOrientationValue kAXVerticalOrientationValue
#define QAXVerticalScrollBarAttribute kAXVerticalScrollBarAttribute
-#define QAXVerticalScrollBarAttribute kAXVerticalScrollBarAttribute
-#define QAXVisibleRowsAttribute kAXVisibleRowsAttribute
#define QAXVisibleRowsAttribute kAXVisibleRowsAttribute
#define QAXWindowAttribute kAXWindowAttribute
-#define QAXWindowAttribute kAXWindowAttribute
-#define QAXWindowAttribute kAXWindowAttribute
#define QAXWindowCreatedNotification kAXWindowCreatedNotification
#define QAXWindowMovedNotification kAXWindowMovedNotification
#define QAXWindowRole kAXWindowRole
#define QAXZoomButtonAttribute kAXZoomButtonAttribute
-#define QAXZoomButtonAttribute kAXZoomButtonAttribute
#endif
diff --git a/src/gui/accessible/qaccessiblewidget.cpp b/src/gui/accessible/qaccessiblewidget.cpp
index 4b2b2ab..753ac57 100644
--- a/src/gui/accessible/qaccessiblewidget.cpp
+++ b/src/gui/accessible/qaccessiblewidget.cpp
@@ -131,9 +131,16 @@ QString Q_GUI_EXPORT qt_accHotKey(const QString &text)
int fa = 0;
QChar ac;
while ((fa = text.indexOf(QLatin1Char('&'), fa)) != -1) {
- if (fa == text.length() - 1 || text.at(fa+1) != QLatin1Char('&')) {
- ac = text.at(fa+1);
- break;
+ ++fa;
+ if (fa < text.length()) {
+ // ignore "&&"
+ if (text.at(fa) == QLatin1Char('&')) {
+ ++fa;
+ continue;
+ } else {
+ ac = text.at(fa);
+ break;
+ }
}
}
if (ac.isNull())
diff --git a/src/gui/dialogs/qfiledialog.cpp b/src/gui/dialogs/qfiledialog.cpp
index 5131271..b20321f 100644
--- a/src/gui/dialogs/qfiledialog.cpp
+++ b/src/gui/dialogs/qfiledialog.cpp
@@ -957,25 +957,29 @@ void QFileDialog::setNameFilters(const QStringList &filters)
{
Q_D(QFileDialog);
d->defaultFileTypes = (filters == QStringList(QFileDialog::tr("All Files (*)")));
- d->nameFilters = filters;
+ QStringList cleanedFilters;
+ for (int i = 0; i < filters.count(); ++i) {
+ cleanedFilters << filters[i].simplified();
+ }
+ d->nameFilters = cleanedFilters;
if (d->nativeDialogInUse){
- d->setNameFilters_sys(filters);
+ d->setNameFilters_sys(cleanedFilters);
return;
}
d->qFileDialogUi->fileTypeCombo->clear();
- if (filters.isEmpty())
+ if (cleanedFilters.isEmpty())
return;
if (testOption(HideNameFilterDetails)) {
QStringList strippedFilters;
- for (int i = 0; i < filters.count(); ++i) {
- strippedFilters.append(filters[i].mid(0, filters[i].indexOf(QLatin1String(" ("))));
+ for (int i = 0; i < cleanedFilters.count(); ++i) {
+ strippedFilters.append(cleanedFilters[i].mid(0, cleanedFilters[i].indexOf(QLatin1String(" ("))));
}
d->qFileDialogUi->fileTypeCombo->addItems(strippedFilters);
} else {
- d->qFileDialogUi->fileTypeCombo->addItems(filters);
+ d->qFileDialogUi->fileTypeCombo->addItems(cleanedFilters);
}
d->_q_useNameFilter(0);
}
diff --git a/src/gui/dialogs/qfiledialog_mac.mm b/src/gui/dialogs/qfiledialog_mac.mm
index 4c13d01..90af9fc 100644
--- a/src/gui/dialogs/qfiledialog_mac.mm
+++ b/src/gui/dialogs/qfiledialog_mac.mm
@@ -278,7 +278,7 @@ QT_USE_NAMESPACE
{
Q_UNUSED(sender);
QString qtFileName = QT_PREPEND_NAMESPACE(qt_mac_NSStringToQString)(filename);
- QFileInfo info(qtFileName);
+ QFileInfo info(qtFileName.normalized(QT_PREPEND_NAMESPACE(QString::NormalizationForm_C)));
QString path = info.absolutePath();
if (path != *mLastFilterCheckPath){
*mLastFilterCheckPath = path;
diff --git a/src/gui/dialogs/qfilesystemmodel.cpp b/src/gui/dialogs/qfilesystemmodel.cpp
index c7b3137..012d3a1 100644
--- a/src/gui/dialogs/qfilesystemmodel.cpp
+++ b/src/gui/dialogs/qfilesystemmodel.cpp
@@ -1430,7 +1430,10 @@ void QFileSystemModel::setFilter(QDir::Filters filters)
}
/*!
- Returns the filter specification for the directory model.
+ Returns the filter specified for the directory model.
+
+ If a filter has not been set, the default filter is QDir::AllEntries |
+ QDir::NoDotAndDotDot | QDir::AllDirs.
\sa QDir::Filters
*/
diff --git a/src/gui/embedded/qkbd_defaultmap_qws_p.h b/src/gui/embedded/qkbd_defaultmap_qws_p.h
index 34ce69e..0d6d77d 100644
--- a/src/gui/embedded/qkbd_defaultmap_qws_p.h
+++ b/src/gui/embedded/qkbd_defaultmap_qws_p.h
@@ -1,6 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@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.
+//
+
const QWSKeyboard::Mapping QWSKbPrivate::s_keymap_default[] = {
{ 1, 0xffff, 0x01000000, 0x00, 0x00, 0x0000 },
{ 2, 0x0031, 0x00000031, 0x00, 0x00, 0x0000 },
diff --git a/src/gui/embedded/qkbd_qws_p.h b/src/gui/embedded/qkbd_qws_p.h
index f7dcdaf..3224da2 100644
--- a/src/gui/embedded/qkbd_qws_p.h
+++ b/src/gui/embedded/qkbd_qws_p.h
@@ -1,6 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@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>
namespace QWSKeyboard {
diff --git a/src/gui/embedded/qkbdlinuxinput_qws.cpp b/src/gui/embedded/qkbdlinuxinput_qws.cpp
index d04b09f..1ef2696 100644
--- a/src/gui/embedded/qkbdlinuxinput_qws.cpp
+++ b/src/gui/embedded/qkbdlinuxinput_qws.cpp
@@ -105,9 +105,9 @@ QWSLinuxInputKbPrivate::QWSLinuxInputKbPrivate(QWSLinuxInputKeyboardHandler *h,
QStringList args = device.split(QLatin1Char(':'));
foreach (const QString &arg, args) {
- if (arg.startsWith(QLatin1String("repeat_delay=")))
+ if (arg.startsWith(QLatin1String("repeat-delay=")))
repeat_delay = arg.mid(13).toInt();
- else if (arg.startsWith(QLatin1String("repeat_rate=")))
+ else if (arg.startsWith(QLatin1String("repeat-rate=")))
repeat_rate = arg.mid(12).toInt();
else if (arg.startsWith(QLatin1String("/dev/")))
dev = arg;
diff --git a/src/gui/embedded/qkbdpc101_qws.cpp b/src/gui/embedded/qkbdpc101_qws.cpp
deleted file mode 100644
index 3173645..0000000
--- a/src/gui/embedded/qkbdpc101_qws.cpp
+++ /dev/null
@@ -1,485 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at qt-sales@nokia.com.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qkbdpc101_qws.h"
-
-#ifndef QT_NO_QWS_KEYBOARD
-
-#include "qscreen_qws.h"
-#include "qwindowsystem_qws.h"
-#include "qnamespace.h"
-#include "qapplication.h"
-
-#include <unistd.h>
-#include <sys/ioctl.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <errno.h>
-
-#ifdef Q_OS_LINUX
-#include <sys/kd.h>
-#include <sys/vt.h>
-#endif
-
-QT_BEGIN_NAMESPACE
-
-static const QWSKeyMap pc101KeyM[] = {
- { Qt::Key_unknown, 0xffff , 0xffff , 0xffff },
- { Qt::Key_Escape, 27 , 27 , 0xffff },
- { Qt::Key_1, '1' , '!' , 0xffff },
- { Qt::Key_2, '2' , '@' , 0xffff },
- { Qt::Key_3, '3' , '#' , 0xffff },
- { Qt::Key_4, '4' , '$' , 0xffff },
- { Qt::Key_5, '5' , '%' , 0xffff },
- { Qt::Key_6, '6' , '^' , 0xffff },
- { Qt::Key_7, '7' , '&' , 0xffff },
- { Qt::Key_8, '8' , '*' , 0xffff },
- { Qt::Key_9, '9' , '(' , 0xffff }, // 10
- { Qt::Key_0, '0' , ')' , 0xffff },
- { Qt::Key_Minus, '-' , '_' , 0xffff },
- { Qt::Key_Equal, '=' , '+' , 0xffff },
- { Qt::Key_Backspace, 8 , 8 , 0xffff },
- { Qt::Key_Tab, 9 , 9 , 0xffff },
- { Qt::Key_Q, 'q' , 'Q' , 'Q'-64 },
- { Qt::Key_W, 'w' , 'W' , 'W'-64 },
- { Qt::Key_E, 'e' , 'E' , 'E'-64 },
- { Qt::Key_R, 'r' , 'R' , 'R'-64 },
- { Qt::Key_T, 't' , 'T' , 'T'-64 }, // 20
- { Qt::Key_Y, 'y' , 'Y' , 'Y'-64 },
- { Qt::Key_U, 'u' , 'U' , 'U'-64 },
- { Qt::Key_I, 'i' , 'I' , 'I'-64 },
- { Qt::Key_O, 'o' , 'O' , 'O'-64 },
- { Qt::Key_P, 'p' , 'P' , 'P'-64 },
- { Qt::Key_BraceLeft, '[' , '{' , 0xffff },
- { Qt::Key_BraceRight, ']' , '}' , 0xffff },
- { Qt::Key_Return, 13 , 13 , 0xffff },
- { Qt::Key_Control, 0xffff , 0xffff , 0xffff },
- { Qt::Key_A, 'a' , 'A' , 'A'-64 }, // 30
- { Qt::Key_S, 's' , 'S' , 'S'-64 },
- { Qt::Key_D, 'd' , 'D' , 'D'-64 },
- { Qt::Key_F, 'f' , 'F' , 'F'-64 },
- { Qt::Key_G, 'g' , 'G' , 'G'-64 },
- { Qt::Key_H, 'h' , 'H' , 'H'-64 },
- { Qt::Key_J, 'j' , 'J' , 'J'-64 },
- { Qt::Key_K, 'k' , 'K' , 'K'-64 },
- { Qt::Key_L, 'l' , 'L' , 'L'-64 },
- { Qt::Key_Semicolon, ';' , ':' , 0xffff },
- { Qt::Key_Apostrophe, '\'' , '"' , 0xffff }, // 40
- { Qt::Key_QuoteLeft, '`' , '~' , 0xffff },
- { Qt::Key_Shift, 0xffff , 0xffff , 0xffff },
- { Qt::Key_Backslash, '\\' , '|' , 0xffff },
- { Qt::Key_Z, 'z' , 'Z' , 'Z'-64 },
- { Qt::Key_X, 'x' , 'X' , 'X'-64 },
- { Qt::Key_C, 'c' , 'C' , 'C'-64 },
- { Qt::Key_V, 'v' , 'V' , 'V'-64 },
- { Qt::Key_B, 'b' , 'B' , 'B'-64 },
- { Qt::Key_N, 'n' , 'N' , 'N'-64 },
- { Qt::Key_M, 'm' , 'M' , 'M'-64 }, // 50
- { Qt::Key_Comma, ',' , '<' , 0xffff },
- { Qt::Key_Period, '.' , '>' , 0xffff },
- { Qt::Key_Slash, '/' , '?' , 0xffff },
- { Qt::Key_Shift, 0xffff , 0xffff , 0xffff },
- { Qt::Key_Asterisk, '*' , '*' , 0xffff },
- { Qt::Key_Alt, 0xffff , 0xffff , 0xffff },
- { Qt::Key_Space, ' ' , ' ' , 0xffff },
- { Qt::Key_CapsLock, 0xffff , 0xffff , 0xffff },
- { Qt::Key_F1, 0xffff , 0xffff , 0xffff },
- { Qt::Key_F2, 0xffff , 0xffff , 0xffff }, // 60
- { Qt::Key_F3, 0xffff , 0xffff , 0xffff },
- { Qt::Key_F4, 0xffff , 0xffff , 0xffff },
- { Qt::Key_F5, 0xffff , 0xffff , 0xffff },
- { Qt::Key_F6, 0xffff , 0xffff , 0xffff },
- { Qt::Key_F7, 0xffff , 0xffff , 0xffff },
- { Qt::Key_F8, 0xffff , 0xffff , 0xffff },
- { Qt::Key_F9, 0xffff , 0xffff , 0xffff },
- { Qt::Key_F10, 0xffff , 0xffff , 0xffff },
- { Qt::Key_NumLock, 0xffff , 0xffff , 0xffff },
- { Qt::Key_ScrollLock, 0xffff , 0xffff , 0xffff }, // 70
- { Qt::Key_7, '7' , '7' , 0xffff },
- { Qt::Key_8, '8' , '8' , 0xffff },
- { Qt::Key_9, '9' , '9' , 0xffff },
- { Qt::Key_Minus, '-' , '-' , 0xffff },
- { Qt::Key_4, '4' , '4' , 0xffff },
- { Qt::Key_5, '5' , '5' , 0xffff },
- { Qt::Key_6, '6' , '6' , 0xffff },
- { Qt::Key_Plus, '+' , '+' , 0xffff },
- { Qt::Key_1, '1' , '1' , 0xffff },
- { Qt::Key_2, '2' , '2' , 0xffff }, // 80
- { Qt::Key_3, '3' , '3' , 0xffff },
- { Qt::Key_0, '0' , '0' , 0xffff },
- { Qt::Key_Period, '.' , '.' , 0xffff },
- { Qt::Key_SysReq, 0xffff , 0xffff , 0xffff },
- { Qt::Key_unknown, 0xffff , 0xffff , 0xffff },
- { Qt::Key_Less, '<' , '>' , 0xffff },
- { Qt::Key_F11, 0xffff , 0xffff , 0xffff },
- { Qt::Key_F12, 0xffff , 0xffff , 0xffff },
- { Qt::Key_unknown, 0xffff , 0xffff , 0xffff },
- { Qt::Key_unknown, 0xffff , 0xffff , 0xffff }, // 90
- { Qt::Key_unknown, 0xffff , 0xffff , 0xffff },
- { Qt::Key_unknown, 0xffff , 0xffff , 0xffff },
- { Qt::Key_unknown, 0xffff , 0xffff , 0xffff },
- { Qt::Key_unknown, 0xffff , 0xffff , 0xffff },
- { Qt::Key_unknown, 0xffff , 0xffff , 0xffff },
- { Qt::Key_Enter, 13 , 13 , 0xffff },
- { Qt::Key_Control, 0xffff , 0xffff , 0xffff },
- { Qt::Key_Slash, '/' , '/' , 0xffff },
- { Qt::Key_SysReq, 0xffff , 0xffff , 0xffff },
- { Qt::Key_Meta, 0xffff , 0xffff , 0xffff }, // 100
- { Qt::Key_unknown, 0xffff , 0xffff , 0xffff }, // break
- { Qt::Key_Home, 0xffff , 0xffff , 0xffff },
- { Qt::Key_Up, 0xffff , 0xffff , 0xffff },
- { Qt::Key_PageUp, 0xffff , 0xffff , 0xffff },
- { Qt::Key_Left, 0xffff , 0xffff , 0xffff },
- { Qt::Key_Right, 0xffff , 0xffff , 0xffff },
- { Qt::Key_End, 0xffff , 0xffff , 0xffff },
- { Qt::Key_Down, 0xffff , 0xffff , 0xffff },
- { Qt::Key_PageDown, 0xffff , 0xffff , 0xffff },
- { Qt::Key_Insert, 0xffff , 0xffff , 0xffff }, // 110
- { Qt::Key_Delete, 0xffff , 0xffff , 0xffff },
- { Qt::Key_unknown, 0xffff , 0xffff , 0xffff }, // macro
- { Qt::Key_F13, 0xffff , 0xffff , 0xffff },
- { Qt::Key_F14, 0xffff , 0xffff , 0xffff },
- { Qt::Key_Help, 0xffff , 0xffff , 0xffff },
- { Qt::Key_unknown, 0xffff , 0xffff , 0xffff }, // do
- { Qt::Key_F17, 0xffff , 0xffff , 0xffff },
- { Qt::Key_Plus, '+' , '-' , 0xffff },
- { Qt::Key_Pause, 0xffff , 0xffff , 0xffff },
- { Qt::Key_unknown, 0xffff , 0xffff , 0xffff },
- { Qt::Key_unknown, 0xffff , 0xffff , 0xffff },
- { Qt::Key_unknown, 0xffff , 0xffff , 0xffff },
- { Qt::Key_unknown, 0xffff , 0xffff , 0xffff },
- { Qt::Key_unknown, 0xffff , 0xffff , 0xffff },
- { Qt::Key_unknown, 0xffff , 0xffff , 0xffff },
- { Qt::Key_unknown, 0xffff , 0xffff , 0xffff },
- { Qt::Key_unknown, 0xffff , 0xffff , 0xffff },
- { 0, 0xffff , 0xffff , 0xffff }
-};
-
-static const int keyMSize = sizeof(pc101KeyM)/sizeof(QWSKeyMap)-1;
-
-//===========================================================================
-
-//
-// PC-101 type keyboards
-//
-
-/*!
- \class QWSPC101KeyboardHandler
- \ingroup qws
-
- \internal
-*/
-
-QWSPC101KeyboardHandler::QWSPC101KeyboardHandler(const QString&)
-{
- shift = false;
- alt = false;
- ctrl = false;
- extended = 0;
- prevuni = 0;
- prevkey = 0;
- caps = false;
-#if defined(QT_QWS_IPAQ)
- // iPAQ Action Key has ScanCode 0x60: 0x60|0x80 = 0xe0 == extended mode 1 !
- ipaq_return_pressed = false;
-#endif
-}
-
-QWSPC101KeyboardHandler::~QWSPC101KeyboardHandler()
-{
-}
-
-const QWSKeyMap *QWSPC101KeyboardHandler::keyMap() const
-{
- return pc101KeyM;
-}
-
-void QWSPC101KeyboardHandler::doKey(uchar code)
-{
-
- int keyCode = Qt::Key_unknown;
- bool release = false;
- int keypad = 0;
- bool softwareRepeat = false;
-
-#ifndef QT_QWS_USE_KEYCODES
- // extended?
- if (code == 224
-#if defined(QT_QWS_IPAQ)
- && !ipaq_return_pressed
-#endif
- ) {
- extended = 1;
- return;
- } else if (code == 225) {
- extended = 2;
- return;
- }
-#endif
-
- if (code & 0x80) {
- release = true;
- code &= 0x7f;
- }
-
-#ifndef QT_QWS_USE_KEYCODES
- if (extended == 1) {
- switch (code) {
- case 72:
- keyCode = Qt::Key_Up;
- break;
- case 75:
- keyCode = Qt::Key_Left;
- break;
- case 77:
- keyCode = Qt::Key_Right;
- break;
- case 80:
- keyCode = Qt::Key_Down;
- break;
- case 82:
- keyCode = Qt::Key_Insert;
- break;
- case 71:
- keyCode = Qt::Key_Home;
- break;
- case 73:
- keyCode = Qt::Key_PageUp;
- break;
- case 83:
- keyCode = Qt::Key_Delete;
- break;
- case 79:
- keyCode = Qt::Key_End;
- break;
- case 81:
- keyCode = Qt::Key_PageDown;
- break;
- case 28:
- keyCode = Qt::Key_Enter;
- break;
- case 53:
- keyCode = Qt::Key_Slash;
- break;
- case 0x1d:
- keyCode = Qt::Key_Control;
- break;
- case 0x2a:
- keyCode = Qt::Key_Print;
- break;
- case 0x38:
- keyCode = Qt::Key_Alt;
- break;
- case 0x5b:
- keyCode = Qt::Key_Super_L;
- break;
- case 0x5c:
- keyCode = Qt::Key_Super_R;
- break;
- case 0x5d:
- keyCode = Qt::Key_Menu;
- break;
-#if 0
- default:
- qDebug("extended1 code %x release %d", code, release);
- break;
-#endif
- }
- } else if (extended == 2) {
- switch (code) {
- case 0x1d:
- return;
- case 0x45:
- keyCode = Qt::Key_Pause;
- break;
- }
- } else
-#endif
- {
- if (code < keyMSize) {
- keyCode = pc101KeyM[code].key_code;
- }
-
-#if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX)
- softwareRepeat = true;
-
- switch (code) {
- case 0x7a: case 0x7b: case 0x7c: case 0x7d:
- keyCode = code - 0x7a + Qt::Key_F9;
- softwareRepeat = false;
- break;
- case 0x79:
- keyCode = Qt::Key_SysReq;
- softwareRepeat = false;
- break;
- case 0x78:
-# ifdef QT_QWS_IPAQ
- keyCode = Qt::Key_F24; // record
-# else
- keyCode = Qt::Key_Escape;
-# endif
- softwareRepeat = false;
- break;
- case 0x60:
- keyCode = Qt::Key_Return;
-# ifdef QT_QWS_IPAQ
- ipaq_return_pressed = !release;
-# endif
- break;
- case 0x67:
- keyCode = Qt::Key_Right;
- break;
- case 0x69:
- keyCode = Qt::Key_Up;
- break;
- case 0x6a:
- keyCode = Qt::Key_Down;
- break;
- case 0x6c:
- keyCode = Qt::Key_Left;
- break;
- }
-
- if (qt_screen->isTransformed()
- && keyCode >= Qt::Key_Left && keyCode <= Qt::Key_Down)
- {
- keyCode = transformDirKey(keyCode);
- }
-#endif
- /*
- Translate shift+Qt::Key_Tab to Qt::Key_Backtab
- */
- if ((keyCode == Qt::Key_Tab) && shift)
- keyCode = Qt::Key_Backtab;
- }
-
-#ifndef QT_QWS_USE_KEYCODES
- /*
- Qt::Keypad consists of extended keys 53 and 28,
- and non-extended keys 55 and 71 through 83.
- */
- if ((extended == 1) ? (code == 53 || code == 28) :
- (code == 55 || (code >= 71 && code <= 83)))
-#else
- if (code == 55 || code >= 71 && code <= 83 || code == 96
- || code == 98 || code == 118)
-#endif
- {
- keypad = Qt::KeypadModifier;
- }
-
- // Ctrl-Alt-Backspace exits qws
- if (ctrl && alt && keyCode == Qt::Key_Backspace) {
- qApp->quit();
- }
-
- if (keyCode == Qt::Key_Alt) {
- alt = !release;
- } else if (keyCode == Qt::Key_Control) {
- ctrl = !release;
- } else if (keyCode == Qt::Key_Shift) {
- shift = !release;
- } else if (keyCode == Qt::Key_CapsLock && release) {
- caps = !caps;
-#if defined(Q_OS_LINUX)
- char leds;
- ioctl(0, KDGETLED, &leds);
- leds = leds & ~LED_CAP;
- if (caps) leds |= LED_CAP;
- ioctl(0, KDSETLED, leds);
-#endif
- }
- if (keyCode != Qt::Key_unknown) {
- bool bAlt = alt;
- bool bCtrl = ctrl;
- bool bShift = shift;
- int unicode = 0;
- if (code < keyMSize) {
- if (!extended) {
- bool bCaps = shift ||
- (caps ? QChar(keyMap()[code].unicode).isLetter() : false);
- if (bCtrl)
- unicode = keyMap()[code].ctrl_unicode ? keyMap()[code].ctrl_unicode : 0xffff;
- else if (bCaps)
- unicode = keyMap()[code].shift_unicode ? keyMap()[code].shift_unicode : 0xffff;
- else
- unicode = keyMap()[code].unicode ? keyMap()[code].unicode : 0xffff;
-#ifndef QT_QWS_USE_KEYCODES
- } else if (extended==1) {
- if (code == 53)
- unicode = '/';
-#endif
- }
- }
-
- modifiers = 0;
- if (bAlt) modifiers |= Qt::AltModifier;
- if (bCtrl) modifiers |= Qt::ControlModifier;
- if (bShift) modifiers |= Qt::ShiftModifier;
- if (keypad) modifiers |= Qt::KeypadModifier;
-
- // looks wrong -- WWA
- bool repeat = false;
- if (prevuni == unicode && prevkey == keyCode && !release)
- repeat = true;
-
- processKeyEvent(unicode, keyCode, modifiers, !release, repeat);
-
- if (!release) {
- prevuni = unicode;
- prevkey = keyCode;
- } else {
- prevkey = prevuni = 0;
- }
- }
-
- if (softwareRepeat && !release)
- beginAutoRepeat(prevuni, prevkey, modifiers);
- else
- endAutoRepeat();
-
- extended = 0;
-}
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_QWS_KEYBOARD
diff --git a/src/gui/embedded/qkbdpc101_qws.h b/src/gui/embedded/qkbdpc101_qws.h
deleted file mode 100644
index f9f0104..0000000
--- a/src/gui/embedded/qkbdpc101_qws.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at qt-sales@nokia.com.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QKBDPC101_QWS_H
-#define QKBDPC101_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_PC101
-
-struct QWSKeyMap {
- uint key_code;
- ushort unicode;
- ushort shift_unicode;
- ushort ctrl_unicode;
-};
-
-class QWSPC101KeyboardHandler : public QWSKeyboardHandler
-{
-public:
- explicit QWSPC101KeyboardHandler(const QString&);
- virtual ~QWSPC101KeyboardHandler();
-
- virtual void doKey(uchar scancode);
- virtual const QWSKeyMap *keyMap() const;
-
-protected:
- bool shift;
- bool alt;
- bool ctrl;
- bool caps;
-#if defined(QT_QWS_IPAQ)
- uint ipaq_return_pressed:1;
-#endif
- uint extended:2;
- Qt::KeyboardModifiers modifiers;
- int prevuni;
- int prevkey;
-};
-
-#endif // QT_NO_QWS_KBD_PC101
-
-#endif // QT_NO_QWS_KEYBOARD
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QKBDPC101_QWS_H
diff --git a/src/gui/embedded/qkbdtty_qws.cpp b/src/gui/embedded/qkbdtty_qws.cpp
index 8311ba7..5c0dec8 100644
--- a/src/gui/embedded/qkbdtty_qws.cpp
+++ b/src/gui/embedded/qkbdtty_qws.cpp
@@ -122,9 +122,9 @@ QWSTtyKbPrivate::QWSTtyKbPrivate(QWSTtyKeyboardHandler *h, const QString &device
QStringList args = device.split(QLatin1Char(':'));
foreach (const QString &arg, args) {
- if (arg.startsWith(QLatin1String("repeat_delay=")))
+ if (arg.startsWith(QLatin1String("repeat-delay=")))
repeat_delay = arg.mid(13).toInt();
- else if (arg.startsWith(QLatin1String("repeat_rate=")))
+ else if (arg.startsWith(QLatin1String("repeat-rate=")))
repeat_rate = arg.mid(12).toInt();
else if (arg.startsWith(QLatin1String("/dev/")))
dev = arg;
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index b4c8684..21ffe7d 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -533,25 +533,22 @@ QT_BEGIN_NAMESPACE
// QRectF::intersects() returns false always if either the source or target
// rectangle's width or height are 0. This works around that problem.
-static QRectF _q_adjustedRect(const QRectF &rect)
-{
- static const qreal p = (qreal)0.00001;
- QRectF r = rect;
- if (!r.width())
- r.adjust(-p, 0, p, 0);
- if (!r.height())
- r.adjust(0, -p, 0, p);
- return r;
+static inline void _q_adjustRect(QRectF *rect)
+{
+ Q_ASSERT(rect);
+ if (!rect->width())
+ rect->adjust(-0.00001, 0, 0.00001, 0);
+ if (!rect->height())
+ rect->adjust(0, -0.00001, 0, 0.00001);
}
-static QRect _q_adjustedRect(const QRect &rect)
+static inline void _q_adjustRect(QRect *rect)
{
- QRect r = rect;
- if (!r.width())
- r.adjust(0, 0, 1, 0);
- if (!r.height())
- r.adjust(0, 0, 0, 1);
- return r;
+ Q_ASSERT(rect);
+ if (!rect->width())
+ rect->adjust(0, 0, 1, 0);
+ if (!rect->height())
+ rect->adjust(0, 0, 0, 1);
}
/*
@@ -613,6 +610,7 @@ void QGraphicsItemPrivate::updateAncestorFlag(QGraphicsItem::GraphicsItemFlag ch
case QGraphicsItem::ItemClipsChildrenToShape:
flag = AncestorClipsChildren;
enabled = flags & QGraphicsItem::ItemClipsChildrenToShape;
+ invalidateCachedClipPathRecursively(/*childrenOnly=*/true);
break;
case QGraphicsItem::ItemIgnoresTransformations:
flag = AncestorIgnoresTransformations;
@@ -779,9 +777,9 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent, bool de
if (newParent == parent)
return;
- QVariant variant;
- qVariantSetValue<QGraphicsItem *>(variant, newParent);
- newParent = qVariantValue<QGraphicsItem *>(q->itemChange(QGraphicsItem::ItemParentChange, variant));
+ const QVariant newParentVariant(q->itemChange(QGraphicsItem::ItemParentChange,
+ qVariantFromValue<QGraphicsItem *>(newParent)));
+ newParent = qVariantValue<QGraphicsItem *>(newParentVariant);
if (newParent == parent)
return;
@@ -799,11 +797,11 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent, bool de
if (!deleting)
q_ptr->prepareGeometryChange();
+ const QVariant thisPointerVariant(qVariantFromValue<QGraphicsItem *>(q));
if (parent) {
// Remove from current parent
parent->d_ptr->removeChild(q);
- qVariantSetValue<QGraphicsItem *>(variant, q);
- parent->itemChange(QGraphicsItem::ItemChildRemovedChange, variant);
+ parent->itemChange(QGraphicsItem::ItemChildRemovedChange, thisPointerVariant);
}
// Update toplevelitem list. If this item is being deleted, its parent
@@ -828,10 +826,9 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent, bool de
}
parent->d_ptr->addChild(q);
- qVariantSetValue<QGraphicsItem *>(variant, q);
- parent->itemChange(QGraphicsItem::ItemChildAddedChange, variant);
+ parent->itemChange(QGraphicsItem::ItemChildAddedChange, thisPointerVariant);
if (!implicitUpdate)
- updateHelper();
+ updateHelper(QRectF(), false, true);
// Inherit ancestor flags from the new parent.
updateAncestorFlag(QGraphicsItem::GraphicsItemFlag(-1));
@@ -862,7 +859,7 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent, bool de
setEnabledHelper(true, /* explicit = */ false);
// If the item is being deleted, the whole scene will be updated.
- updateHelper();
+ updateHelper(QRectF(), false, true);
}
}
@@ -873,10 +870,7 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent, bool de
}
// Resolve opacity.
- if (parent)
- resolveEffectiveOpacity(parent->effectiveOpacity());
- else
- resolveEffectiveOpacity(1.0);
+ updateEffectiveOpacity();
// Resolve depth.
resolveDepth(parent ? parent->d_ptr->depth : -1);
@@ -885,7 +879,7 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent, bool de
invalidateSceneTransformCache();
// Deliver post-change notification
- q->itemChange(QGraphicsItem::ItemParentHasChanged, qVariantFromValue<QGraphicsItem *>(parent));
+ q->itemChange(QGraphicsItem::ItemParentHasChanged, newParentVariant);
}
/*!
@@ -1240,7 +1234,7 @@ void QGraphicsItem::setFlags(GraphicsItemFlags flags)
int geomChangeFlagsMask = (ItemClipsChildrenToShape | ItemClipsToShape | ItemIgnoresTransformations);
bool fullUpdate = (flags & geomChangeFlagsMask) != (d_ptr->flags & geomChangeFlagsMask);
if (fullUpdate)
- d_ptr->fullUpdateHelper();
+ d_ptr->fullUpdateHelper(false, true);
// Keep the old flags to compare the diff.
GraphicsItemFlags oldFlags = this->flags();
@@ -1250,12 +1244,8 @@ void QGraphicsItem::setFlags(GraphicsItemFlags flags)
// Reresolve effective opacity if the opacity flags change.
static const quint32 opacityFlagsMask = ItemIgnoresParentOpacity | ItemDoesntPropagateOpacityToChildren;
- if ((flags & opacityFlagsMask) != (oldFlags & opacityFlagsMask)) {
- if (QGraphicsItem *p = d_ptr->parent)
- d_ptr->resolveEffectiveOpacity(p->effectiveOpacity());
- else
- d_ptr->resolveEffectiveOpacity(1.0);
- }
+ if ((flags & opacityFlagsMask) != (oldFlags & opacityFlagsMask))
+ d_ptr->updateEffectiveOpacity();
if (!(d_ptr->flags & ItemIsFocusable) && hasFocus()) {
// Clear focus on the item if it has focus when the focusable flag
@@ -1275,6 +1265,9 @@ void QGraphicsItem::setFlags(GraphicsItemFlags flags)
d_ptr->updateAncestorFlag(ItemClipsChildrenToShape);
}
+ if ((flags & ItemClipsToShape) != (oldFlags & ItemClipsToShape))
+ d_ptr->invalidateCachedClipPath();
+
if ((flags & ItemIgnoresTransformations) != (oldFlags & ItemIgnoresTransformations)) {
// Item children clipping changes. Propagate the ancestor flag to
// all children.
@@ -1282,7 +1275,7 @@ void QGraphicsItem::setFlags(GraphicsItemFlags flags)
}
// ### Why updateHelper?
- d_ptr->updateHelper();
+ d_ptr->updateHelper(QRectF(), false, true);
// Notify change.
itemChange(ItemFlagsHaveChanged, quint32(flags));
@@ -1380,9 +1373,9 @@ QString QGraphicsItem::toolTip() const
*/
void QGraphicsItem::setToolTip(const QString &toolTip)
{
- QString newCursor = itemChange(ItemToolTipChange, toolTip).toString();
- d_ptr->setExtra(QGraphicsItemPrivate::ExtraToolTip, toolTip);
- itemChange(ItemToolTipHasChanged, toolTip);
+ const QVariant toolTipVariant(itemChange(ItemToolTipChange, toolTip));
+ d_ptr->setExtra(QGraphicsItemPrivate::ExtraToolTip, toolTipVariant.toString());
+ itemChange(ItemToolTipHasChanged, toolTipVariant);
}
#endif // QT_NO_TOOLTIP
@@ -1424,12 +1417,13 @@ QCursor QGraphicsItem::cursor() const
*/
void QGraphicsItem::setCursor(const QCursor &cursor)
{
- QCursor newCursor = qVariantValue<QCursor>(itemChange(ItemCursorChange,
- qVariantFromValue<QCursor>(cursor)));
- d_ptr->setExtra(QGraphicsItemPrivate::ExtraCursor, newCursor);
+ const QVariant cursorVariant(itemChange(ItemCursorChange, qVariantFromValue<QCursor>(cursor)));
+ d_ptr->setExtra(QGraphicsItemPrivate::ExtraCursor, qVariantValue<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()))) {
@@ -1443,7 +1437,7 @@ void QGraphicsItem::setCursor(const QCursor &cursor)
}
}
}
- itemChange(ItemCursorHasChanged, qVariantFromValue<QCursor>(newCursor));
+ itemChange(ItemCursorHasChanged, cursorVariant);
}
/*!
@@ -1537,7 +1531,9 @@ void QGraphicsItemPrivate::setVisibleHelper(bool newVisible, bool explicitly, bo
return;
// Modify the property.
- newVisible = q_ptr->itemChange(QGraphicsItem::ItemVisibleChange, quint32(newVisible)).toBool();
+ const QVariant newVisibleVariant(q_ptr->itemChange(QGraphicsItem::ItemVisibleChange,
+ quint32(newVisible)));
+ newVisible = newVisibleVariant.toBool();
if (visible == quint32(newVisible))
return;
visible = newVisible;
@@ -1584,9 +1580,10 @@ void QGraphicsItemPrivate::setVisibleHelper(bool newVisible, bool explicitly, bo
}
// 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);
+ child->d_ptr->setVisibleHelper(newVisible, false, updateChildren);
}
// Enable subfocus
@@ -1598,7 +1595,7 @@ void QGraphicsItemPrivate::setVisibleHelper(bool newVisible, bool explicitly, bo
}
// Deliver post-change notification.
- q_ptr->itemChange(QGraphicsItem::ItemVisibleHasChanged, quint32(visible));
+ q_ptr->itemChange(QGraphicsItem::ItemVisibleHasChanged, newVisibleVariant);
}
/*!
@@ -1704,7 +1701,9 @@ void QGraphicsItemPrivate::setEnabledHelper(bool newEnabled, bool explicitly, bo
}
// Modify the property.
- enabled = q_ptr->itemChange(QGraphicsItem::ItemEnabledChange, quint32(newEnabled)).toBool();
+ const QVariant newEnabledVariant(q_ptr->itemChange(QGraphicsItem::ItemEnabledChange,
+ quint32(newEnabled)));
+ enabled = newEnabledVariant.toBool();
// Schedule redraw.
if (update)
@@ -1716,7 +1715,7 @@ void QGraphicsItemPrivate::setEnabledHelper(bool newEnabled, bool explicitly, bo
}
// Deliver post-change notification.
- q_ptr->itemChange(QGraphicsItem::ItemEnabledHasChanged, quint32(enabled));
+ q_ptr->itemChange(QGraphicsItem::ItemEnabledHasChanged, newEnabledVariant);
}
/*!
@@ -1803,7 +1802,8 @@ void QGraphicsItem::setSelected(bool selected)
selected = false;
if (d_ptr->selected == selected)
return;
- bool newSelected = itemChange(ItemSelectedChange, quint32(selected)).toBool();
+ const QVariant newSelectedVariant(itemChange(ItemSelectedChange, quint32(selected)));
+ bool newSelected = newSelectedVariant.toBool();
if (d_ptr->selected == newSelected)
return;
d_ptr->selected = newSelected;
@@ -1823,7 +1823,7 @@ void QGraphicsItem::setSelected(bool selected)
}
// Deliver post-change notification.
- itemChange(QGraphicsItem::ItemSelectedHasChanged, quint32(d_ptr->selected));
+ itemChange(QGraphicsItem::ItemSelectedHasChanged, newSelectedVariant);
}
/*!
@@ -1867,6 +1867,9 @@ qreal QGraphicsItem::opacity() const
*/
qreal QGraphicsItem::effectiveOpacity() const
{
+ if (!d_ptr->hasEffectiveOpacity)
+ return qreal(1.0);
+
QVariant effectiveOpacity = d_ptr->extra(QGraphicsItemPrivate::ExtraEffectiveOpacity);
return effectiveOpacity.isNull() ? qreal(1.0) : qreal(effectiveOpacity.toDouble());
}
@@ -1896,17 +1899,18 @@ qreal QGraphicsItem::effectiveOpacity() const
void QGraphicsItem::setOpacity(qreal opacity)
{
// Notify change.
- qreal newOpacity = itemChange(ItemOpacityChange, double(opacity)).toDouble();
+ const QVariant newOpacityVariant(itemChange(ItemOpacityChange, double(opacity)));
+ qreal newOpacity = newOpacityVariant.toDouble();
// Normalize.
newOpacity = qBound<qreal>(0.0, newOpacity, 1.0);
// No change? Done.
- if (qFuzzyCompare(newOpacity, this->opacity()))
+ if (qFuzzyIsNull(newOpacity - this->opacity()))
return;
// Assign local opacity.
- if (qFuzzyCompare(newOpacity, qreal(1.0))) {
+ if (qFuzzyIsNull(newOpacity - 1)) {
// Opaque, unset opacity.
d_ptr->hasOpacity = 0;
d_ptr->unsetExtra(QGraphicsItemPrivate::ExtraOpacity);
@@ -2051,7 +2055,13 @@ bool QGraphicsItem::acceptsHoverEvents() const
*/
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();
+ }
}
/*!
@@ -2061,7 +2071,7 @@ void QGraphicsItem::setAcceptHoverEvents(bool enabled)
*/
void QGraphicsItem::setAcceptsHoverEvents(bool enabled)
{
- d_ptr->acceptsHover = quint32(enabled);
+ setAcceptHoverEvents(enabled);
}
/*! \since 4.6
@@ -2379,19 +2389,22 @@ QPointF QGraphicsItem::scenePos() const
the item is also updated; otherwise it is not updated before and after the
change.
*/
-void QGraphicsItemPrivate::setPosHelper(const QPointF &pos, bool update)
+void QGraphicsItemPrivate::setPosHelper(const QPointF &pos)
{
Q_Q(QGraphicsItem);
if (this->pos == pos)
return;
// Notify the item that the position is changing.
- QPointF newPos = q->itemChange(QGraphicsItem::ItemPositionChange, pos).toPointF();
+ const QVariant newPosVariant(q->itemChange(QGraphicsItem::ItemPositionChange, pos));
+ QPointF newPos = newPosVariant.toPointF();
if (newPos == this->pos)
return;
// Update and repositition.
- if (scene && update) {
+ inSetPosHelper = 1;
+ updateCachedClipPathFromSetPosHelper(newPos);
+ if (scene) {
fullUpdateHelper(true);
q->prepareGeometryChange();
}
@@ -2399,7 +2412,8 @@ void QGraphicsItemPrivate::setPosHelper(const QPointF &pos, bool update)
invalidateSceneTransformCache();
// Send post-notification.
- q->itemChange(QGraphicsItem::ItemPositionHasChanged, newPos);
+ q->itemChange(QGraphicsItem::ItemPositionHasChanged, newPosVariant);
+ inSetPosHelper = 0;
}
/*!
@@ -2414,7 +2428,7 @@ void QGraphicsItemPrivate::setPosHelper(const QPointF &pos, bool update)
*/
void QGraphicsItem::setPos(const QPointF &pos)
{
- d_ptr->setPosHelper(pos, /* update = */ true);
+ d_ptr->setPosHelper(pos);
}
/*!
@@ -2541,10 +2555,10 @@ QTransform QGraphicsItem::sceneTransform() const
QTransform m;
if (d_ptr->hasTransform) {
m = transform();
- m *= QTransform::fromTranslate(d_ptr->pos.x(), d_ptr->pos.y());
- } else {
- // ### ? QTransform::fromTranslate(d_ptr->pos.x(), d_ptr->pos.y())
- m.translate(d_ptr->pos.x(), d_ptr->pos.y());
+ if (!d_ptr->pos.isNull())
+ m *= QTransform::fromTranslate(d_ptr->pos.x(), d_ptr->pos.y());
+ } else if (!d_ptr->pos.isNull()) {
+ m = QTransform::fromTranslate(d_ptr->pos.x(), d_ptr->pos.y());
}
// Combine with parent and add to cache.
@@ -2669,6 +2683,8 @@ QTransform QGraphicsItem::itemTransform(const QGraphicsItem *other, bool *ok) co
if (ok)
*ok = true;
const QPointF &itemPos = d_ptr->pos;
+ if (itemPos.isNull())
+ return d_ptr->hasTransform ? transform() : QTransform();
if (d_ptr->hasTransform)
return transform() * QTransform::fromTranslate(itemPos.x(), itemPos.y());
return QTransform::fromTranslate(itemPos.x(), itemPos.y());
@@ -2679,7 +2695,8 @@ QTransform QGraphicsItem::itemTransform(const QGraphicsItem *other, bool *ok) co
const QPointF &otherPos = other->d_ptr->pos;
if (other->d_ptr->hasTransform) {
QTransform otherToParent = other->transform();
- otherToParent *= QTransform::fromTranslate(otherPos.x(), otherPos.y());
+ if (!otherPos.isNull())
+ otherToParent *= QTransform::fromTranslate(otherPos.x(), otherPos.y());
return otherToParent.inverted(ok);
} else {
if (ok)
@@ -2704,11 +2721,11 @@ QTransform QGraphicsItem::itemTransform(const QGraphicsItem *other, bool *ok) co
QTransform itemToParent = QTransform::fromTranslate(itemPos.x(), itemPos.y());
if (hasTr)
- itemToParent = transform() * itemToParent;
+ itemToParent = itemPos.isNull() ? transform() : transform() * itemToParent;
QTransform otherToParent = QTransform::fromTranslate(otherPos.x(), otherPos.y());
if (otherHasTr)
- otherToParent = other->transform() * otherToParent;
+ otherToParent = otherPos.isNull() ? other->transform() : other->transform() * otherToParent;
return itemToParent * otherToParent.inverted(ok);
}
@@ -2748,7 +2765,8 @@ QTransform QGraphicsItem::itemTransform(const QGraphicsItem *other, bool *ok) co
const QGraphicsItemPrivate *pd = p->d_ptr;
if (pd->hasTransform)
x *= p->transform();
- x *= QTransform::fromTranslate(pd->pos.x(), pd->pos.y());
+ if (!pd->pos.isNull())
+ x *= QTransform::fromTranslate(pd->pos.x(), pd->pos.y());
} while ((p = p->d_ptr->parent) && p != root);
if (parentOfOther)
return x.inverted(ok);
@@ -2780,21 +2798,23 @@ void QGraphicsItem::setMatrix(const QMatrix &matrix, bool combine)
return;
// Notify the item that the matrix is changing.
- QVariant variant;
- qVariantSetValue<QMatrix>(variant, newTransform.toAffine());
- newTransform = QTransform(qVariantValue<QMatrix>(itemChange(ItemMatrixChange, variant)));
+ QVariant newTransformVariant(itemChange(ItemMatrixChange,
+ qVariantFromValue<QMatrix>(newTransform.toAffine())));
+ newTransform = QTransform(qVariantValue<QMatrix>(newTransformVariant));
if (oldTransform == newTransform)
return;
// Update and set the new transformation.
- d_ptr->fullUpdateHelper(true);
+ d_ptr->fullUpdateHelper(true, true);
prepareGeometryChange();
d_ptr->hasTransform = !newTransform.isIdentity();
d_ptr->setExtra(QGraphicsItemPrivate::ExtraTransform, newTransform);
d_ptr->invalidateSceneTransformCache();
// Send post-notification.
- itemChange(ItemTransformHasChanged, newTransform);
+ // NB! We have to change the value from QMatrix to QTransform.
+ qVariantSetValue<QTransform>(newTransformVariant, newTransform);
+ itemChange(ItemTransformHasChanged, newTransformVariant);
}
/*!
@@ -2826,21 +2846,21 @@ void QGraphicsItem::setTransform(const QTransform &matrix, bool combine)
return;
// Notify the item that the transformation matrix is changing.
- QVariant variant;
- qVariantSetValue<QTransform>(variant, newTransform);
- newTransform = qVariantValue<QTransform>(itemChange(ItemTransformChange, variant));
+ const QVariant newTransformVariant(itemChange(ItemTransformChange,
+ qVariantFromValue<QTransform>(newTransform)));
+ newTransform = qVariantValue<QTransform>(newTransformVariant);
if (oldTransform == newTransform)
return;
// Update and set the new transformation.
- d_ptr->fullUpdateHelper(true);
+ d_ptr->fullUpdateHelper(true, true);
prepareGeometryChange();
d_ptr->hasTransform = !newTransform.isIdentity();
d_ptr->setExtra(QGraphicsItemPrivate::ExtraTransform, newTransform);
d_ptr->invalidateSceneTransformCache();
// Send post-notification.
- itemChange(ItemTransformHasChanged, newTransform);
+ itemChange(ItemTransformHasChanged, newTransformVariant);
}
/*!
@@ -2988,7 +3008,8 @@ qreal QGraphicsItem::zValue() const
*/
void QGraphicsItem::setZValue(qreal z)
{
- qreal newZ = qreal(itemChange(ItemZValueChange, double(z)).toDouble());
+ const QVariant newZVariant(itemChange(ItemZValueChange, double(z)));
+ qreal newZ = qreal(newZVariant.toDouble());
if (newZ == d_ptr->z)
return;
d_ptr->z = newZ;
@@ -3000,7 +3021,7 @@ void QGraphicsItem::setZValue(qreal z)
d_ptr->scene->d_func()->invalidateSortCache();
}
- itemChange(ItemZValueHasChanged, double(newZ));
+ itemChange(ItemZValueHasChanged, newZVariant);
}
/*!
@@ -3025,7 +3046,9 @@ QRectF QGraphicsItem::childrenBoundingRect() const
QRectF childRect;
foreach (QGraphicsItem *child, children()) {
QPointF childPos = child->pos();
- QTransform matrix = child->transform() * QTransform::fromTranslate(childPos.x(), childPos.y());
+ QTransform matrix = child->transform();
+ if (!childPos.isNull())
+ matrix *= QTransform::fromTranslate(childPos.x(), childPos.y());
childRect |= matrix.mapRect(child->boundingRect() | child->childrenBoundingRect());
}
return childRect;
@@ -3157,57 +3180,79 @@ bool QGraphicsItem::isClipped() const
QPainterPath QGraphicsItem::clipPath() const
{
Q_D(const QGraphicsItem);
- QPainterPath clip;
- if (!isClipped())
- return clip;
+ if (!d->dirtyClipPath)
+ return d->emptyClipPath ? QPainterPath() : d->cachedClipPath;
+ if (!isClipped()) {
+ d_ptr->setCachedClipPath(QPainterPath());
+ return d->cachedClipPath;
+ }
+
+ const QRectF thisBoundingRect(boundingRect());
+ if (thisBoundingRect.isEmpty()) {
+ if (d_ptr->flags & ItemClipsChildrenToShape)
+ d_ptr->setEmptyCachedClipPathRecursively();
+ else
+ d_ptr->setEmptyCachedClipPath();
+ return QPainterPath();
+ }
+
+ QPainterPath clip;
// Start with the item's bounding rect.
- clip.addRect(boundingRect());
+ clip.addRect(thisBoundingRect);
- bool clipAway = false;
if (d->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren) {
- // Make list of parents up to the farthest ancestor that clips its
- // children to its shape.
- QVarLengthArray<const QGraphicsItem *, 32> clippingAncestors;
- const QGraphicsItem *parent = parentItem();
- const QGraphicsItem *clipOwner = 0;
- do {
+ const QGraphicsItem *parent = this;
+ const QGraphicsItem *lastParent = this;
+
+ // Intersect any in-between clips starting at the top and moving downwards.
+ bool foundValidClipPath = false;
+ while ((parent = parent->d_ptr->parent)) {
if (parent->d_ptr->flags & ItemClipsChildrenToShape) {
- clippingAncestors.append(parent);
- clipOwner = parent;
- }
- } while ((parent->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren) && (parent = parent->parentItem()));
+ // Map clip to the current parent and intersect with its shape/clipPath
+ clip = lastParent->itemTransform(parent).map(clip);
+ if ((foundValidClipPath = !parent->d_ptr->dirtyClipPath && parent->isClipped())) {
+ if (parent->d_ptr->emptyClipPath) {
+ if (d_ptr->flags & ItemClipsChildrenToShape)
+ d_ptr->setEmptyCachedClipPathRecursively();
+ else
+ d_ptr->setEmptyCachedClipPath();
+ return QPainterPath();
+ }
+ clip = clip.intersected(parent->d_ptr->cachedClipPath);
+ if (!(parent->d_ptr->flags & ItemClipsToShape))
+ clip = clip.intersected(parent->shape());
+ } else {
+ clip = clip.intersected(parent->shape());
+ }
- // Start with the topmost clip.
- QPainterPath parentClip = clipOwner->shape();
+ if (clip.isEmpty()) {
+ if (d_ptr->flags & ItemClipsChildrenToShape)
+ d_ptr->setEmptyCachedClipPathRecursively();
+ else
+ d_ptr->setEmptyCachedClipPath();
+ return clip;
+ }
+ lastParent = parent;
+ }
- // Intersect any in-between clips starting at the bottom and moving
- // upwards.
- for (int i = clippingAncestors.size() - 2; i >= 0; --i) {
- const QGraphicsItem *item = clippingAncestors[i];
- // ### what if itemtransform fails
- if (clipOwner)
- parentClip = clipOwner->itemTransform(item).map(parentClip);
- parentClip = parentClip.intersected(item->shape());
- if (parentClip.isEmpty()) {
- clip = parentClip;
- clipAway = true;
+ if (!(parent->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren)
+ || foundValidClipPath) {
break;
}
- clipOwner = item;
}
- if (!clipAway) {
+ if (lastParent != this) {
+ // Map clip back to the item's transform.
// ### what if itemtransform fails
- clip = clip.intersected(clipOwner->itemTransform(this).map(parentClip));
- if (clip.isEmpty())
- clipAway = true;
+ clip = lastParent->itemTransform(this).map(clip);
}
}
- if (!clipAway && d->flags & ItemClipsToShape)
+ if (d->flags & ItemClipsToShape)
clip = clip.intersected(shape());
+ d_ptr->setCachedClipPath(clip);
return clip;
}
@@ -3296,8 +3341,10 @@ bool QGraphicsItem::collidesWithPath(const QPainterPath &path, Qt::ItemSelection
return false;
}
- QRectF rectA = _q_adjustedRect(boundingRect());
- QRectF rectB = _q_adjustedRect(path.controlPointRect());
+ 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.
@@ -3306,12 +3353,11 @@ bool QGraphicsItem::collidesWithPath(const QPainterPath &path, Qt::ItemSelection
// For further testing, we need this item's shape or bounding rect.
QPainterPath thisShape;
- if (mode == Qt::IntersectsItemShape || mode == Qt::ContainsItemShape) {
+ if (mode == Qt::IntersectsItemShape || mode == Qt::ContainsItemShape)
thisShape = (isClipped() && !d_ptr->localCollisionHack) ? clipPath() : shape();
- } else {
- thisShape.addPolygon(_q_adjustedRect(boundingRect()));
- thisShape.closeSubpath();
- }
+ else
+ thisShape.addRect(rectA);
+
if (thisShape == QPainterPath()) {
// Empty shape? No collision.
return false;
@@ -3481,7 +3527,8 @@ QRegion QGraphicsItem::boundingRegion(const QTransform &itemToDeviceTransform) c
// 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 = _q_adjustedRect(itemToDeviceTransform.mapRect(boundingRect()).toRect());
+ QRect deviceRect = itemToDeviceTransform.mapRect(boundingRect()).toRect();
+ _q_adjustRect(&deviceRect);
if (granularity == 0.0)
return QRegion(deviceRect);
@@ -3611,6 +3658,24 @@ void QGraphicsItem::setBoundingRegionGranularity(qreal granularity)
/*!
\internal
+ Returns true if we can discard an update request; otherwise false.
+*/
+bool QGraphicsItemPrivate::discardUpdateRequest(bool ignoreClipping,
+ bool ignoreVisibleBit,
+ bool ignoreDirtyBit) 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 (!visible && !ignoreVisibleBit)
+ || (dirty && !ignoreDirtyBit)
+ || !scene
+ || (scene->d_func()->updateAll && scene->d_func()->hasSceneRect)
+ || (!ignoreClipping && (childrenClippedToShape() && isClippedAway()))
+ || (childrenCombineOpacity() && isFullyTransparent());
+}
+
+/*!
+ \internal
Asks the scene to mark this item's scene rect as dirty, requesting a
redraw. This does not invalidate any cache.
@@ -3619,31 +3684,16 @@ void QGraphicsItem::setBoundingRegionGranularity(qreal granularity)
only case where the item's background should be marked as dirty even when
the item isn't visible.
*/
-void QGraphicsItemPrivate::updateHelper(const QRectF &rect, bool force, bool updateCache)
+void QGraphicsItemPrivate::updateHelper(const QRectF &rect, bool force, bool maybeDirtyClipPath)
{
// 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.
- QGraphicsItemCache *cache = maybeExtraItemCache();
- if (dirty && (!updateCache || !cache || cache->allExposed))
- return;
-
- if (!scene || (scene && scene->d_func()->updateAll && scene->d_func()->hasSceneRect))
+ if (discardUpdateRequest(/*ignoreClipping=*/maybeDirtyClipPath, /*ignoreVisibleBit=*/force))
return;
- if (updateCache && QGraphicsItem::CacheMode(cacheMode) != QGraphicsItem::NoCache) {
- if (rect.isNull()) {
- cache->allExposed = true;
- cache->exposed.clear();
- } else {
- cache->exposed.append(rect);
- }
- }
-
- if (!dirty && scene && (visible || force)) {
- if (rect.isNull())
- dirty = 1;
- scene->itemUpdated(q_ptr, rect);
- }
+ if (rect.isNull())
+ dirty = 1;
+ scene->itemUpdated(q_ptr, rect);
}
/*!
@@ -3651,21 +3701,25 @@ void QGraphicsItemPrivate::updateHelper(const QRectF &rect, bool force, bool upd
Propagates updates to \a item and all its children.
*/
-void QGraphicsItemPrivate::fullUpdateHelper(bool childrenOnly)
+void QGraphicsItemPrivate::fullUpdateHelper(bool childrenOnly, bool maybeDirtyClipPath)
{
- // 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.
- if (!scene || (scene && scene->d_func()->updateAll && scene->d_func()->hasSceneRect))
+ if (discardUpdateRequest(/*ignoreClipping=*/maybeDirtyClipPath,
+ /*ignoreVisibleBit=*/false,
+ /*ignoreDirtyBit=*/true)) {
return;
- if (!childrenOnly && !dirty)
- updateHelper();
- if (children.isEmpty() || dirtyChildren)
- return;
- if (flags & QGraphicsItem::ItemClipsChildrenToShape) {
- // ### mark all children dirty?
+ }
+
+ if (!childrenOnly && !dirty) {
+ // Effectively the same as updateHelper(QRectF(), false, maybeDirtyClipPath).
+ dirty = 1;
+ scene->itemUpdated(q_ptr, QRectF());
+ }
+
+ if (dirtyChildren || childrenClippedToShape()) {
// Unnecessary to update children as well.
return;
}
+
if (ancestorFlags & AncestorClipsChildren) {
Q_Q(QGraphicsItem);
// Check if we can avoid updating all children.
@@ -3688,10 +3742,36 @@ void QGraphicsItemPrivate::fullUpdateHelper(bool childrenOnly)
}
}
foreach (QGraphicsItem *child, children)
- child->d_ptr->fullUpdateHelper();
+ child->d_ptr->fullUpdateHelper(false, maybeDirtyClipPath);
dirtyChildren = 1;
}
+static inline bool allChildrenCombineOpacityHelper(QGraphicsItem *parent)
+{
+ Q_ASSERT(parent);
+ if (parent->flags() & QGraphicsItem::ItemDoesntPropagateOpacityToChildren)
+ return false;
+
+ const QList<QGraphicsItem *> children(parent->childItems());
+ for (int i = 0; i < children.size(); ++i) {
+ if (children.at(i)->flags() & QGraphicsItem::ItemIgnoresParentOpacity)
+ return false;
+ }
+ return true;
+}
+
+void QGraphicsItemPrivate::updateEffectiveOpacity()
+{
+ Q_Q(QGraphicsItem);
+ if (parent) {
+ resolveEffectiveOpacity(parent->effectiveOpacity());
+ parent->d_ptr->allChildrenCombineOpacity = allChildrenCombineOpacityHelper(parent);
+ } else {
+ resolveEffectiveOpacity(1.0);
+ }
+ allChildrenCombineOpacity = allChildrenCombineOpacityHelper(q);
+}
+
/*!
\internal
@@ -3716,7 +3796,14 @@ void QGraphicsItemPrivate::resolveEffectiveOpacity(qreal parentEffectiveOpacity)
}
// Set this item's resolved opacity.
- setExtra(ExtraEffectiveOpacity, myEffectiveOpacity);
+ if (qFuzzyIsNull(myEffectiveOpacity - 1)) {
+ // Opaque, unset effective opacity.
+ hasEffectiveOpacity = 0;
+ unsetExtra(ExtraEffectiveOpacity);
+ } else {
+ hasEffectiveOpacity = 1;
+ setExtra(ExtraEffectiveOpacity, myEffectiveOpacity);
+ }
// Resolve children always.
for (int i = 0; i < children.size(); ++i)
@@ -3807,6 +3894,109 @@ void QGraphicsItemPrivate::removeExtraItemCache()
unsetExtra(ExtraCacheData);
}
+void QGraphicsItemPrivate::setEmptyCachedClipPathRecursively(const QRectF &emptyIfOutsideThisRect)
+{
+ setEmptyCachedClipPath();
+
+ const bool checkRect = !emptyIfOutsideThisRect.isNull()
+ && !(flags & QGraphicsItem::ItemClipsChildrenToShape);
+ for (int i = 0; i < children.size(); ++i) {
+ if (!checkRect) {
+ children.at(i)->d_ptr->setEmptyCachedClipPathRecursively();
+ continue;
+ }
+
+ QGraphicsItem *child = children.at(i);
+ const QRectF rect = child->mapRectFromParent(emptyIfOutsideThisRect);
+ if (rect.intersects(child->boundingRect()))
+ child->d_ptr->invalidateCachedClipPathRecursively(false, rect);
+ else
+ child->d_ptr->setEmptyCachedClipPathRecursively(rect);
+ }
+}
+
+void QGraphicsItemPrivate::invalidateCachedClipPathRecursively(bool childrenOnly, const QRectF &emptyIfOutsideThisRect)
+{
+ if (!childrenOnly)
+ invalidateCachedClipPath();
+
+ const bool checkRect = !emptyIfOutsideThisRect.isNull();
+ for (int i = 0; i < children.size(); ++i) {
+ if (!checkRect) {
+ children.at(i)->d_ptr->invalidateCachedClipPathRecursively(false);
+ continue;
+ }
+
+ QGraphicsItem *child = children.at(i);
+ const QRectF rect = child->mapRectFromParent(emptyIfOutsideThisRect);
+ if (rect.intersects(child->boundingRect()))
+ child->d_ptr->invalidateCachedClipPathRecursively(false, rect);
+ else
+ child->d_ptr->setEmptyCachedClipPathRecursively(rect);
+ }
+}
+
+void QGraphicsItemPrivate::updateCachedClipPathFromSetPosHelper(const QPointF &newPos)
+{
+ Q_ASSERT(inSetPosHelper);
+
+ if (!(ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren))
+ return; // Not clipped by any ancestor.
+
+ // Find closest clip ancestor and transform.
+ Q_Q(QGraphicsItem);
+ QTransform thisToParentTransform = hasTransform
+ ? q->transform() * QTransform::fromTranslate(newPos.x(), newPos.y())
+ : QTransform::fromTranslate(newPos.x(), newPos.y());
+ QGraphicsItem *clipParent = parent;
+ while (clipParent && !(clipParent->d_ptr->flags & QGraphicsItem::ItemClipsChildrenToShape)) {
+ if (clipParent->d_ptr->hasTransform)
+ thisToParentTransform *= clipParent->transform();
+ if (!clipParent->d_ptr->pos.isNull()) {
+ thisToParentTransform *= QTransform::fromTranslate(clipParent->d_ptr->pos.x(),
+ clipParent->d_ptr->pos.y());
+ }
+ clipParent = clipParent->d_ptr->parent;
+ }
+
+ // thisToParentTransform is now the same as q->itemTransform(clipParent), except
+ // that the new position (which is not yet set on the item) is taken into account.
+ Q_ASSERT(clipParent);
+ Q_ASSERT(clipParent->d_ptr->flags & QGraphicsItem::ItemClipsChildrenToShape);
+
+ // From here everything is calculated in clip parent's coordinates.
+ const QRectF parentBoundingRect(clipParent->boundingRect());
+ const QRectF thisBoundingRect(thisToParentTransform.mapRect(q->boundingRect()));
+
+ if (!parentBoundingRect.intersects(thisBoundingRect)) {
+ // Item is moved outside the clip parent's bounding rect,
+ // i.e. it is fully clipped and the clip path is empty.
+ if (flags & QGraphicsItem::ItemClipsChildrenToShape)
+ setEmptyCachedClipPathRecursively();
+ else
+ setEmptyCachedClipPathRecursively(thisToParentTransform.inverted().mapRect(parentBoundingRect));
+ return;
+ }
+
+ const QPainterPath parentClip(clipParent->isClipped() ? clipParent->clipPath() : clipParent->shape());
+ if (parentClip.contains(thisBoundingRect))
+ return; // Item is inside the clip parent's shape. No update required.
+
+ const QRectF parentClipRect(parentClip.controlPointRect());
+ if (!parentClipRect.intersects(thisBoundingRect)) {
+ // Item is moved outside the clip parent's shape,
+ // i.e. it is fully clipped and the clip path is empty.
+ if (flags & QGraphicsItem::ItemClipsChildrenToShape)
+ setEmptyCachedClipPathRecursively();
+ else
+ setEmptyCachedClipPathRecursively(thisToParentTransform.inverted().mapRect(parentClipRect));
+ } else {
+ // Item is partially inside the clip parent's shape,
+ // i.e. the cached clip path must be invalidated.
+ invalidateCachedClipPathRecursively(false, thisToParentTransform.inverted().mapRect(parentClipRect));
+ }
+}
+
/*!
\internal
@@ -3837,7 +4027,25 @@ bool QGraphicsItemPrivate::isProxyWidget() const
*/
void QGraphicsItem::update(const QRectF &rect)
{
- d_ptr->updateHelper(rect, /* force = */ false, /* updateCache = */ true);
+ if ((rect.isEmpty() && !rect.isNull()) || d_ptr->discardUpdateRequest())
+ return;
+
+ if (CacheMode(d_ptr->cacheMode) != NoCache) {
+ QGraphicsItemCache *cache = d_ptr->extraItemCache();
+ if (!cache->allExposed) {
+ if (rect.isNull()) {
+ cache->allExposed = true;
+ cache->exposed.clear();
+ } else {
+ cache->exposed.append(rect);
+ }
+ }
+ }
+
+ // Effectively the same as updateHelper(rect);
+ if (rect.isNull())
+ d_ptr->dirty = 1;
+ d_ptr->scene->itemUpdated(this, rect);
}
/*!
@@ -3908,7 +4116,7 @@ void QGraphicsItem::scroll(qreal dx, qreal dy, const QRectF &rect)
return;
if (d->cacheMode != NoCache) {
QGraphicsItemCache *c;
- bool scrollCache = qFuzzyCompare(dx - int(dx), qreal(0.0)) && qFuzzyCompare(dy - int(dy), qreal(0.0))
+ bool scrollCache = qFuzzyIsNull(dx - int(dx)) && qFuzzyIsNull(dy - int(dy))
&& (c = (QGraphicsItemCache *)qVariantValue<void *>(d_ptr->extra(QGraphicsItemPrivate::ExtraCacheData)))
&& (d->cacheMode == ItemCoordinateCache && !c->fixedSize.isValid());
if (scrollCache) {
@@ -4102,7 +4310,9 @@ QPointF QGraphicsItem::mapToItem(const QGraphicsItem *item, const QPointF &point
*/
QPointF QGraphicsItem::mapToParent(const QPointF &point) const
{
- return d_ptr->pos + (d_ptr->hasTransform ? transform().map(point) : point);
+ if (!d_ptr->hasTransform)
+ return point + d_ptr->pos;
+ return transform().map(point) + d_ptr->pos;
}
/*!
@@ -4168,8 +4378,8 @@ QPolygonF QGraphicsItem::mapToItem(const QGraphicsItem *item, const QRectF &rect
QPolygonF QGraphicsItem::mapToParent(const QRectF &rect) const
{
if (!d_ptr->hasTransform)
- return QPolygonF(rect.translated(d_ptr->pos));
- return transform().map(rect.translated(d_ptr->pos));
+ return rect.translated(d_ptr->pos);
+ return transform().map(rect).translated(d_ptr->pos);
}
/*!
@@ -4236,8 +4446,8 @@ QRectF QGraphicsItem::mapRectToItem(const QGraphicsItem *item, const QRectF &rec
*/
QRectF QGraphicsItem::mapRectToParent(const QRectF &rect) const
{
- QRectF r = rect.translated(d_ptr->pos.x(), d_ptr->pos.y());
- return !d_ptr->hasTransform ? r : transform().mapRect(r);
+ QRectF r = !d_ptr->hasTransform ? rect : transform().mapRect(rect);
+ return r.translated(d_ptr->pos);
}
/*!
@@ -4368,9 +4578,9 @@ QPolygonF QGraphicsItem::mapToItem(const QGraphicsItem *item, const QPolygonF &p
*/
QPolygonF QGraphicsItem::mapToParent(const QPolygonF &polygon) const
{
- QPolygonF p = polygon;
- p.translate(d_ptr->pos);
- return d_ptr->hasTransform ? transform().map(p) : p;
+ if (!d_ptr->hasTransform)
+ return polygon.translated(d_ptr->pos);
+ return transform().map(polygon).translated(d_ptr->pos);
}
/*!
@@ -4412,7 +4622,9 @@ QPainterPath QGraphicsItem::mapToItem(const QGraphicsItem *item, const QPainterP
*/
QPainterPath QGraphicsItem::mapToParent(const QPainterPath &path) const
{
- return d_ptr->parent ? itemTransform(d_ptr->parent).map(path) : mapToScene(path);
+ if (!d_ptr->hasTransform)
+ return path.translated(d_ptr->pos);
+ return transform().map(path).translated(d_ptr->pos);
}
/*!
@@ -4627,9 +4839,9 @@ QPainterPath QGraphicsItem::mapFromItem(const QGraphicsItem *item, const QPainte
*/
QPainterPath QGraphicsItem::mapFromParent(const QPainterPath &path) const
{
- if (d_ptr->parent)
- return d_ptr->parent->itemTransform(this).map(path);
- return mapFromScene(path);
+ QPainterPath p(path);
+ p.translate(-d_ptr->pos);
+ return d_ptr->hasTransform ? transform().inverted().map(p) : p;
}
/*!
@@ -5642,11 +5854,18 @@ void QGraphicsItem::removeFromIndex()
void QGraphicsItem::prepareGeometryChange()
{
if (d_ptr->scene) {
- d_ptr->updateHelper();
-
+ d_ptr->updateHelper(QRectF(), false, /*maybeDirtyClipPath=*/!d_ptr->inSetPosHelper);
QGraphicsScenePrivate *scenePrivate = d_ptr->scene->d_func();
scenePrivate->removeFromIndex(this);
}
+
+ if (d_ptr->inSetPosHelper)
+ return;
+
+ if (d_ptr->flags & ItemClipsChildrenToShape)
+ d_ptr->invalidateCachedClipPathRecursively();
+ else
+ d_ptr->invalidateCachedClipPath();
}
/*!
@@ -5661,7 +5880,7 @@ static void qt_graphicsItem_highlightSelected(
QGraphicsItem *item, QPainter *painter, const QStyleOptionGraphicsItem *option)
{
const QRectF murect = painter->transform().mapRect(QRectF(0, 0, 1, 1));
- if (qFuzzyCompare(qMax(murect.width(), murect.height()) + 1, 1))
+ if (qFuzzyIsNull(qMax(murect.width(), murect.height())))
return;
const QRectF mbrect = painter->transform().mapRect(item->boundingRect());
@@ -8423,6 +8642,7 @@ void QGraphicsSimpleTextItem::setText(const QString &text)
return;
d->text = text;
d->updateBoundingRect();
+ update();
}
/*!
@@ -8684,13 +8904,17 @@ void QGraphicsItemGroup::addToGroup(QGraphicsItem *item)
QTransform oldSceneMatrix = item->sceneTransform();
item->setPos(mapFromItem(item, 0, 0));
item->setParentItem(this);
- item->setTransform(oldSceneMatrix
- * sceneTransform().inverted()
- * QTransform::fromTranslate(-item->x(), -item->y()));
+ QTransform newItemTransform(oldSceneMatrix);
+ newItemTransform *= sceneTransform().inverted();
+ if (!item->pos().isNull())
+ newItemTransform *= QTransform::fromTranslate(-item->x(), -item->y());
+ item->setTransform(newItemTransform);
item->d_func()->setIsMemberOfGroup(true);
prepareGeometryChange();
- d->itemsBoundingRect |= (item->transform() * QTransform::fromTranslate(item->x(), item->y()))
- .mapRect(item->boundingRect() | item->childrenBoundingRect());
+ QTransform itemTransform(item->transform());
+ if (!item->pos().isNull())
+ itemTransform *= QTransform::fromTranslate(item->x(), item->y());
+ d->itemsBoundingRect |= itemTransform.mapRect(item->boundingRect() | item->childrenBoundingRect());
update();
}
diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h
index 228368c..b1184fb 100644
--- a/src/gui/graphicsview/qgraphicsitem_p.h
+++ b/src/gui/graphicsview/qgraphicsitem_p.h
@@ -134,10 +134,15 @@ public:
hasBoundingRegionGranularity(0),
flags(0),
hasOpacity(0),
+ hasEffectiveOpacity(0),
isWidget(0),
dirty(0),
dirtyChildren(0),
localCollisionHack(0),
+ dirtyClipPath(1),
+ emptyClipPath(0),
+ inSetPosHelper(0),
+ allChildrenCombineOpacity(1),
acceptTouchEvents(0),
globalStackingOrder(-1),
sceneTransformIndex(-1),
@@ -159,11 +164,15 @@ public:
virtual QVariant inputMethodQueryHelper(Qt::InputMethodQuery query) const;
static bool movableAncestorIsSelected(const QGraphicsItem *item);
- void setPosHelper(const QPointF &pos, bool update);
+ void setPosHelper(const QPointF &pos);
void setVisibleHelper(bool newVisible, bool explicitly, bool update = true);
void setEnabledHelper(bool newEnabled, bool explicitly, bool update = true);
- void updateHelper(const QRectF &rect = QRectF(), bool force = false, bool updateCache = false);
- void fullUpdateHelper(bool childrenOnly = false);
+ bool discardUpdateRequest(bool ignoreClipping = false,
+ bool ignoreVisibleBit = false,
+ bool ignoreDirtyBit = false) const;
+ void updateHelper(const QRectF &rect = QRectF(), bool force = false, bool maybeDirtyClipPath = false);
+ void fullUpdateHelper(bool childrenOnly = false, bool maybeDirtyClipPath = false);
+ void updateEffectiveOpacity();
void resolveEffectiveOpacity(qreal effectiveParentOpacity);
void resolveDepth(int parentDepth);
void invalidateSceneTransformCache();
@@ -239,6 +248,47 @@ public:
QGraphicsItemCache *extraItemCache() const;
void removeExtraItemCache();
+ inline void setCachedClipPath(const QPainterPath &path)
+ {
+ cachedClipPath = path;
+ dirtyClipPath = 0;
+ emptyClipPath = 0;
+ }
+
+ inline void setEmptyCachedClipPath()
+ {
+ emptyClipPath = 1;
+ dirtyClipPath = 0;
+ }
+
+ void setEmptyCachedClipPathRecursively(const QRectF &emptyIfOutsideThisRect = QRectF());
+
+ inline void invalidateCachedClipPath()
+ { /*static int count = 0 ;qWarning("%i", ++count);*/ dirtyClipPath = 1; emptyClipPath = 0; }
+
+ void invalidateCachedClipPathRecursively(bool childrenOnly = false, const QRectF &emptyIfOutsideThisRect = QRectF());
+ void updateCachedClipPathFromSetPosHelper(const QPointF &newPos);
+
+ inline bool isFullyTransparent() const
+ { return hasEffectiveOpacity && qFuzzyIsNull(q_func()->effectiveOpacity()); }
+
+ inline bool childrenCombineOpacity() const
+ { return allChildrenCombineOpacity || children.isEmpty(); }
+
+ inline bool isClippedAway() const
+ { return !dirtyClipPath && q_func()->isClipped() && (emptyClipPath || cachedClipPath.isEmpty()); }
+
+ inline bool childrenClippedToShape() const
+ { return (flags & QGraphicsItem::ItemClipsChildrenToShape) || children.isEmpty(); }
+
+ inline bool isInvisible() const
+ {
+ return !visible
+ || (childrenClippedToShape() && isClippedAway())
+ || (childrenCombineOpacity() && isFullyTransparent());
+ }
+
+ QPainterPath cachedClipPath;
QPointF pos;
qreal z;
QGraphicsScene *scene;
@@ -269,10 +319,15 @@ public:
// New 32 bytes
quint32 hasOpacity : 1;
+ quint32 hasEffectiveOpacity : 1;
quint32 isWidget : 1;
quint32 dirty : 1;
quint32 dirtyChildren : 1;
quint32 localCollisionHack : 1;
+ quint32 dirtyClipPath : 1;
+ quint32 emptyClipPath : 1;
+ quint32 inSetPosHelper : 1;
+ quint32 allChildrenCombineOpacity : 1;
quint32 acceptTouchEvents : 1;
// Optional stacking order
diff --git a/src/gui/graphicsview/qgraphicsproxywidget.cpp b/src/gui/graphicsview/qgraphicsproxywidget.cpp
index 1d2721b..e660879 100644
--- a/src/gui/graphicsview/qgraphicsproxywidget.cpp
+++ b/src/gui/graphicsview/qgraphicsproxywidget.cpp
@@ -177,6 +177,10 @@ QT_BEGIN_NAMESPACE
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
*/
@@ -1033,7 +1037,7 @@ void QGraphicsProxyWidget::dragMoveEvent(QGraphicsSceneDragDropEvent *event)
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());
+ dragEnter.setDropAction(event->proposedAction());
QApplication::sendEvent(receiver, &dragEnter);
event->setAccepted(dragEnter.isAccepted());
event->setDropAction(dragEnter.dropAction());
@@ -1431,7 +1435,7 @@ int QGraphicsProxyWidget::type() const
Creates a proxy widget for the given \a child of the widget
contained in this proxy.
-
+
This function makes it possible to aquire proxies for
non top-level widgets. For instance, you can embed a dialog,
and then transform only one of its widgets.
diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp
index 2e714cb..52c96f2 100644
--- a/src/gui/graphicsview/qgraphicsscene.cpp
+++ b/src/gui/graphicsview/qgraphicsscene.cpp
@@ -292,15 +292,21 @@ static inline bool QRectF_intersects(const QRectF &s, const QRectF &r)
// QRectF::intersects() returns false always if either the source or target
// rectangle's width or height are 0. This works around that problem.
-static QRectF _q_adjustedRect(const QRectF &rect)
+static inline void _q_adjustRect(QRectF *rect)
{
- static const qreal p = (qreal)0.00001;
- QRectF r = rect;
- if (!r.width())
- r.adjust(-p, 0, p, 0);
- if (!r.height())
- r.adjust(0, -p, 0, p);
- return r;
+ Q_ASSERT(rect);
+ if (!rect->width())
+ rect->adjust(-0.00001, 0, 0.00001, 0);
+ if (!rect->height())
+ rect->adjust(0, -0.00001, 0, 0.00001);
+}
+
+static inline QRectF adjustedItemBoundingRect(const QGraphicsItem *item)
+{
+ Q_ASSERT(item);
+ QRectF boundingRect(item->boundingRect());
+ _q_adjustRect(&boundingRect);
+ return boundingRect;
}
static void _q_hoverFromMouseEvent(QGraphicsSceneHoverEvent *hover, const QGraphicsSceneMouseEvent *mouseEvent)
@@ -345,6 +351,8 @@ QGraphicsScenePrivate::QGraphicsScenePrivate()
dragDropItem(0),
enterWidget(0),
lastDropAction(Qt::IgnoreAction),
+ allItemsIgnoreHoverEvents(true),
+ allItemsUseDefaultCursor(true),
painterStateProtection(true),
sortCacheEnabled(false),
updatingSortCache(false),
@@ -656,10 +664,11 @@ void QGraphicsScenePrivate::_q_updateLater()
*/
void QGraphicsScenePrivate::_q_polishItems()
{
+ const QVariant booleanTrueVariant(true);
foreach (QGraphicsItem *item, unpolishedItems) {
if (!item->d_ptr->explicitlyHidden) {
- item->itemChange(QGraphicsItem::ItemVisibleChange, true);
- item->itemChange(QGraphicsItem::ItemVisibleHasChanged, true);
+ item->itemChange(QGraphicsItem::ItemVisibleChange, booleanTrueVariant);
+ item->itemChange(QGraphicsItem::ItemVisibleHasChanged, booleanTrueVariant);
}
if (item->isWidget()) {
QEvent event(QEvent::Polish);
@@ -757,6 +766,15 @@ void QGraphicsScenePrivate::_q_removeItemLater(QGraphicsItem *item)
unpolishedItems.removeAll(item);
dirtyItems.removeAll(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;
+ }
+
// Remove from scene transform cache
int transformIndex = item->d_func()->sceneTransformIndex;
if (transformIndex != -1) {
@@ -1040,6 +1058,12 @@ void QGraphicsScenePrivate::clearKeyboardGrabber()
ungrabKeyboard(keyboardGrabberItems.first());
}
+void QGraphicsScenePrivate::enableMouseTrackingOnViews()
+{
+ foreach (QGraphicsView *view, views)
+ view->viewport()->setMouseTracking(true);
+}
+
/*!
Returns all items for the screen position in \a event.
*/
@@ -1371,6 +1395,48 @@ QGraphicsWidget *QGraphicsScenePrivate::windowForItem(const QGraphicsItem *item)
return 0;
}
+
+QList<QGraphicsItem *> QGraphicsScenePrivate::items_helper(const QPointF &pos) const
+{
+ QList<QGraphicsItem *> items;
+
+ // The index returns a rough estimate of what items are inside the rect.
+ // Refine it by iterating through all returned items.
+ QRectF adjustedRect = QRectF(pos, QSize(1,1));
+ foreach (QGraphicsItem *item, estimateItemsInRect(adjustedRect)) {
+ // Find the item's scene transform in a clever way.
+ QTransform x = item->sceneTransform();
+ bool keep = false;
+
+ // ### _q_adjustedRect is only needed because QRectF::intersects,
+ // QRectF::contains and QTransform::map() and friends don't work with
+ // flat rectangles.
+ const QRectF br(adjustedItemBoundingRect(item));
+ // Rect intersects/contains item's shape
+ if (QRectF_intersects(adjustedRect, x.mapRect(br))) {
+ bool ok;
+ QTransform xinv = x.inverted(&ok);
+ if (ok) {
+ if (item->contains(xinv.map(pos))) {
+ items << item;
+ keep = true;
+ }
+ }
+ }
+
+ if (keep && (item->flags() & QGraphicsItem::ItemClipsChildrenToShape)) {
+ // Recurse into children that clip children.
+ bool ok;
+ QTransform xinv = x.inverted(&ok);
+ if (ok)
+ childItems_helper(&items, item, xinv.map(pos));
+ }
+ }
+
+ sortItems(&items, Qt::AscendingOrder, sortCacheEnabled);
+ return items;
+}
+
QList<QGraphicsItem *> QGraphicsScenePrivate::items_helper(const QRectF &rect,
Qt::ItemSelectionMode mode,
Qt::SortOrder order) const
@@ -1381,7 +1447,8 @@ QList<QGraphicsItem *> QGraphicsScenePrivate::items_helper(const QRectF &rect,
// The index returns a rough estimate of what items are inside the rect.
// Refine it by iterating through all returned items.
- QRectF adjustedRect = _q_adjustedRect(rect);
+ QRectF adjustedRect(rect);
+ _q_adjustRect(&adjustedRect);
foreach (QGraphicsItem *item, estimateItemsInRect(adjustedRect)) {
// Find the item's scene transform in a clever way.
QTransform x = item->sceneTransform();
@@ -1390,7 +1457,7 @@ QList<QGraphicsItem *> QGraphicsScenePrivate::items_helper(const QRectF &rect,
// ### _q_adjustedRect is only needed because QRectF::intersects,
// QRectF::contains and QTransform::map() and friends don't work with
// flat rectangles.
- QRectF br = _q_adjustedRect(item->boundingRect());
+ const QRectF br(adjustedItemBoundingRect(item));
if (mode >= Qt::ContainsItemBoundingRect) {
// Rect intersects/contains item's bounding rect
QRectF mbr = x.mapRect(br);
@@ -1405,7 +1472,7 @@ QList<QGraphicsItem *> QGraphicsScenePrivate::items_helper(const QRectF &rect,
bool ok;
QTransform xinv = x.inverted(&ok);
if (ok) {
- if (path == QPainterPath())
+ if (path.isEmpty())
path.addRect(rect);
if (itemCollidesWithPath(item, xinv.map(path), mode)) {
items << item;
@@ -1442,7 +1509,8 @@ QList<QGraphicsItem *> QGraphicsScenePrivate::items_helper(const QPolygonF &poly
{
QList<QGraphicsItem *> items;
- QRectF polyRect = _q_adjustedRect(polygon.boundingRect());
+ QRectF polyRect(polygon.boundingRect());
+ _q_adjustRect(&polyRect);
QPainterPath path;
// The index returns a rough estimate of what items are inside the rect.
@@ -1455,7 +1523,7 @@ QList<QGraphicsItem *> QGraphicsScenePrivate::items_helper(const QPolygonF &poly
// ### _q_adjustedRect is only needed because QRectF::intersects,
// QRectF::contains and QTransform::map() and friends don't work with
// flat rectangles.
- QRectF br = _q_adjustedRect(item->boundingRect());
+ const QRectF br(adjustedItemBoundingRect(item));
if (mode >= Qt::ContainsItemBoundingRect) {
// Polygon contains/intersects item's bounding rect
if (path == QPainterPath())
@@ -1500,21 +1568,47 @@ QList<QGraphicsItem *> QGraphicsScenePrivate::items_helper(const QPainterPath &p
Qt::SortOrder order) const
{
QList<QGraphicsItem *> items;
+ QRectF pathRect(path.controlPointRect());
+ _q_adjustRect(&pathRect);
+
// The index returns a rough estimate of what items are inside the rect.
// Refine it by iterating through all returned items.
- foreach (QGraphicsItem *item, estimateItemsInRect(_q_adjustedRect(path.controlPointRect()))) {
+ foreach (QGraphicsItem *item, estimateItemsInRect(pathRect)) {
// Find the item's scene transform in a clever way.
QTransform x = item->sceneTransform();
- bool ok;
- QTransform xinv = x.inverted(&ok);
- if (ok) {
- QPainterPath mappedPath = xinv.map(path);
- if (itemCollidesWithPath(item, mappedPath, mode)) {
+ bool keep = false;
+
+ // ### _q_adjustedRect is only needed because QRectF::intersects,
+ // QRectF::contains and QTransform::map() and friends don't work with
+ // flat rectangles.
+ const QRectF br(adjustedItemBoundingRect(item));
+ if (mode >= Qt::ContainsItemBoundingRect) {
+ // Path contains/intersects item's bounding rect
+ if ((mode == Qt::IntersectsItemBoundingRect && path.intersects(x.mapRect(br)))
+ || (mode == Qt::ContainsItemBoundingRect && path.contains(x.mapRect(br)))) {
items << item;
- if (item->flags() & QGraphicsItem::ItemClipsChildrenToShape)
- childItems_helper(&items, item, mappedPath, mode);
+ keep = true;
+ }
+ } else {
+ // Path contains/intersects item's shape
+ if (QRectF_intersects(pathRect, x.mapRect(br))) {
+ bool ok;
+ QTransform xinv = x.inverted(&ok);
+ if (ok) {
+ if (itemCollidesWithPath(item, xinv.map(path), mode)) {
+ items << item;
+ keep = true;
+ }
+ }
}
}
+
+ if (keep && (item->flags() & QGraphicsItem::ItemClipsChildrenToShape)) {
+ bool ok;
+ QTransform xinv = x.inverted(&ok);
+ if (ok)
+ childItems_helper(&items, item, xinv.map(path), mode);
+ }
}
if (order != Qt::SortOrder(-1))
@@ -1524,13 +1618,13 @@ QList<QGraphicsItem *> QGraphicsScenePrivate::items_helper(const QPainterPath &p
void QGraphicsScenePrivate::childItems_helper(QList<QGraphicsItem *> *items,
const QGraphicsItem *parent,
- const QRectF &rect,
- Qt::ItemSelectionMode mode) const
+ const QPointF &pos) const
{
- QPainterPath path;
bool parentClip = (parent->flags() & QGraphicsItem::ItemClipsChildrenToShape);
- QRectF r = !parentClip ? _q_adjustedRect(rect) : _q_adjustedRect(rect).intersected(_q_adjustedRect(parent->boundingRect()));
- if (r.isEmpty())
+ if (parentClip && parent->d_ptr->isClippedAway())
+ return;
+ // ### is this needed?
+ if (parentClip && !parent->boundingRect().contains(pos))
return;
QList<QGraphicsItem *> &children = parent->d_ptr->children;
@@ -1540,31 +1634,73 @@ void QGraphicsScenePrivate::childItems_helper(QList<QGraphicsItem *> *items,
continue;
// Skip invisible items and all their children.
- if (!item->d_ptr->visible || qFuzzyCompare(item->effectiveOpacity(), qreal(0.0)))
+ if (item->d_ptr->isInvisible())
continue;
- // ### _q_adjustedRect is only needed because QRectF::intersects,
- // QRectF::contains and QTransform::map() and friends don't work with
- // flat rectangles.
- QRectF br = _q_adjustedRect(item->boundingRect());
- QRectF mbr = item->mapRectToParent(br);
bool keep = false;
- if (mode >= Qt::ContainsItemBoundingRect) {
- // Rect intersects/contains item's bounding rect
- if ((mode == Qt::IntersectsItemBoundingRect && QRectF_intersects(rect, mbr))
- || (mode == Qt::ContainsItemBoundingRect && rect != mbr && rect.contains(br))) {
+ if (!item->d_ptr->isClippedAway()) {
+ if (item->contains(item->mapFromParent(pos))) {
items->append(item);
keep = true;
}
- } else {
- // Rect intersects/contains item's shape
- if (QRectF_intersects(rect, mbr)) {
- if (path == QPainterPath())
- path.addRect(rect);
- if (itemCollidesWithPath(item, item->mapFromParent(path), mode)) {
+ }
+
+ if ((keep || !(item->flags() & QGraphicsItem::ItemClipsChildrenToShape)) && !item->d_ptr->children.isEmpty())
+ // Recurse into children.
+ childItems_helper(items, item, item->mapFromParent(pos));
+ }
+}
+
+
+void QGraphicsScenePrivate::childItems_helper(QList<QGraphicsItem *> *items,
+ const QGraphicsItem *parent,
+ const QRectF &rect,
+ Qt::ItemSelectionMode mode) const
+{
+ bool parentClip = (parent->flags() & QGraphicsItem::ItemClipsChildrenToShape);
+ if (parentClip && parent->d_ptr->isClippedAway())
+ return;
+ QRectF adjustedRect(rect);
+ _q_adjustRect(&adjustedRect);
+ QRectF r = !parentClip ? adjustedRect : adjustedRect.intersected(adjustedItemBoundingRect(parent));
+ if (r.isEmpty())
+ return;
+
+ QPainterPath path;
+ QList<QGraphicsItem *> &children = parent->d_ptr->children;
+ for (int i = 0; i < children.size(); ++i) {
+ QGraphicsItem *item = children.at(i);
+ if (item->d_ptr->hasTransform && !item->transform().isInvertible())
+ continue;
+
+ // Skip invisible items and all their children.
+ if (item->d_ptr->isInvisible())
+ continue;
+
+ bool keep = false;
+ if (!item->d_ptr->isClippedAway()) {
+ // ### _q_adjustedRect is only needed because QRectF::intersects,
+ // QRectF::contains and QTransform::map() and friends don't work with
+ // flat rectangles.
+ const QRectF br(adjustedItemBoundingRect(item));
+ QRectF mbr = item->mapRectToParent(br);
+ if (mode >= Qt::ContainsItemBoundingRect) {
+ // Rect intersects/contains item's bounding rect
+ if ((mode == Qt::IntersectsItemBoundingRect && QRectF_intersects(rect, mbr))
+ || (mode == Qt::ContainsItemBoundingRect && rect != mbr && rect.contains(br))) {
items->append(item);
keep = true;
}
+ } else {
+ // Rect intersects/contains item's shape
+ if (QRectF_intersects(rect, mbr)) {
+ if (path == QPainterPath())
+ path.addRect(rect);
+ if (itemCollidesWithPath(item, item->mapFromParent(path), mode)) {
+ items->append(item);
+ keep = true;
+ }
+ }
}
}
@@ -1581,18 +1717,22 @@ void QGraphicsScenePrivate::childItems_helper(QList<QGraphicsItem *> *items,
}
}
+
void QGraphicsScenePrivate::childItems_helper(QList<QGraphicsItem *> *items,
const QGraphicsItem *parent,
const QPolygonF &polygon,
Qt::ItemSelectionMode mode) const
{
- QPainterPath path;
bool parentClip = (parent->flags() & QGraphicsItem::ItemClipsChildrenToShape);
- QRectF polyRect = _q_adjustedRect(polygon.boundingRect());
- QRectF r = !parentClip ? polyRect : polyRect.intersected(_q_adjustedRect(parent->boundingRect()));
+ if (parentClip && parent->d_ptr->isClippedAway())
+ return;
+ QRectF polyRect(polygon.boundingRect());
+ _q_adjustRect(&polyRect);
+ QRectF r = !parentClip ? polyRect : polyRect.intersected(adjustedItemBoundingRect(parent));
if (r.isEmpty())
return;
+ QPainterPath path;
QList<QGraphicsItem *> &children = parent->d_ptr->children;
for (int i = 0; i < children.size(); ++i) {
QGraphicsItem *item = children.at(i);
@@ -1600,32 +1740,34 @@ void QGraphicsScenePrivate::childItems_helper(QList<QGraphicsItem *> *items,
continue;
// Skip invisible items.
- if (!item->d_ptr->visible || qFuzzyCompare(item->effectiveOpacity() + 1, qreal(1.0)))
+ if (item->d_ptr->isInvisible())
continue;
- // ### _q_adjustedRect is only needed because QRectF::intersects,
- // QRectF::contains and QTransform::map() and friends don't work with
- // flat rectangles.
- QRectF br = _q_adjustedRect(item->boundingRect());
bool keep = false;
- if (mode >= Qt::ContainsItemBoundingRect) {
- // Polygon contains/intersects item's bounding rect
- if (path == QPainterPath())
- path.addPolygon(polygon);
- if ((mode == Qt::IntersectsItemBoundingRect && path.intersects(item->mapRectToParent(br)))
- || (mode == Qt::ContainsItemBoundingRect && path.contains(item->mapRectToParent(br)))) {
- items->append(item);
- keep = true;
- }
- } else {
- // Polygon contains/intersects item's shape
- if (QRectF_intersects(polyRect, item->mapRectToParent(br))) {
+ if (!item->d_ptr->isClippedAway()) {
+ // ### _q_adjustedRect is only needed because QRectF::intersects,
+ // QRectF::contains and QTransform::map() and friends don't work with
+ // flat rectangles.
+ const QRectF br(adjustedItemBoundingRect(item));
+ if (mode >= Qt::ContainsItemBoundingRect) {
+ // Polygon contains/intersects item's bounding rect
if (path == QPainterPath())
path.addPolygon(polygon);
- if (itemCollidesWithPath(item, item->mapFromParent(path), mode)) {
+ if ((mode == Qt::IntersectsItemBoundingRect && path.intersects(item->mapRectToParent(br)))
+ || (mode == Qt::ContainsItemBoundingRect && path.contains(item->mapRectToParent(br)))) {
items->append(item);
keep = true;
}
+ } else {
+ // Polygon contains/intersects item's shape
+ if (QRectF_intersects(polyRect, item->mapRectToParent(br))) {
+ if (path == QPainterPath())
+ path.addPolygon(polygon);
+ if (itemCollidesWithPath(item, item->mapFromParent(path), mode)) {
+ items->append(item);
+ keep = true;
+ }
+ }
}
}
@@ -1642,30 +1784,52 @@ void QGraphicsScenePrivate::childItems_helper(QList<QGraphicsItem *> *items,
Qt::ItemSelectionMode mode) const
{
bool parentClip = (parent->flags() & QGraphicsItem::ItemClipsChildrenToShape);
- QPainterPath intersectedPath = !parentClip ? path : path.intersected(parent->shape());
- if (intersectedPath.isEmpty())
+ if (parentClip && parent->d_ptr->isClippedAway())
+ return;
+ QRectF pathRect(path.boundingRect());
+ _q_adjustRect(&pathRect);
+ QRectF r = !parentClip ? pathRect : pathRect.intersected(adjustedItemBoundingRect(parent));
+ if (r.isEmpty())
return;
QList<QGraphicsItem *> &children = parent->d_ptr->children;
for (int i = 0; i < children.size(); ++i) {
QGraphicsItem *item = children.at(i);
+ if (item->d_ptr->hasTransform && !item->transform().isInvertible())
+ continue;
// Skip invisible items.
- if (!item->d_ptr->visible || qFuzzyCompare(item->effectiveOpacity(), qreal(0.0)))
+ if (item->d_ptr->isInvisible())
continue;
- QTransform x = item->sceneTransform();
-
- bool ok;
- QTransform xinv = x.inverted(&ok);
- if (ok) {
- QPainterPath mappedPath = xinv.map(path);
- if (itemCollidesWithPath(item, mappedPath, mode)) {
- items->append(item);
- if (!item->d_ptr->children.isEmpty())
- childItems_helper(items, item, mappedPath, mode);
+ bool keep = false;
+ if (!item->d_ptr->isClippedAway()) {
+ // ### _q_adjustedRect is only needed because QRectF::intersects,
+ // QRectF::contains and QTransform::map() and friends don't work with
+ // flat rectangles.
+ const QRectF br(adjustedItemBoundingRect(item));
+ if (mode >= Qt::ContainsItemBoundingRect) {
+ // Polygon contains/intersects item's bounding rect
+ if ((mode == Qt::IntersectsItemBoundingRect && path.intersects(item->mapRectToParent(br)))
+ || (mode == Qt::ContainsItemBoundingRect && path.contains(item->mapRectToParent(br)))) {
+ items->append(item);
+ keep = true;
+ }
+ } else {
+ // Path contains/intersects item's shape
+ if (QRectF_intersects(pathRect, item->mapRectToParent(br))) {
+ if (itemCollidesWithPath(item, item->mapFromParent(path), mode)) {
+ items->append(item);
+ keep = true;
+ }
+ }
}
}
+
+ if ((keep || !(item->flags() & QGraphicsItem::ItemClipsChildrenToShape)) && !item->d_ptr->children.isEmpty()) {
+ // Recurse into children that clip children.
+ childItems_helper(items, item, item->mapFromParent(path), mode);
+ }
}
}
@@ -2339,17 +2503,8 @@ QList<QGraphicsItem *> QGraphicsScene::items() const
*/
QList<QGraphicsItem *> QGraphicsScene::items(const QPointF &pos) const
{
- QList<QGraphicsItem *> itemsAtPoint;
-
- // Find all items within a 1x1 rect area starting at pos. This can be
- // inefficient for scenes that use small coordinates (like unity
- // coordinates), or for detailed graphs. ### The index should support
- // fetching items at a pos to avoid this limitation.
- foreach (QGraphicsItem *item, items(QRectF(pos, QSizeF(1, 1)), Qt::IntersectsItemBoundingRect)) {
- if (item->contains(item->mapFromScene(pos)))
- itemsAtPoint << item;
- }
- return itemsAtPoint;
+ Q_D(const QGraphicsScene);
+ return d->items_helper(pos);
}
@@ -2625,6 +2780,8 @@ void QGraphicsScene::clear()
d->lastItemCount = 0;
d->bspTree.clear();
d->largestUntransformableItem = QRectF();
+ d->allItemsIgnoreHoverEvents = true;
+ d->allItemsUseDefaultCursor = true;
}
/*!
@@ -2734,8 +2891,9 @@ void QGraphicsScene::addItem(QGraphicsItem *item)
// Notify the item that its scene is changing, and allow the item to
// react.
- QGraphicsScene *targetScene = qVariantValue<QGraphicsScene *>(item->itemChange(QGraphicsItem::ItemSceneChange,
- qVariantFromValue<QGraphicsScene *>(this)));
+ const QVariant newSceneVariant(item->itemChange(QGraphicsItem::ItemSceneChange,
+ qVariantFromValue<QGraphicsScene *>(this)));
+ QGraphicsScene *targetScene = qVariantValue<QGraphicsScene *>(newSceneVariant);
if (targetScene != this) {
if (targetScene && item->scene() != targetScene)
targetScene->addItem(item);
@@ -2788,6 +2946,17 @@ void QGraphicsScene::addItem(QGraphicsItem *item)
++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();
+ }
+ if (d->allItemsUseDefaultCursor && item->hasCursor()) {
+ d->allItemsUseDefaultCursor = false;
+ if (d->allItemsIgnoreHoverEvents) // already enabled otherwise
+ d->enableMouseTrackingOnViews();
+ }
+
// Update selection lists
if (item->isSelected())
d->selectedItems << item;
@@ -2833,7 +3002,7 @@ void QGraphicsScene::addItem(QGraphicsItem *item)
emit selectionChanged();
// Deliver post-change notification
- item->itemChange(QGraphicsItem::ItemSceneHasChanged, qVariantFromValue<QGraphicsScene *>(this));
+ item->itemChange(QGraphicsItem::ItemSceneHasChanged, newSceneVariant);
}
/*!
@@ -3097,8 +3266,9 @@ void QGraphicsScene::removeItem(QGraphicsItem *item)
// Notify the item that it's scene is changing to 0, allowing the item to
// react.
- QGraphicsScene *targetScene = qVariantValue<QGraphicsScene *>(item->itemChange(QGraphicsItem::ItemSceneChange,
- qVariantFromValue<QGraphicsScene *>(0)));
+ const QVariant newSceneVariant(item->itemChange(QGraphicsItem::ItemSceneChange,
+ qVariantFromValue<QGraphicsScene *>(0)));
+ QGraphicsScene *targetScene = qVariantValue<QGraphicsScene *>(newSceneVariant);
if (targetScene != 0 && targetScene != this) {
targetScene->addItem(item);
return;
@@ -3171,6 +3341,16 @@ void QGraphicsScene::removeItem(QGraphicsItem *item)
d->unpolishedItems.removeAll(item);
d->dirtyItems.removeAll(item);
+ //We remove all references of item from the sceneEventFilter arrays
+ QMultiMap<QGraphicsItem*, QGraphicsItem*>::iterator iterator = d->sceneEventFilters.begin();
+ while (iterator != d->sceneEventFilters.end()) {
+ if (iterator.value() == item || iterator.key() == item)
+ iterator = d->sceneEventFilters.erase(iterator);
+ else
+ ++iterator;
+ }
+
+
//Ensure dirty flag have the correct default value so the next time it will be added it will receive updates
item->d_func()->dirty = 0;
item->d_func()->dirtyChildren = 0;
@@ -3198,7 +3378,7 @@ void QGraphicsScene::removeItem(QGraphicsItem *item)
emit selectionChanged();
// Deliver post-change notification
- item->itemChange(QGraphicsItem::ItemSceneHasChanged, qVariantFromValue<QGraphicsScene *>(0));
+ item->itemChange(QGraphicsItem::ItemSceneHasChanged, newSceneVariant);
}
/*!
@@ -3472,7 +3652,7 @@ QVariant QGraphicsScene::inputMethodQuery(Qt::InputMethodQuery query) const
void QGraphicsScene::update(const QRectF &rect)
{
Q_D(QGraphicsScene);
- if (d->updateAll)
+ if (d->updateAll || (rect.isEmpty() && !rect.isNull()))
return;
// Check if anyone's connected; if not, we can send updates directly to
@@ -4091,6 +4271,9 @@ bool QGraphicsScenePrivate::itemAcceptsHoverEvents_helper(const QGraphicsItem *i
*/
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()) {
@@ -4490,7 +4673,7 @@ static void _q_paintItem(QGraphicsItem *item, QPainter *painter,
? proxy->widget()->windowOpacity() : 1.0;
const qreal oldPainterOpacity = painter->opacity();
- if (qFuzzyCompare(windowOpacity + 1, qreal(1.0)))
+ if (qFuzzyIsNull(windowOpacity))
return;
// Set new painter opacity.
if (windowOpacity < 1.0)
@@ -4593,7 +4776,9 @@ void QGraphicsScenePrivate::drawItemHelper(QGraphicsItem *item, QPainter *painte
// Item's (local) bounding rect
QRectF brect = item->boundingRect();
- if (_q_adjustedRect(brect).isEmpty())
+ QRectF adjustedBrect(brect);
+ _q_adjustRect(&adjustedBrect);
+ if (adjustedBrect.isEmpty())
return;
// Fetch the off-screen transparent buffer and exposed area info.
@@ -4765,11 +4950,9 @@ void QGraphicsScenePrivate::drawItemHelper(QGraphicsItem *item, QPainter *painte
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.setCompositionMode(QPainter::CompositionMode_Source);
newPixPainter.drawPixmap(-diff, pix);
newPixPainter.end();
}
@@ -4801,8 +4984,9 @@ void QGraphicsScenePrivate::drawItemHelper(QGraphicsItem *item, QPainter *painte
if (itemCache->allExposed || !itemCache->exposed.isEmpty() || !scrollExposure.isEmpty()) {
// Construct an item-to-pixmap transform.
QPointF p = deviceRect.topLeft();
- QTransform itemToPixmap = QTransform::fromTranslate(-p.x(), -p.y());
- itemToPixmap = painter->worldTransform() * itemToPixmap;
+ 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;
@@ -5129,16 +5313,19 @@ void QGraphicsScene::itemUpdated(QGraphicsItem *item, const QRectF &rect)
// Deliver the actual update.
if (!d->updateAll) {
if (d->views.isEmpty() || ((d->connectedSignals & d->changedSignalMask) && !item->d_ptr->itemIsUntransformable()
- && qFuzzyCompare(item->boundingRegionGranularity(), qreal(0.0)))) {
+ && 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.
update(item->sceneBoundingRect());
} else {
// ### Remove _q_adjustedRects().
- QRectF boundingRect = _q_adjustedRect(item->boundingRect());
- if (!rect.isNull())
- boundingRect &= _q_adjustedRect(rect);
+ QRectF boundingRect(adjustedItemBoundingRect(item));
+ if (!rect.isNull()) {
+ QRectF adjustedRect(rect);
+ _q_adjustRect(&adjustedRect);
+ boundingRect &= adjustedRect;
+ }
// Update each view directly.
for (int i = 0; i < d->views.size(); ++i)
@@ -5150,6 +5337,9 @@ void QGraphicsScene::itemUpdated(QGraphicsItem *item, const QRectF &rect)
d->resetDirtyItemsLater();
}
+ if (!item->isVisible())
+ return; // Hiding an item won't effect the largestUntransformableItem/sceneRect.
+
// Update d->largestUntransformableItem by mapping this item's bounding
// rect back to the topmost untransformable item's untransformed
// coordinate system (which sort of equals the 1:1 coordinate system of an
@@ -5165,7 +5355,9 @@ void QGraphicsScene::itemUpdated(QGraphicsItem *item, const QRectF &rect)
// defined scene rect.
if (!d->hasSceneRect) {
QRectF oldGrowingItemsBoundingRect = d->growingItemsBoundingRect;
- d->growingItemsBoundingRect |= _q_adjustedRect(item->sceneBoundingRect());
+ QRectF adjustedItemSceneBoundingRect(item->sceneBoundingRect());
+ _q_adjustRect(&adjustedItemSceneBoundingRect);
+ d->growingItemsBoundingRect |= adjustedItemSceneBoundingRect;
if (d->growingItemsBoundingRect != oldGrowingItemsBoundingRect)
emit sceneRectChanged(d->growingItemsBoundingRect);
}
diff --git a/src/gui/graphicsview/qgraphicsscene_p.h b/src/gui/graphicsview/qgraphicsscene_p.h
index d5e539b..de39205 100644
--- a/src/gui/graphicsview/qgraphicsscene_p.h
+++ b/src/gui/graphicsview/qgraphicsscene_p.h
@@ -169,6 +169,9 @@ public:
Qt::DropAction lastDropAction;
QList<QGraphicsItem *> cachedItemsUnderMouse;
QList<QGraphicsItem *> hoverItems;
+ bool allItemsIgnoreHoverEvents;
+ bool allItemsUseDefaultCursor;
+ void enableMouseTrackingOnViews();
QMap<Qt::MouseButton, QPointF> mouseGrabberButtonDownPos;
QMap<Qt::MouseButton, QPointF> mouseGrabberButtonDownScenePos;
QMap<Qt::MouseButton, QPoint> mouseGrabberButtonDownScreenPos;
@@ -201,6 +204,7 @@ public:
void mousePressEventHandler(QGraphicsSceneMouseEvent *mouseEvent);
QGraphicsWidget *windowForItem(const QGraphicsItem *item) const;
+ QList<QGraphicsItem *> items_helper(const QPointF &pos) const;
QList<QGraphicsItem *> items_helper(const QRectF &rect,
Qt::ItemSelectionMode mode,
Qt::SortOrder order) const;
@@ -212,6 +216,9 @@ public:
Qt::SortOrder order) const;
void childItems_helper(QList<QGraphicsItem *> *items,
const QGraphicsItem *parent,
+ const QPointF &pos) const;
+ void childItems_helper(QList<QGraphicsItem *> *items,
+ const QGraphicsItem *parent,
const QRectF &rect,
Qt::ItemSelectionMode mode) const;
void childItems_helper(QList<QGraphicsItem *> *items,
diff --git a/src/gui/graphicsview/qgraphicsview.cpp b/src/gui/graphicsview/qgraphicsview.cpp
index f95d328..2bcce32 100644
--- a/src/gui/graphicsview/qgraphicsview.cpp
+++ b/src/gui/graphicsview/qgraphicsview.cpp
@@ -587,6 +587,10 @@ void QGraphicsViewPrivate::mouseMoveEventHandler(QMouseEvent *event)
return;
if (!scene)
return;
+ if (scene->d_func()->allItemsIgnoreHoverEvents && scene->d_func()->allItemsUseDefaultCursor
+ && !event->buttons()) { // forward event to the scene if something is pressed.
+ return; // No need to process this event further.
+ }
QGraphicsSceneMouseEvent mouseEvent(QEvent::GraphicsSceneMouseMove);
mouseEvent.setWidget(q->viewport());
@@ -614,6 +618,16 @@ void QGraphicsViewPrivate::mouseMoveEventHandler(QMouseEvent *event)
}
#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()) {
@@ -790,6 +804,19 @@ QRegion QGraphicsViewPrivate::mapToViewRegion(const QGraphicsItem *item, const Q
return item->boundingRegion(itv) & itv.mapRect(rect).toAlignedRect();
}
+// 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 QRectF adjustedItemBoundingRect(const QGraphicsItem *item)
+{
+ Q_ASSERT(item);
+ QRectF boundingRect(item->boundingRect());
+ if (!boundingRect.width())
+ boundingRect.adjust(-0.00001, 0, 0.00001, 0);
+ if (!boundingRect.height())
+ boundingRect.adjust(0, -0.00001, 0, 0.00001);
+ return boundingRect;
+}
+
/*!
\internal
*/
@@ -801,38 +828,37 @@ void QGraphicsViewPrivate::itemUpdated(QGraphicsItem *item, const QRectF &rect)
updateLater();
QRectF updateRect = rect;
- if (item->isClipped()) {
+ if ((item->d_ptr->flags & QGraphicsItem::ItemClipsChildrenToShape) || item->d_ptr->children.isEmpty()) {
+ updateRect &= adjustedItemBoundingRect(item);
+ if (updateRect.isEmpty())
+ return;
+ }
+
+ QGraphicsItem *clipItem = item;
+ if (item->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren) {
// Minimize unnecessary redraw.
- QGraphicsItem *p = item;
- while ((p = p->d_ptr->parent)) {
- if (p->flags() & QGraphicsItem::ItemClipsChildrenToShape) {
- updateRect &= p->itemTransform(item).mapRect(p->boundingRect());
- if (updateRect.isNull())
+ QGraphicsItem *parent = item;
+ while ((parent = parent->d_ptr->parent)) {
+ if (parent->d_ptr->flags & QGraphicsItem::ItemClipsChildrenToShape) {
+ // Map update rect to the current parent and itersect with its bounding rect.
+ updateRect = clipItem->itemTransform(parent).mapRect(updateRect)
+ & adjustedItemBoundingRect(parent);
+ if (updateRect.isEmpty())
return;
+ clipItem = parent;
}
- if (!(p->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren))
+ if (!(parent->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren))
break;
}
-
- if (updateRect.isNull())
- return;
}
- // Map the rect to view coordinates.
- QRect vr = viewport->rect();
-
- if (!item->d_ptr->hasBoundingRegionGranularity) {
- QRect r = mapToViewRect(item, updateRect) & vr;
- if (r.isNull())
- return;
- this->updateRect(r);
- } else {
- QRegion r = mapToViewRegion(item, updateRect) & vr;
- if (r.isEmpty())
- return;
- updateRegion(r);
- }
+ // Map update rect from clipItem coordinates to view coordinates.
+ Q_ASSERT(clipItem);
+ if (!item->d_ptr->hasBoundingRegionGranularity)
+ this->updateRect(mapToViewRect(clipItem, updateRect) & viewport->rect());
+ else
+ updateRegion(mapToViewRegion(clipItem, updateRect) & viewport->rect());
}
void QGraphicsViewPrivate::updateLater()
@@ -855,16 +881,19 @@ void QGraphicsViewPrivate::_q_updateLaterSlot()
const QList<QGraphicsItem *> &dirtyItems = scene->d_func()->dirtyItems;
for (int i = 0; i < dirtyItems.size(); ++i) {
const QGraphicsItem *item = dirtyItems.at(i);
+ if (item->d_ptr->discardUpdateRequest(/*ignoreClipping=*/false,
+ /*ignoreVisibleBit=*/false,
+ /*ignoreDirtyBit=*/true)) {
+ continue;
+ }
QTransform x = item->sceneTransform() * viewTransform;
- QRect viewRect = x.mapRect(item->boundingRect()).toAlignedRect() & vr;
- if (!viewRect.isNull())
- updateRect(viewRect);
+ updateRect(x.mapRect(item->boundingRect()).toAlignedRect() & vr);
}
dirtyRectCount += dirtyRects.size();
bool noUpdate = !fullUpdatePending && viewportUpdateMode == QGraphicsView::FullViewportUpdate;
- if ((dirtyRectCount > 0 || !dirtyBoundingRect.isNull()) && !fullUpdatePending && !noUpdate) {
+ if ((dirtyRectCount > 0 || !dirtyBoundingRect.isEmpty()) && !fullUpdatePending && !noUpdate) {
if (viewportUpdateMode == QGraphicsView::BoundingRectViewportUpdate
|| (viewportUpdateMode == QGraphicsView::SmartViewportUpdate
&& dirtyRectCount >= QGRAPHICSVIEW_REGION_RECT_THRESHOLD)) {
@@ -921,6 +950,9 @@ void QGraphicsViewPrivate::updateAll()
void QGraphicsViewPrivate::updateRegion(const QRegion &r)
{
+ if (r.isEmpty())
+ return;
+
Q_Q(QGraphicsView);
// Rect intersects viewport - update everything?
@@ -969,6 +1001,9 @@ void QGraphicsViewPrivate::updateRegion(const QRegion &r)
void QGraphicsViewPrivate::updateRect(const QRect &r)
{
+ if (r.isEmpty())
+ return;
+
Q_Q(QGraphicsView);
// Rect intersects viewport - update everything?
@@ -1025,103 +1060,71 @@ void QGraphicsViewPrivate::freeStyleOptionsArray(QStyleOptionGraphicsItem *array
extern QPainterPath qt_regionToPath(const QRegion &region);
-QList<QGraphicsItem *> QGraphicsViewPrivate::findItems(const QRegion &exposedRegion,
- const QTransform &worldTransform,
- bool *allItems) const
+/*!
+ ### 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
{
Q_Q(const QGraphicsView);
- QList<QGraphicsItem *> itemList;
- QSet<QGraphicsItem *> tmp;
- bool simpleTransform = worldTransform.type() <= QTransform::TxScale;
-
- QPainterPath path = qt_regionToPath(exposedRegion);
- *allItems = path.contains(q->mapFromScene(scene->d_func()->growingItemsBoundingRect).boundingRect());
- QList<QRectF> exposedRects;
- QList<QPolygonF> exposedPolys;
-
- // Transform the exposed viewport rects to scene rects or polygons
- foreach (const QRect &rect, exposedRegion.rects()) {
- QPolygonF exposedPoly = q->mapToScene(rect.adjusted(-1, -1, 1, 1));
- QRectF exposedRect = exposedPoly.boundingRect();
- if (!simpleTransform)
- exposedPolys << exposedPoly;
- exposedRects << exposedRect;
- }
-
- // Find which items need to be drawn.
- if (*allItems) {
+
+ // Step 1) If all items are contained within the expose region, then
+ // return a list of all visible items.
+ const QRectF exposedRegionSceneBounds = q->mapToScene(exposedRegion.boundingRect().adjusted(-1, -1, 2, 2))
+ .boundingRect();
+ if (exposedRegionSceneBounds.contains(scene->d_func()->growingItemsBoundingRect)) {
+ Q_ASSERT(allItems);
+ *allItems = true;
+
// All items are guaranteed within the exposed region, don't bother using the index.
- foreach (QGraphicsItem *item, scene->items()) {
+ QList<QGraphicsItem *> itemList(scene->items());
+ int i = 0;
+ while (i < itemList.size()) {
// But we only want to include items that are visible
- if (item->isVisible())
- itemList << item;
- }
- } else if (simpleTransform) {
- // Simple rect lookups will do.
- if (exposedRects.size() > 1) {
- foreach (const QRectF &rect, exposedRects) {
- foreach (QGraphicsItem *item, scene->d_func()->items_helper(rect, Qt::IntersectsItemBoundingRect, Qt::SortOrder(-1) /* don't sort */)) {
- if (!tmp.contains(item)) {
- tmp << item;
- itemList << item;
- }
- }
- }
- } else {
- itemList += scene->d_func()->items_helper(exposedRects[0], Qt::IntersectsItemBoundingRect, Qt::SortOrder(-1) /* don't sort */);
- }
- } else {
- // Polygon lookup is necessary.
- if (exposedRects.size() > 1) {
- foreach (const QPolygonF &poly, exposedPolys) {
- foreach (QGraphicsItem *item, scene->d_func()->items_helper(poly, Qt::IntersectsItemBoundingRect, Qt::SortOrder(-1) /* don't sort */)) {
- if (!tmp.contains(item)) {
- tmp << item;
- itemList << item;
- }
- }
- }
- } else {
- itemList += scene->d_func()->items_helper(exposedPolys[0], Qt::IntersectsItemBoundingRect, Qt::SortOrder(-1) /* don't sort */);
+ if (!itemList.at(i)->isVisible())
+ itemList.removeAt(i);
+ else
+ ++i;
}
+
+ // Sort the items.
+ QGraphicsScenePrivate::sortItems(&itemList, Qt::DescendingOrder, scene->d_func()->sortCacheEnabled);
+ return itemList;
}
- // Check for items that ignore inherited transformations, and add them if
- // necessary.
- QRectF untr = scene->d_func()->largestUntransformableItem;
- if (!*allItems && !untr.isNull()) {
- // Map the largest untransformable item subtree boundingrect from view
- // to scene coordinates, and use this to expand all exposed rects in
- // search for untransformable items.
- QRectF ltri = matrix.inverted().mapRect(untr);
- ltri.adjust(-untr.width(), -untr.height(), untr.width(), untr.height());
-
- foreach (const QRect &rect, exposedRegion.rects()) {
- QRectF exposed = q->mapToScene(rect.adjusted(-1, -1, 1, 1)).boundingRect();
- exposed.adjust(-ltri.width(), -ltri.height(), ltri.width(), ltri.height());
-
- foreach (QGraphicsItem *item, scene->d_func()->estimateItemsInRect(exposed)) {
- if (item->d_ptr->itemIsUntransformable()) {
- if (!tmp.contains(item)) {
- QPainterPath rectPath;
- rectPath.addRect(rect);
- QPainterPath path = item->deviceTransform(q->viewportTransform()).inverted().map(rectPath);
- if (item->collidesWithPath(path, Qt::IntersectsItemBoundingRect)) {
- itemList << item;
- tmp << item;
- }
- }
- }
- }
- }
+ // 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 = (scene->d_func()->largestUntransformableItem.isNull()
+ && exposedRegion.numRects() == 1 && matrix.type() <= QTransform::TxScale);
+ if (simpleRectLookup) {
+ return scene->d_func()->items_helper(exposedRegionSceneBounds,
+ Qt::IntersectsItemBoundingRect,
+ Qt::DescendingOrder);
}
- tmp.clear();
- // Sort the items.
- QGraphicsScenePrivate::sortItems(&itemList, Qt::DescendingOrder,
- scene->d_func()->sortCacheEnabled);
+ // 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 exposedPath(qt_regionToPath(adjustedRegion));
+ if (scene->d_func()->largestUntransformableItem.isNull()) {
+ const QPainterPath exposedScenePath(q->mapToScene(exposedPath));
+ return scene->d_func()->items_helper(exposedScenePath,
+ Qt::IntersectsItemBoundingRect,
+ Qt::DescendingOrder);
+ }
- return itemList;
+ // NB! Path must be in viewport coordinates.
+ return itemsInArea(exposedPath, Qt::IntersectsItemBoundingRect, Qt::DescendingOrder);
}
void QGraphicsViewPrivate::generateStyleOptions(const QList<QGraphicsItem *> &itemList,
@@ -1699,6 +1702,12 @@ void QGraphicsView::setScene(QGraphicsScene *scene)
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);
+ }
} else {
d->recalculateContentSize();
}
@@ -2224,7 +2233,8 @@ QList<QGraphicsItem *> QGraphicsView::items() const
certainly room for improvement.
*/
QList<QGraphicsItem *> QGraphicsViewPrivate::itemsInArea(const QPainterPath &path,
- Qt::ItemSelectionMode mode) const
+ Qt::ItemSelectionMode mode,
+ Qt::SortOrder order) const
{
Q_Q(const QGraphicsView);
@@ -2274,8 +2284,8 @@ QList<QGraphicsItem *> QGraphicsViewPrivate::itemsInArea(const QPainterPath &pat
}
// ### Insertion sort would be faster.
- QGraphicsScenePrivate::sortItems(&result, Qt::AscendingOrder,
- scene->d_func()->sortCacheEnabled);
+ if (order != Qt::SortOrder(-1))
+ QGraphicsScenePrivate::sortItems(&result, order, scene->d_func()->sortCacheEnabled);
return result;
}
@@ -2809,7 +2819,12 @@ void QGraphicsView::setupViewport(QWidget *widget)
widget->setAutoFillBackground(true);
}
- widget->setMouseTracking(true);
+ // We are only interested in mouse tracking if items
+ // accept hover events or use non-default cursors.
+ if (d->scene && (!d->scene->d_func()->allItemsIgnoreHoverEvents
+ || !d->scene->d_func()->allItemsUseDefaultCursor)) {
+ widget->setMouseTracking(true);
+ }
widget->setAcceptDrops(acceptDrops());
}
@@ -3302,7 +3317,7 @@ void QGraphicsView::mouseMoveEvent(QMouseEvent *event)
}
// Update old rubberband
- if (d->viewportUpdateMode != QGraphicsView::NoViewportUpdate && !d->rubberBandRect.isNull()) {
+ if (d->viewportUpdateMode != QGraphicsView::NoViewportUpdate && !d->rubberBandRect.isEmpty()) {
if (d->viewportUpdateMode != FullViewportUpdate)
viewport()->update(d->rubberBandRegion(viewport(), d->rubberBandRect));
else
@@ -3484,7 +3499,7 @@ void QGraphicsView::paintEvent(QPaintEvent *event)
QPainter painter(viewport());
QTransform original = painter.worldTransform();
#ifndef QT_NO_RUBBERBAND
- if (d->rubberBanding && !d->rubberBandRect.isNull())
+ if (d->rubberBanding && !d->rubberBandRect.isEmpty())
painter.save();
#endif
// Set up render hints
@@ -3503,7 +3518,7 @@ void QGraphicsView::paintEvent(QPaintEvent *event)
// Find all exposed items
bool allItems = false;
- QList<QGraphicsItem *> itemList = d->findItems(exposedRegion, viewTransform, &allItems);
+ QList<QGraphicsItem *> itemList = d->findItems(exposedRegion, &allItems);
#ifdef QGRAPHICSVIEW_DEBUG
int exposedTime = stopWatch.elapsed();
@@ -3580,7 +3595,7 @@ void QGraphicsView::paintEvent(QPaintEvent *event)
#ifndef QT_NO_RUBBERBAND
// Rubberband
- if (d->rubberBanding && !d->rubberBandRect.isNull()) {
+ if (d->rubberBanding && !d->rubberBandRect.isEmpty()) {
painter.restore();
QStyleOptionRubberBand option;
option.initFrom(viewport());
@@ -3654,30 +3669,30 @@ void QGraphicsView::scrollContentsBy(int dx, int dy)
if (isRightToLeft())
dx = -dx;
- if (d->viewportUpdateMode != QGraphicsView::NoViewportUpdate
- && d->viewportUpdateMode != QGraphicsView::FullViewportUpdate) {
- for (int i = 0; i < d->dirtyRects.size(); ++i)
- d->dirtyRects[i].translate(dx, dy);
- for (int i = 0; i < d->dirtyRegions.size(); ++i)
- d->dirtyRegions[i].translate(dx, dy);
- }
-
+ if (d->viewportUpdateMode != QGraphicsView::NoViewportUpdate) {
+ if (d->viewportUpdateMode != QGraphicsView::FullViewportUpdate) {
+ for (int i = 0; i < d->dirtyRects.size(); ++i)
+ d->dirtyRects[i].translate(dx, dy);
+ for (int i = 0; i < d->dirtyRegions.size(); ++i)
+ d->dirtyRegions[i].translate(dx, dy);
+ if (d->accelerateScrolling) {
#ifndef QT_NO_RUBBERBAND
- // Update old rubberband
- if (d->viewportUpdateMode != QGraphicsView::NoViewportUpdate && !d->rubberBandRect.isNull()) {
- if (d->viewportUpdateMode != FullViewportUpdate)
- viewport()->update(d->rubberBandRegion(viewport(), d->rubberBandRect));
- else
- viewport()->update();
- }
+ // 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
-
- if (d->viewportUpdateMode != QGraphicsView::NoViewportUpdate){
- if (d->accelerateScrolling && d->viewportUpdateMode != FullViewportUpdate)
- viewport()->scroll(dx, dy);
- else
+ viewport()->scroll(dx, dy);
+ } else {
+ viewport()->update();
+ }
+ } else {
viewport()->update();
+ }
}
+
d->updateLastCenterPoint();
if ((d->cacheMode & CacheBackground)
diff --git a/src/gui/graphicsview/qgraphicsview_p.h b/src/gui/graphicsview/qgraphicsview_p.h
index e9479f3..abab921 100644
--- a/src/gui/graphicsview/qgraphicsview_p.h
+++ b/src/gui/graphicsview/qgraphicsview_p.h
@@ -85,7 +85,8 @@ public:
qint64 verticalScroll() const;
QList<QGraphicsItem *> itemsInArea(const QPainterPath &path,
- Qt::ItemSelectionMode mode = Qt::IntersectsItemShape) const;
+ Qt::ItemSelectionMode mode = Qt::IntersectsItemShape,
+ Qt::SortOrder = Qt::AscendingOrder) const;
QPointF mousePressItemPoint;
QPointF mousePressScenePoint;
@@ -172,9 +173,7 @@ public:
void updateRegion(const QRegion &region);
bool updateSceneSlotReimplementedChecked;
- QList<QGraphicsItem *> findItems(const QRegion &exposedRegion,
- const QTransform &worldTransform,
- bool *allItems) const;
+ QList<QGraphicsItem *> findItems(const QRegion &exposedRegion, bool *allItems) const;
void generateStyleOptions(const QList<QGraphicsItem *> &itemList,
QGraphicsItem **itemArray,
diff --git a/src/gui/graphicsview/qgraphicswidget.cpp b/src/gui/graphicsview/qgraphicswidget.cpp
index 64ec0e7..2e7d82a 100644
--- a/src/gui/graphicsview/qgraphicswidget.cpp
+++ b/src/gui/graphicsview/qgraphicswidget.cpp
@@ -366,32 +366,33 @@ void QGraphicsWidget::resize(const QSizeF &size)
void QGraphicsWidget::setGeometry(const QRectF &rect)
{
QGraphicsWidgetPrivate *wd = QGraphicsWidget::d_func();
- const QGraphicsLayoutItemPrivate *d = QGraphicsLayoutItem::d_ptr;
- setAttribute(Qt::WA_Resized);
- QRectF newGeom = rect;
- newGeom.setSize(rect.size().expandedTo(effectiveSizeHint(Qt::MinimumSize))
- .boundedTo(effectiveSizeHint(Qt::MaximumSize)));
- if (newGeom == d->geom)
- return;
-
- // Update and prepare to change the geometry (remove from index).
- if (wd->scene) {
- if (rect.topLeft() != d->geom.topLeft())
- wd->fullUpdateHelper(true);
- else
- update();
- }
- prepareGeometryChange();
-
- // setPos triggers ItemPositionChange, which can adjust position
+ QGraphicsLayoutItemPrivate *d = QGraphicsLayoutItem::d_ptr;
+ QRectF newGeom;
QPointF oldPos = d->geom.topLeft();
- wd->inSetGeometry = 1;
- wd->setPosHelper(newGeom.topLeft(), /* update = */ false);
- wd->inSetGeometry = 0;
- newGeom.moveTopLeft(pos());
-
- if (newGeom == d->geom)
- return;
+ 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;
+ wd->setPosHelper(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();
@@ -401,6 +402,11 @@ void QGraphicsWidget::setGeometry(const QRectF &rect)
event.setOldPos(oldPos);
event.setNewPos(pos());
QApplication::sendEvent(this, &event);
+ if (wd->inSetPos) {
+ //set the new pos
+ d->geom.moveTopLeft(pos());
+ return;
+ }
}
QSizeF oldSize = size();
QGraphicsLayoutItem::setGeometry(newGeom);
@@ -1016,9 +1022,11 @@ QVariant QGraphicsWidget::itemChange(GraphicsItemChange change, const QVariant &
break;
case ItemPositionHasChanged:
if (!d->inSetGeometry) {
+ d->inSetPos = 1;
// Ensure setGeometry is called (avoid recursion when setPos is
// called from within setGeometry).
setGeometry(QRectF(pos(), size()));
+ d->inSetPos = 0 ;
}
break;
case ItemParentChange: {
@@ -1627,6 +1635,11 @@ void QGraphicsWidget::setWindowFlags(Qt::WindowFlags wFlags)
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();
+ }
}
/*!
diff --git a/src/gui/graphicsview/qgraphicswidget_p.h b/src/gui/graphicsview/qgraphicswidget_p.h
index 455a129..53eaa31 100644
--- a/src/gui/graphicsview/qgraphicswidget_p.h
+++ b/src/gui/graphicsview/qgraphicswidget_p.h
@@ -86,6 +86,7 @@ public:
inheritedFontResolveMask(0),
inSetGeometry(0),
polished(0),
+ inSetPos(0),
focusPolicy(Qt::NoFocus),
focusNext(0),
focusPrev(0),
@@ -195,6 +196,7 @@ public:
quint32 attributes : 10;
quint32 inSetGeometry : 1;
quint32 polished: 1;
+ quint32 inSetPos : 1;
// Focus
Qt::FocusPolicy focusPolicy;
diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp
index 3c71f15..0514567 100644
--- a/src/gui/image/qicon.cpp
+++ b/src/gui/image/qicon.cpp
@@ -304,6 +304,8 @@ QPixmap QPixmapIconEngine::pixmap(const QSize &size, QIcon::Mode mode, QIcon::St
QString key = QLatin1String("$qt_icon_")
+ QString::number(pm.cacheKey())
+ QString::number(pe->mode)
+ + QString::number(qApp->palette().cacheKey())
+ + QLatin1Char('_')
+ QString::number(actualSize.width())
+ QLatin1Char('_')
+ QString::number(actualSize.height())
diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp
index dc236e4..14e8b8f 100644
--- a/src/gui/image/qimage.cpp
+++ b/src/gui/image/qimage.cpp
@@ -1691,8 +1691,12 @@ void QImage::setColorTable(const QVector<QRgb> colors)
d->colortable = colors;
d->has_alpha_clut = false;
- for (int i = 0; i < d->colortable.size(); ++i)
- d->has_alpha_clut |= (qAlpha(d->colortable.at(i)) != 255);
+ for (int i = 0; i < d->colortable.size(); ++i) {
+ if (qAlpha(d->colortable.at(i)) != 255) {
+ d->has_alpha_clut = true;
+ break;
+ }
+ }
}
/*!
@@ -3607,6 +3611,9 @@ int QImage::pixelIndex(int x, int y) const
If the \a position is not valid, the results are undefined.
+ \warning This function is expensive when used for massive pixel
+ manipulations.
+
\sa setPixel(), valid(), {QImage#Pixel Manipulation}{Pixel
Manipulation}
*/
@@ -5581,6 +5588,8 @@ bool QImage::isDetached() const
Use one of the composition mods in QPainter::CompositionMode instead.
+ \warning This function is expensive.
+
\sa alphaChannel(), {QImage#Image Transformations}{Image
Transformations}, {QImage#Image Formats}{Image Formats}
*/
@@ -5663,6 +5672,11 @@ void QImage::setAlphaChannel(const QImage &alphaChannel)
\l{QPixmap::}{alphaChannel()}, which works in the same way as
this function on QPixmaps.
+ Most usecases for this function can be replaced with QPainter and
+ using composition modes.
+
+ \warning This is an expensive function.
+
\sa setAlphaChannel(), hasAlphaChannel(),
{QPixmap#Pixmap Information}{Pixmap},
{QImage#Image Transformations}{Image Transformations}
diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp
index e563fc9..3b82da8 100644
--- a/src/gui/image/qpixmap.cpp
+++ b/src/gui/image/qpixmap.cpp
@@ -724,7 +724,7 @@ void QPixmap::resize_helper(const QSize &s)
pixels black. The effect of this function is undefined when the pixmap is
being painted on.
- This is potentially an expensive operation.
+ \warning This is potentially an expensive operation.
\sa mask(), {QPixmap#Pixmap Transformations}{Pixmap Transformations},
QBitmap
@@ -1430,6 +1430,12 @@ void QPixmap::deref()
If the given \a size is empty, this function returns a null
pixmap.
+
+ In some cases it can be more beneficial to draw the pixmap to a
+ painter with a scale set rather than scaling the pixmap. This is
+ the case when the painter is for instance based on OpenGL or when
+ the scale factor changes rapidly.
+
\sa isNull(), {QPixmap#Pixmap Transformations}{Pixmap
Transformations}
@@ -1801,6 +1807,10 @@ int QPixmap::metric(PaintDeviceMetric metric) const
The effect of this function is undefined when the pixmap is being
painted on.
+ \warning This is potentially an expensive operation. Most usecases
+ for this function are covered by QPainter and compositionModes
+ which will normally execute faster.
+
\sa alphaChannel(), {QPixmap#Pixmap Transformations}{Pixmap
Transformations}
*/
@@ -1843,6 +1853,9 @@ void QPixmap::setAlphaChannel(const QPixmap &alphaChannel)
\image alphachannelimage.png The pixmap and channelImage QPixmaps
+ \warning This is an expensive operation. The alpha channel of the
+ pixmap is extracted dynamically from the pixeldata.
+
\sa setAlphaChannel(), {QPixmap#Pixmap Information}{Pixmap
Information}
*/
@@ -1864,7 +1877,8 @@ QPaintEngine *QPixmap::paintEngine() const
Extracts a bitmap mask from the pixmap's alphachannel.
- This is potentially an expensive operation.
+ \warning This is potentially an expensive operation. The mask of
+ the pixmap is extracted dynamically from the pixeldata.
\sa setMask(), {QPixmap#Pixmap Information}{Pixmap Information}
*/
diff --git a/src/gui/inputmethod/qmacinputcontext_mac.cpp b/src/gui/inputmethod/qmacinputcontext_mac.cpp
index f0e7ea9..86385fa 100644
--- a/src/gui/inputmethod/qmacinputcontext_mac.cpp
+++ b/src/gui/inputmethod/qmacinputcontext_mac.cpp
@@ -45,6 +45,7 @@
#include "qtextformat.h"
#include <qdebug.h>
#include <private/qapplication_p.h>
+#include <private/qkeymapper_p.h>
QT_BEGIN_NAMESPACE
@@ -63,7 +64,8 @@ static QTextFormat qt_mac_compose_format()
}
QMacInputContext::QMacInputContext(QObject *parent)
- : QInputContext(parent), composing(false), recursionGuard(false), textDocument(0)
+ : QInputContext(parent), composing(false), recursionGuard(false), textDocument(0),
+ keydownEvent(0)
{
// createTextDocument();
}
@@ -183,6 +185,16 @@ QMacInputContext::cleanup()
#endif
}
+void QMacInputContext::setLastKeydownEvent(EventRef event)
+{
+ EventRef tmpEvent = keydownEvent;
+ keydownEvent = event;
+ if (keydownEvent)
+ RetainEvent(keydownEvent);
+ if (tmpEvent)
+ ReleaseEvent(tmpEvent);
+}
+
OSStatus
QMacInputContext::globalEventProcessor(EventHandlerCallRef, EventRef event, void *)
{
@@ -335,6 +347,12 @@ QMacInputContext::globalEventProcessor(EventHandlerCallRef, EventRef event, void
GetEventParameter(key_ev, kEventParamKeyMacCharCodes, typeChar, 0, sizeof(chr), 0, &chr);
if(!chr || chr >= 128 || (text.length() > 0 && (text.length() > 1 || text.at(0) != QLatin1Char(chr))))
handled_event = !widget->testAttribute(Qt::WA_InputMethodEnabled);
+ QMacInputContext *context = qobject_cast<QMacInputContext*>(qApp->inputContext());
+ if (context && context->lastKeydownEvent()) {
+ qt_keymapper_private()->translateKeyEvent(widget, 0, context->lastKeydownEvent(),
+ 0, false);
+ context->setLastKeydownEvent(0);
+ }
}
break; }
default:
diff --git a/src/gui/inputmethod/qmacinputcontext_p.h b/src/gui/inputmethod/qmacinputcontext_p.h
index f708040..c3f245a 100644
--- a/src/gui/inputmethod/qmacinputcontext_p.h
+++ b/src/gui/inputmethod/qmacinputcontext_p.h
@@ -78,6 +78,10 @@ public:
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:
@@ -85,6 +89,7 @@ private:
bool recursionGuard;
TSMDocumentID textDocument;
QString currentText;
+ EventRef keydownEvent;
};
QT_END_NAMESPACE
diff --git a/src/gui/inputmethod/qwininputcontext_win.cpp b/src/gui/inputmethod/qwininputcontext_win.cpp
index 663184f..0ba4cd4 100644
--- a/src/gui/inputmethod/qwininputcontext_win.cpp
+++ b/src/gui/inputmethod/qwininputcontext_win.cpp
@@ -57,15 +57,17 @@
#ifdef Q_IME_DEBUG
#include "qdebug.h"
-#endif
-
-QT_BEGIN_NAMESPACE
+#endif
-extern bool qt_sendSpontaneousEvent(QObject*, QEvent*);
#if defined(Q_OS_WINCE)
extern void qt_wince_show_SIP(bool show); // defined in qguifunctions_wince.cpp
#endif
+QT_BEGIN_NAMESPACE
+
+extern bool qt_sendSpontaneousEvent(QObject*, QEvent*);
+
+
DEFINE_GUID(IID_IActiveIMMApp,
0x08c0e040, 0x62d1, 0x11d1, 0x93, 0x26, 0x0, 0x60, 0xb0, 0x67, 0xb8, 0x6e);
diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp
index 09ea444..b1aac37 100644
--- a/src/gui/itemviews/qabstractitemview.cpp
+++ b/src/gui/itemviews/qabstractitemview.cpp
@@ -1400,6 +1400,9 @@ bool QAbstractItemView::event(QEvent *event)
case QEvent::FocusOut:
d->checkPersistentEditorFocus();
break;
+ case QEvent::FontChange:
+ d->doDelayedItemsLayout(); // the size of the items will change
+ break;
default:
break;
}
diff --git a/src/gui/itemviews/qheaderview.cpp b/src/gui/itemviews/qheaderview.cpp
index aacfab0..eb36178 100644
--- a/src/gui/itemviews/qheaderview.cpp
+++ b/src/gui/itemviews/qheaderview.cpp
@@ -1195,7 +1195,7 @@ QHeaderView::ResizeMode QHeaderView::resizeMode(int logicalIndex) const
Q_D(const QHeaderView);
int visual = visualIndex(logicalIndex);
Q_ASSERT(visual != -1);
- return d->visualIndexResizeMode(visual);
+ return d->headerSectionResizeMode(visual);
}
/*!
@@ -1234,7 +1234,7 @@ void QHeaderView::setSortIndicatorShown(bool show)
if (sortIndicatorSection() < 0 || sortIndicatorSection() > count())
return;
- if (d->visualIndexResizeMode(sortIndicatorSection()) == ResizeToContents)
+ if (d->headerSectionResizeMode(sortIndicatorSection()) == ResizeToContents)
resizeSections();
d->viewport->update();
@@ -2937,22 +2937,25 @@ int QHeaderViewPrivate::lastVisibleVisualIndex() const
void QHeaderViewPrivate::resizeSections(QHeaderView::ResizeMode globalMode, bool useGlobalMode)
{
Q_Q(QHeaderView);
+ //stop the timer in case it is delayed
+ delayedResize.stop();
executePostedLayout();
if (sectionCount == 0)
return;
+
+ if (resizeRecursionBlock)
+ return;
+ resizeRecursionBlock = true;
+
invalidateCachedSizeHint();
+ const int lastVisibleSection = lastVisibleVisualIndex();
+
// find stretchLastSection if we have it
int stretchSection = -1;
- if (stretchLastSection && !useGlobalMode) {
- for (int i = sectionCount - 1; i >= 0; --i) {
- if (!isVisualIndexHidden(i)) {
- stretchSection = i;
- break;
- }
- }
- }
+ if (stretchLastSection && !useGlobalMode)
+ stretchSection = lastVisibleVisualIndex();
// count up the number of strected sections and how much space left for them
int lengthToStrech = (orientation == Qt::Horizontal ? viewport->width() : viewport->height());
@@ -2966,7 +2969,7 @@ void QHeaderViewPrivate::resizeSections(QHeaderView::ResizeMode globalMode, bool
if (useGlobalMode && (i != stretchSection))
resizeMode = globalMode;
else
- resizeMode = (i == stretchSection ? QHeaderView::Stretch : visualIndexResizeMode(i));
+ resizeMode = (i == stretchSection ? QHeaderView::Stretch : headerSectionResizeMode(i));
if (resizeMode == QHeaderView::Stretch) {
++numberOfStretchedSections;
@@ -2998,7 +3001,6 @@ void QHeaderViewPrivate::resizeSections(QHeaderView::ResizeMode globalMode, bool
int spanStartSection = 0;
int previousSectionLength = 0;
- const int lastVisibleSection = lastVisibleVisualIndex();
QHeaderView::ResizeMode previousSectionResizeMode = QHeaderView::Interactive;
@@ -3017,7 +3019,7 @@ void QHeaderViewPrivate::resizeSections(QHeaderView::ResizeMode globalMode, bool
else
resizeMode = (i == stretchSection
? QHeaderView::Stretch
- : visualIndexResizeMode(i));
+ : newSectionResizeMode);
if (resizeMode == QHeaderView::Stretch && stretchSectionLength != -1) {
if (i == lastVisibleSection)
newSectionLength = qMax(stretchSectionLength, lastSectionSize);
@@ -3054,7 +3056,7 @@ void QHeaderViewPrivate::resizeSections(QHeaderView::ResizeMode globalMode, bool
(sectionCount - spanStartSection) * previousSectionLength,
previousSectionResizeMode);
//Q_ASSERT(headerLength() == length);
-
+ resizeRecursionBlock = false;
viewport->update();
}
diff --git a/src/gui/itemviews/qheaderview_p.h b/src/gui/itemviews/qheaderview_p.h
index fbba69a..95bd84c 100644
--- a/src/gui/itemviews/qheaderview_p.h
+++ b/src/gui/itemviews/qheaderview_p.h
@@ -91,6 +91,7 @@ public:
stretchLastSection(false),
cascadingResizing(false),
forceInitializing(false),
+ resizeRecursionBlock(false),
stretchSections(0),
contentsSections(0),
minimumSectionSize(-1),
@@ -170,10 +171,6 @@ public:
if (!sectionHidden.isEmpty()) sectionHidden.setBit(visual, hidden);
}
- inline QHeaderView::ResizeMode visualIndexResizeMode(int visual) const {
- return headerSectionResizeMode(visual);
- }
-
inline bool hasAutoResizeSections() const {
return stretchSections || stretchLastSection || contentsSections;
}
@@ -211,7 +208,7 @@ public:
}
inline bool sectionIsCascadable(int visual) const {
- return visualIndexResizeMode(visual) == QHeaderView::Interactive;
+ return headerSectionResizeMode(visual) == QHeaderView::Interactive;
}
inline int modelSectionCount() const {
@@ -231,7 +228,6 @@ public:
inline void executePostedResize() const {
if (delayedResize.isActive() && state == NoState) {
- delayedResize.stop();
const_cast<QHeaderView*>(q_func())->resizeSections();
}
}
@@ -276,6 +272,7 @@ public:
bool stretchLastSection;
bool cascadingResizing;
bool forceInitializing;
+ bool resizeRecursionBlock;
int stretchSections;
int contentsSections;
int defaultSectionSize;
diff --git a/src/gui/itemviews/qsortfilterproxymodel.cpp b/src/gui/itemviews/qsortfilterproxymodel.cpp
index 10bcb9a..b0137d2 100644
--- a/src/gui/itemviews/qsortfilterproxymodel.cpp
+++ b/src/gui/itemviews/qsortfilterproxymodel.cpp
@@ -274,6 +274,9 @@ IndexMap::const_iterator QSortFilterProxyModelPrivate::create_mapping(
Mapping *m = new Mapping;
+ if (model->canFetchMore(source_parent))
+ model->fetchMore(source_parent);
+
int source_rows = model->rowCount(source_parent);
for (int i = 0; i < source_rows; ++i) {
if (q->filterAcceptsRow(i, source_parent))
diff --git a/src/gui/itemviews/qtreeview.cpp b/src/gui/itemviews/qtreeview.cpp
index 6dddfab..61f1b5b 100644
--- a/src/gui/itemviews/qtreeview.cpp
+++ b/src/gui/itemviews/qtreeview.cpp
@@ -2019,6 +2019,7 @@ int QTreeView::verticalOffset() const
// If we are scrolling per item and have non-uniform row heights,
// finding the vertical offset in pixels is going to be relatively slow.
// ### find a faster way to do this
+ d->executePostedLayout();
int offset = 0;
for (int i = 0; i < d->viewItems.count(); ++i) {
if (i == verticalScrollBar()->value())
diff --git a/src/gui/kernel/qapplication_x11.cpp b/src/gui/kernel/qapplication_x11.cpp
index 10fb886..b1270bc 100644
--- a/src/gui/kernel/qapplication_x11.cpp
+++ b/src/gui/kernel/qapplication_x11.cpp
@@ -1362,8 +1362,10 @@ static void qt_set_x11_resources(const char* font = 0, const char* fg = 0,
pal.setColor(QPalette::Disabled, QPalette::Highlight, Qt::darkBlue);
}
- QApplicationPrivate::setSystemPalette(pal);
-
+ // QGtkStyle sets it's own system palette
+ if (!(QApplicationPrivate::app_style && QApplicationPrivate::app_style->inherits("QGtkStyle"))) {
+ QApplicationPrivate::setSystemPalette(pal);
+ }
QColor::setAllowX11ColorNames(allowX11ColorNames);
}
diff --git a/src/gui/kernel/qcocoaapplication_mac.mm b/src/gui/kernel/qcocoaapplication_mac.mm
index f95f004f..a3cc2c1 100644
--- a/src/gui/kernel/qcocoaapplication_mac.mm
+++ b/src/gui/kernel/qcocoaapplication_mac.mm
@@ -1,11 +1,11 @@
/****************************************************************************
- **
- ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
- **
- ** This file is part of the QtGui module of the Qt Toolkit.
- **
- ** $QT_BEGIN_LICENSE:LGPL$
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
@@ -36,11 +36,11 @@
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
** $QT_END_LICENSE$
- **
- ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- **
- ****************************************************************************/
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+****************************************************************************/
/****************************************************************************
**
diff --git a/src/gui/kernel/qcocoaapplicationdelegate_mac.mm b/src/gui/kernel/qcocoaapplicationdelegate_mac.mm
index e6bd511..6571068 100644
--- a/src/gui/kernel/qcocoaapplicationdelegate_mac.mm
+++ b/src/gui/kernel/qcocoaapplicationdelegate_mac.mm
@@ -1,11 +1,11 @@
/****************************************************************************
- **
- ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
- **
- ** This file is part of the QtGui module of the Qt Toolkit.
- **
- ** $QT_BEGIN_LICENSE:LGPL$
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
@@ -36,11 +36,11 @@
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
** $QT_END_LICENSE$
- **
- ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- **
- ****************************************************************************/
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+****************************************************************************/
/****************************************************************************
**
diff --git a/src/gui/kernel/qcocoamenuloader_mac.mm b/src/gui/kernel/qcocoamenuloader_mac.mm
index 7ecb765..e836286 100644
--- a/src/gui/kernel/qcocoamenuloader_mac.mm
+++ b/src/gui/kernel/qcocoamenuloader_mac.mm
@@ -1,11 +1,11 @@
/****************************************************************************
- **
- ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
- **
- ** This file is part of the QtGui module of the Qt Toolkit.
- **
- ** $QT_BEGIN_LICENSE:LGPL$
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
@@ -36,11 +36,11 @@
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
** $QT_END_LICENSE$
- **
- ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- **
- ****************************************************************************/
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+****************************************************************************/
#include "qmacdefines_mac.h"
#ifdef QT_MAC_USE_COCOA
diff --git a/src/gui/kernel/qcocoapanel_mac.mm b/src/gui/kernel/qcocoapanel_mac.mm
index c17b30c..c69826f 100644
--- a/src/gui/kernel/qcocoapanel_mac.mm
+++ b/src/gui/kernel/qcocoapanel_mac.mm
@@ -49,8 +49,10 @@
#include <QtGui/QWidget>
+QT_FORWARD_DECLARE_CLASS(QWidget);
+QT_BEGIN_NAMESPACE
extern Qt::MouseButton cocoaButton2QtButton(NSInteger buttonNum); // qcocoaview.mm
-
+QT_END_NAMESPACE
QT_USE_NAMESPACE
@implementation QT_MANGLE_NAMESPACE(QCocoaPanel)
@@ -108,7 +110,7 @@ QT_USE_NAMESPACE
[self retain];
QWidget *widget = [[QT_MANGLE_NAMESPACE(QCocoaWindowDelegate) sharedDelegate] qt_qwidgetForWindow:self];
- QCocoaView *view = static_cast<QCocoaView *>(qt_mac_nativeview_for(widget));
+ QT_MANGLE_NAMESPACE(QCocoaView) *view = static_cast<QT_MANGLE_NAMESPACE(QCocoaView) *>(qt_mac_nativeview_for(widget));
Qt::MouseButton mouseButton = cocoaButton2QtButton([event buttonNumber]);
// sometimes need to redirect mouse events to the popup.
@@ -157,10 +159,11 @@ QT_USE_NAMESPACE
[self release];
}
-
- (BOOL)makeFirstResponder:(NSResponder *)responder
{
- if (responder == nil)
+ // For some reason Cocoa wants to flip the first responder
+ // when Qt doesn't want to, sorry, but "No" :-)
+ if (responder == nil && qApp->focusWidget())
return NO;
return [super makeFirstResponder:responder];
}
@@ -171,7 +174,7 @@ QT_USE_NAMESPACE
+ (Class)frameViewClassForStyleMask:(NSUInteger)styleMask
{
if (styleMask & QtMacCustomizeWindow)
- return [QCocoaWindowCustomThemeFrame class];
+ return [QT_MANGLE_NAMESPACE(QCocoaWindowCustomThemeFrame) class];
return [super frameViewClassForStyleMask:styleMask];
}
diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm
index 19367d1..670226b 100644
--- a/src/gui/kernel/qcocoaview_mac.mm
+++ b/src/gui/kernel/qcocoaview_mac.mm
@@ -181,6 +181,7 @@ QT_FORWARD_DECLARE_CLASS(QAbstractScrollAreaPrivate)
QT_FORWARD_DECLARE_CLASS(QPaintEvent)
QT_FORWARD_DECLARE_CLASS(QPainter)
QT_FORWARD_DECLARE_CLASS(QHoverEvent)
+QT_FORWARD_DECLARE_CLASS(QCursor)
QT_USE_NAMESPACE
extern "C" {
extern NSString *NSTextInputReplacementRangeAttributeName;
@@ -195,6 +196,7 @@ extern "C" {
if (self) {
[self finishInitWithQWidget:widget widgetPrivate:widgetprivate];
}
+ composingText = new QString();
composing = false;
sendKeyEvents = true;
[self setHidden:YES];
@@ -236,6 +238,34 @@ extern "C" {
}
}
+- (void)resetCursorRects
+{
+ QWidget *cursorWidget = qwidget;
+
+ if (cursorWidget->testAttribute(Qt::WA_TransparentForMouseEvents))
+ cursorWidget = QApplication::widgetAt(qwidget->mapToGlobal(qwidget->rect().center()));
+
+ if (cursorWidget == 0)
+ return;
+
+ if (!cursorWidget->testAttribute(Qt::WA_SetCursor)) {
+ [super resetCursorRects];
+ return;
+ }
+
+ QRegion mask = qt_widget_private(cursorWidget)->extra->mask;
+ NSCursor *nscursor = static_cast<NSCursor *>(nsCursorForQCursor(cursorWidget->cursor()));
+ if (mask.isEmpty()) {
+ [self addCursorRect:[qt_mac_nativeview_for(cursorWidget) visibleRect] cursor:nscursor];
+ } else {
+ const QVector<QRect> &rects = mask.rects();
+ for (int i = 0; i < rects.size(); ++i) {
+ const QRect &rect = rects.at(i);
+ [self addCursorRect:NSMakeRect(rect.x(), rect.y(), rect.width(), rect.height()) cursor:nscursor];
+ }
+ }
+}
+
- (void)removeDropData
{
if (dropData) {
@@ -300,11 +330,13 @@ extern "C" {
NSPoint windowPoint = [sender draggingLocation];
NSPoint globalPoint = [[sender draggingDestinationWindow] convertBaseToScreen:windowPoint];
NSPoint localPoint = [self convertPoint:windowPoint fromView:nil];
+ NSDragOperation nsActions = [sender draggingSourceOperationMask];
QPoint posDrag(localPoint.x, localPoint.y);
- if (qt_mac_mouse_inside_answer_rect(posDrag))
+ if (qt_mac_mouse_inside_answer_rect(posDrag)
+ && QT_PREPEND_NAMESPACE(qt_mac_dnd_answer_rec.lastOperation) == nsActions)
return QT_PREPEND_NAMESPACE(qt_mac_mapDropActions)(QT_PREPEND_NAMESPACE(qt_mac_dnd_answer_rec.lastAction));
// send drag move event to the widget
- NSDragOperation nsActions = [sender draggingSourceOperationMask];
+ QT_PREPEND_NAMESPACE(qt_mac_dnd_answer_rec.lastOperation) = nsActions;
Qt::DropActions qtAllowed = QT_PREPEND_NAMESPACE(qt_mac_mapNSDragOperations)(nsActions);
QMimeData *mimeData = dropData;
if (QDragManager::self()->source())
@@ -364,6 +396,7 @@ extern "C" {
- (void)dealloc
{
+ delete composingText;
[[NSNotificationCenter defaultCenter] removeObserver:self];
[super dealloc];
}
@@ -913,11 +946,32 @@ extern "C" {
}
}
+- (void)viewWillMoveToWindow:(NSWindow *)window
+{
+ if (qwidget->windowFlags() & Qt::MSWindowsOwnDC
+ && (window != [self window])) { // OpenGL Widget
+ // Create a stupid ClearDrawable Event
+ QEvent event(QEvent::MacGLClearDrawable);
+ qApp->sendEvent(qwidget, &event);
+ }
+}
+
+- (void)viewDidMoveToWindow
+{
+ if (qwidget->windowFlags() & Qt::MSWindowsOwnDC && [self window]) {
+ // call update paint event
+ qwidgetprivate->needWindowChange = true;
+ QEvent event(QEvent::MacGLWindowChange);
+ qApp->sendEvent(qwidget, &event);
+ }
+}
+
+
// NSTextInput Protocol implementation
- (void) insertText:(id)aString
{
- if (composing) {
+ if ([aString length]) {
// Send the commit string to the widget.
QString commitText;
if ([aString isKindOfClass:[NSAttributedString class]]) {
@@ -931,6 +985,7 @@ extern "C" {
e.setCommitString(commitText);
qt_sendSpontaneousEvent(qwidget, &e);
}
+ composingText->clear();
}
- (void) setMarkedText:(id)aString selectedRange:(NSRange)selRange
@@ -984,12 +1039,21 @@ extern "C" {
attrs<<QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat,
0, composingLength, format);
}
+ *composingText = qtText;
QInputMethodEvent e(qtText, attrs);
qt_sendSpontaneousEvent(qwidget, &e);
+ if (!composingLength)
+ composing = false;
}
- (void) unmarkText
{
+ if (composing) {
+ QInputMethodEvent e;
+ e.setCommitString(*composingText);
+ qt_sendSpontaneousEvent(qwidget, &e);
+ }
+ composingText->clear();
composing = false;
}
diff --git a/src/gui/kernel/qcocoaview_mac_p.h b/src/gui/kernel/qcocoaview_mac_p.h
index 9de94d5..ec1281e 100644
--- a/src/gui/kernel/qcocoaview_mac_p.h
+++ b/src/gui/kernel/qcocoaview_mac_p.h
@@ -83,6 +83,7 @@ Q_GUI_EXPORT
bool composing;
int composingLength;
bool sendKeyEvents;
+ QString *composingText;
}
- (id)initWithQWidget:(QWidget *)widget widgetPrivate:(QWidgetPrivate *)widgetprivate;
- (void) finishInitWithQWidget:(QWidget *)widget widgetPrivate:(QWidgetPrivate *)widgetprivate;
diff --git a/src/gui/kernel/qcocoawindow_mac.mm b/src/gui/kernel/qcocoawindow_mac.mm
index ba121cd..89f481f 100644
--- a/src/gui/kernel/qcocoawindow_mac.mm
+++ b/src/gui/kernel/qcocoawindow_mac.mm
@@ -1,11 +1,11 @@
/****************************************************************************
- **
- ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
- **
- ** This file is part of the QtGui module of the Qt Toolkit.
- **
- ** $QT_BEGIN_LICENSE:LGPL$
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
@@ -36,11 +36,11 @@
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
** $QT_END_LICENSE$
- **
- ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- **
- ****************************************************************************/
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+****************************************************************************/
#include "qmacdefines_mac.h"
#ifdef QT_MAC_USE_COCOA
@@ -53,9 +53,10 @@
#include <QtGui/QWidget>
QT_FORWARD_DECLARE_CLASS(QWidget);
-QT_USE_NAMESPACE
-
+QT_BEGIN_NAMESPACE
extern Qt::MouseButton cocoaButton2QtButton(NSInteger buttonNum); // qcocoaview.mm
+QT_END_NAMESPACE
+QT_USE_NAMESPACE
@implementation NSWindow (QT_MANGLE_NAMESPACE(QWidgetIntegration))
@@ -130,7 +131,7 @@ extern Qt::MouseButton cocoaButton2QtButton(NSInteger buttonNum); // qcocoaview.
[self retain];
QWidget *widget = [[QT_MANGLE_NAMESPACE(QCocoaWindowDelegate) sharedDelegate] qt_qwidgetForWindow:self];
- QCocoaView *view = static_cast<QCocoaView *>(qt_mac_nativeview_for(widget));
+ QT_MANGLE_NAMESPACE(QCocoaView) *view = static_cast<QT_MANGLE_NAMESPACE(QCocoaView) *>(qt_mac_nativeview_for(widget));
Qt::MouseButton mouseButton = cocoaButton2QtButton([event buttonNumber]);
// sometimes need to redirect mouse events to the popup.
@@ -182,7 +183,9 @@ extern Qt::MouseButton cocoaButton2QtButton(NSInteger buttonNum); // qcocoaview.
- (BOOL)makeFirstResponder:(NSResponder *)responder
{
- if (responder == nil)
+ // For some reason Cocoa wants to flip the first responder
+ // when Qt doesn't want to, sorry, but "No" :-)
+ if (responder == nil && qApp->focusWidget())
return NO;
return [super makeFirstResponder:responder];
}
diff --git a/src/gui/kernel/qcocoawindowdelegate_mac.mm b/src/gui/kernel/qcocoawindowdelegate_mac.mm
index 8480179..03b2fce 100644
--- a/src/gui/kernel/qcocoawindowdelegate_mac.mm
+++ b/src/gui/kernel/qcocoawindowdelegate_mac.mm
@@ -1,11 +1,11 @@
/****************************************************************************
- **
- ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
- **
- ** This file is part of the QtGui module of the Qt Toolkit.
- **
- ** $QT_BEGIN_LICENSE:LGPL$
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
@@ -36,11 +36,11 @@
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
** $QT_END_LICENSE$
- **
- ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- **
- ****************************************************************************/
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+****************************************************************************/
#import "private/qcocoawindowdelegate_mac_p.h"
#ifdef QT_MAC_USE_COCOA
diff --git a/src/gui/kernel/qcursor.h b/src/gui/kernel/qcursor.h
index 15b4597..ad1860d 100644
--- a/src/gui/kernel/qcursor.h
+++ b/src/gui/kernel/qcursor.h
@@ -77,6 +77,7 @@ class QBitmap;
class QPixmap;
#if defined(Q_WS_MAC)
+void *nsCursorForQCursor(const QCursor &c);
void qt_mac_set_cursor(const QCursor *c, const QPoint &p);
#endif
@@ -128,6 +129,7 @@ public:
private:
QCursorData *d;
#if defined(Q_WS_MAC)
+ friend void *nsCursorForQCursor(const QCursor &c);
friend void qt_mac_set_cursor(const QCursor *c, const QPoint &p);
#endif
};
diff --git a/src/gui/kernel/qcursor_mac.mm b/src/gui/kernel/qcursor_mac.mm
index d632eb79..ae98f2e 100644
--- a/src/gui/kernel/qcursor_mac.mm
+++ b/src/gui/kernel/qcursor_mac.mm
@@ -95,9 +95,19 @@ protected:
}
};
+void *nsCursorForQCursor(const QCursor &c)
+{
+ c.d->update();
+ return [[static_cast<NSCursor *>(c.d->curs.cp.nscursor) retain] autorelease];
+}
+
static QCursorData *currentCursor = 0; //current cursor
void qt_mac_set_cursor(const QCursor *c, const QPoint &)
{
+#ifdef QT_MAC_USE_COCOA
+ Q_UNUSED(c);
+ return;
+#else
if (!c) {
currentCursor = 0;
return;
@@ -128,10 +138,15 @@ void qt_mac_set_cursor(const QCursor *c, const QPoint &)
}
}
currentCursor = c->d;
+#endif
}
void qt_mac_update_cursor_at_global_pos(const QPoint &globalPos)
{
+#ifdef QT_MAC_USE_COCOA
+ Q_UNUSED(globalPos);
+ return;
+#else
QCursor cursor(Qt::ArrowCursor);
if (QApplication::overrideCursor()) {
cursor = *QApplication::overrideCursor();
@@ -144,6 +159,7 @@ void qt_mac_update_cursor_at_global_pos(const QPoint &globalPos)
}
}
qt_mac_set_cursor(&cursor, globalPos);
+#endif
}
void qt_mac_update_cursor()
diff --git a/src/gui/kernel/qkeymapper_mac.cpp b/src/gui/kernel/qkeymapper_mac.cpp
index 1a0fb08..39abc5e 100644
--- a/src/gui/kernel/qkeymapper_mac.cpp
+++ b/src/gui/kernel/qkeymapper_mac.cpp
@@ -48,6 +48,7 @@
#include <qinputcontext.h>
#include <private/qkeymapper_p.h>
#include <private/qapplication_p.h>
+#include <private/qmacinputcontext_p.h>
QT_BEGIN_NAMESPACE
@@ -480,7 +481,8 @@ static bool translateKeyEventInternal(EventHandlerCallRef er, EventRef keyEvent,
#ifdef QT_MAC_USE_COCOA
if (outHandled) {
qt_mac_eat_unicode_key = false;
- CallNextEventHandler(er, keyEvent);
+ if (er)
+ CallNextEventHandler(er, keyEvent);
*outHandled = qt_mac_eat_unicode_key;
}
#endif
@@ -692,8 +694,14 @@ bool QKeyMapperPrivate::translateKeyEvent(QWidget *widget, EventHandlerCallRef e
return true;
}
- if (qApp->inputContext() && qApp->inputContext()->isComposing())
+ if (qApp->inputContext() && qApp->inputContext()->isComposing()) {
+ if (ekind == kEventRawKeyDown) {
+ QMacInputContext *context = qobject_cast<QMacInputContext*>(qApp->inputContext());
+ if (context)
+ context->setLastKeydownEvent(event);
+ }
return false;
+ }
//get modifiers
Qt::KeyboardModifiers modifiers;
int qtKey;
@@ -721,7 +729,8 @@ bool QKeyMapperPrivate::translateKeyEvent(QWidget *widget, EventHandlerCallRef e
//is it of use to text services? If so we won't bother
//with a QKeyEvent.
qt_mac_eat_unicode_key = false;
- CallNextEventHandler(er, event);
+ if (er)
+ CallNextEventHandler(er, event);
extern bool qt_mac_menubar_is_open();
if (qt_mac_eat_unicode_key || qt_mac_menubar_is_open()) {
return true;
diff --git a/src/gui/kernel/qmacdefines_mac.h b/src/gui/kernel/qmacdefines_mac.h
index 97ec544..035b8c5 100644
--- a/src/gui/kernel/qmacdefines_mac.h
+++ b/src/gui/kernel/qmacdefines_mac.h
@@ -105,7 +105,7 @@ Yes, it is an informative comment ;-)
# undef qDebug
#endif
-#if __LP64__
+#ifdef __LP64__
typedef signed int OSStatus;
#else
typedef signed long OSStatus;
diff --git a/src/gui/kernel/qt_mac_p.h b/src/gui/kernel/qt_mac_p.h
index 3aec23f..ca995dc 100644
--- a/src/gui/kernel/qt_mac_p.h
+++ b/src/gui/kernel/qt_mac_p.h
@@ -233,6 +233,7 @@ extern QPaintDevice *qt_mac_safe_pdev; //qapplication_mac.cpp
extern OSWindowRef qt_mac_window_for(const QWidget*); //qwidget_mac.mm
extern OSViewRef qt_mac_nativeview_for(const QWidget *); //qwidget_mac.mm
+extern QPoint qt_mac_nativeMapFromParent(const QWidget *child, const QPoint &pt); //qwidget_mac.mm
#ifdef check
# undef check
@@ -249,11 +250,13 @@ struct QMacDndAnswerRecord {
Qt::KeyboardModifiers modifiers;
Qt::MouseButtons buttons;
Qt::DropAction lastAction;
+ unsigned int lastOperation;
void clear() {
rect = QRect();
modifiers = Qt::NoModifier;
buttons = Qt::NoButton;
lastAction = Qt::IgnoreAction;
+ lastOperation = 0;
}
};
extern QMacDndAnswerRecord qt_mac_dnd_answer_rec;
diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp
index 8ce0231..3e25ffc 100644
--- a/src/gui/kernel/qwidget.cpp
+++ b/src/gui/kernel/qwidget.cpp
@@ -66,6 +66,7 @@
#ifdef Q_WS_MAC
# include "qt_mac_p.h"
# include "qt_cocoa_helpers_mac_p.h"
+# include "qmainwindow.h"
#endif
#if defined(Q_WS_QWS)
# include "qwsdisplay_qws.h"
@@ -4779,7 +4780,7 @@ void QWidget::render(QPainter *painter, const QPoint &targetOffset,
}
const qreal opacity = painter->opacity();
- if (qFuzzyCompare(opacity + 1, qreal(1.0)))
+ if (qFuzzyIsNull(opacity))
return; // Fully transparent.
Q_D(QWidget);
@@ -8979,17 +8980,36 @@ QWidget *QWidget::childAt(const QPoint &p) const
QWidget *QWidgetPrivate::childAt_helper(const QPoint &p, bool ignoreChildrenInDestructor) const
{
Q_Q(const QWidget);
- if (!q->rect().contains(p))
+#ifdef Q_WS_MAC
+ bool includeFrame = q->isWindow() && qobject_cast<const QMainWindow *>(q)
+ && static_cast<const QMainWindow *>(q)->unifiedTitleAndToolBarOnMac();
+#endif
+
+ if (
+#ifdef Q_WS_MAC
+ !includeFrame &&
+#endif
+ !q->rect().contains(p))
return 0;
+
for (int i = children.size(); i > 0 ;) {
--i;
QWidget *w = qobject_cast<QWidget *>(children.at(i));
- if (w && !w->isWindow() && !w->isHidden() && w->geometry().contains(p)) {
+ if (w && !w->isWindow() && !w->isHidden()
+ && (w->geometry().contains(p)
+#ifdef Q_WS_MAC
+ || (includeFrame && w->geometry().contains(qt_mac_nativeMapFromParent(w, p)))
+#endif
+ )) {
if (ignoreChildrenInDestructor && w->data->in_destructor)
continue;
if (w->testAttribute(Qt::WA_TransparentForMouseEvents))
continue;
QPoint childPoint = w->mapFromParent(p);
+#ifdef Q_WS_MAC
+ if (includeFrame && !w->geometry().contains(p))
+ childPoint = qt_mac_nativeMapFromParent(w, p);
+#endif
if (QWidget *t = w->d_func()->childAt_helper(childPoint, ignoreChildrenInDestructor))
return t;
// if WMouseNoMask is set the widget mask is ignored, if
@@ -9430,11 +9450,13 @@ void QWidget::repaint(const QRect &rect)
if (!isVisible() || !updatesEnabled() || rect.isEmpty())
return;
- QTLWExtra *tlwExtra = !d->paintOnScreen() ? window()->d_func()->maybeTopData() : 0;
- if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore) {
- tlwExtra->inRepaint = true;
- tlwExtra->backingStore->markDirty(rect, this, true);
- tlwExtra->inRepaint = false;
+ if (hasBackingStoreSupport()) {
+ 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);
}
@@ -9457,11 +9479,13 @@ void QWidget::repaint(const QRegion &rgn)
if (!isVisible() || !updatesEnabled() || rgn.isEmpty())
return;
- QTLWExtra *tlwExtra = !d->paintOnScreen() ? window()->d_func()->maybeTopData() : 0;
- if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore) {
- tlwExtra->inRepaint = true;
- tlwExtra->backingStore->markDirty(rgn, this, true);
- tlwExtra->inRepaint = false;
+ if (hasBackingStoreSupport()) {
+ 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);
}
diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm
index a3c026b..5d91c74 100644
--- a/src/gui/kernel/qwidget_mac.mm
+++ b/src/gui/kernel/qwidget_mac.mm
@@ -2166,7 +2166,10 @@ void QWidgetPrivate::finishCreateWindow_sys_Cocoa(void * /*NSWindow * */ voidWin
if ((popup || type == Qt::Tool || type == Qt::ToolTip) && !q->isModal()) {
[windowRef setHidesOnDeactivate:YES];
[windowRef setHasShadow:YES];
+ } else {
+ [windowRef setHidesOnDeactivate:NO];
}
+
Q_UNUSED(parentWidget);
Q_UNUSED(dialog);
@@ -2838,12 +2841,26 @@ void QWidgetPrivate::updateSystemBackground()
void QWidgetPrivate::setCursor_sys(const QCursor &)
{
+ Q_Q(QWidget);
+#ifndef QT_MAC_USE_COCOA
qt_mac_update_cursor();
+#else
+ if (q->testAttribute(Qt::WA_WState_Created)) {
+ [qt_mac_window_for(q) invalidateCursorRectsForView:qt_mac_nativeview_for(q)];
+ }
+#endif
}
void QWidgetPrivate::unsetCursor_sys()
{
+ Q_Q(QWidget);
+#ifndef QT_MAC_USE_COCOA
qt_mac_update_cursor();
+#else
+ if (q->testAttribute(Qt::WA_WState_Created)) {
+ [qt_mac_window_for(q) invalidateCursorRectsForView:qt_mac_nativeview_for(q)];
+ }
+#endif
}
void QWidgetPrivate::setWindowTitle_sys(const QString &caption)
@@ -3268,6 +3285,20 @@ void QWidgetPrivate::show_sys()
qt_event_request_window_change(q);
}
+
+QPoint qt_mac_nativeMapFromParent(const QWidget *child, const QPoint &pt)
+{
+#ifndef QT_MAC_USE_COCOA
+ CGPoint nativePoint = CGPointMake(pt.x(), pt.y());
+ HIViewConvertPoint(&nativePoint, qt_mac_nativeview_for(child->parentWidget()),
+ qt_mac_nativeview_for(child));
+#else
+ NSPoint nativePoint = [qt_mac_nativeview_for(child) convertPoint:NSMakePoint(pt.x(), pt.y()) fromView:qt_mac_nativeview_for(child->parentWidget())];
+#endif
+ return QPoint(nativePoint.x, nativePoint.y);
+}
+
+
void QWidgetPrivate::hide_sys()
{
Q_Q(QWidget);
diff --git a/src/gui/math3d/math3d.pri b/src/gui/math3d/math3d.pri
index 581adbd..e4dd53a 100644
--- a/src/gui/math3d/math3d.pri
+++ b/src/gui/math3d/math3d.pri
@@ -1,8 +1,5 @@
HEADERS += \
- math3d/qfixedpt.h \
math3d/qgenericmatrix.h \
- math3d/qmath3dglobal.h \
- math3d/qmath3dutil_p.h \
math3d/qmatrix4x4.h \
math3d/qquaternion.h \
math3d/qvector2d.h \
@@ -10,9 +7,7 @@ HEADERS += \
math3d/qvector4d.h
SOURCES += \
- math3d/qfixedpt.cpp \
math3d/qgenericmatrix.cpp \
- math3d/qmath3dutil.cpp \
math3d/qmatrix4x4.cpp \
math3d/qquaternion.cpp \
math3d/qvector2d.cpp \
diff --git a/src/gui/math3d/qfixedpt.cpp b/src/gui/math3d/qfixedpt.cpp
deleted file mode 100644
index 93f2150..0000000
--- a/src/gui/math3d/qfixedpt.cpp
+++ /dev/null
@@ -1,711 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (qt-info@nokia.com)
-**
-** This file is part of the $MODULE$ of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at qt-sales@nokia.com.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qfixedpt.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \internal
- Returns the fixed-point square root of \a value.
-*/
-qint64 qt_math3d_fixed_sqrt(qint64 value)
-{
- qint64 result = 0;
- qint64 bit = ((qint64)1) << 62;
- while (bit > value)
- bit >>= 2;
- while (bit != 0) {
- if (value >= (result + bit)) {
- value -= result + bit;
- result += (bit << 1);
- }
- result >>= 1;
- bit >>= 2;
- }
- return result;
-}
-
-/*!
- \class QFixedPt
- \brief The QFixedPt class represents fixed-point numbers within a 32-bit integer with a configurable precision.
-
- The template parameter is the number of bits of precision after
- the decimal point. For example, QFixedPt<5> indicates that there
- are 27 bits before the decimal point, and 5 bits of precision after
- the decimal point.
-*/
-
-/*!
- \fn QFixedPt::QFixedPt()
-
- Constructs a default fixed-point number. The initial value
- is undefined.
-*/
-
-/*!
- \fn QFixedPt::QFixedPt(int value)
-
- Constructs a fixed-point number from the integer \a value.
-*/
-
-/*!
- \fn QFixedPt::QFixedPt(qreal value)
-
- Constructs a fixed-point number from the floating-point \a value.
-*/
-
-/*!
- \fn QFixedPt<PrecBits>& QFixedPt::operator=(int value)
-
- Assigns the integer \a value to this fixed-point variable.
-*/
-
-/*!
- \fn QFixedPt<PrecBits>& QFixedPt::operator=(qreal value)
-
- Assigns the floating-point \a value to this fixed-point variable.
-*/
-
-/*!
- \fn int QFixedPt::bits() const
-
- Returns the raw bits that represent the fixed-point value of this object.
-
- \sa setBits()
-*/
-
-/*!
- \fn void QFixedPt::setBits(int value)
-
- Sets the raw bits that represent the fixed-point value of
- this object to \a value.
-
- \sa bits()
-*/
-
-#if !defined(QT_NO_MEMBER_TEMPLATES) || defined(Q_QDOC)
-
-/*!
- \fn QFixedPt<Prec> QFixedPt::toPrecision() const
-
- Returns this fixed-point number, converted to the new fixed-point
- precision Prec.
-
- \sa qFixedPtToPrecision()
-*/
-
-#endif
-
-/*!
- \fn QFixedPt<Prec> qFixedPtToPrecision(const QFixedPt<PrecBits>& value)
-
- Returns the fixed-point number \a value, converted to the new fixed-point
- precision Prec.
-
- \sa QFixedPt::toPrecision()
-*/
-
-/*!
- \fn QFixedPt<PrecBits>& QFixedPt::operator+=(const QFixedPt<PrecBits>& value)
-
- Adds \a value to this fixed-point number.
-*/
-
-/*!
- \fn QFixedPt<PrecBits>& QFixedPt::operator+=(int value)
-
- Adds an integer \a value to this fixed-point number.
-*/
-
-/*!
- \fn QFixedPt<PrecBits>& QFixedPt::operator+=(qreal value)
-
- Adds a floating-point \a value to this fixed-point number.
-*/
-
-/*!
- \fn QFixedPt<PrecBits>& QFixedPt::operator-=(const QFixedPt<PrecBits>& value)
-
- Subtracts \a value from this fixed-point number.
-*/
-
-/*!
- \fn QFixedPt<PrecBits>& QFixedPt::operator-=(int value)
-
- Subtracts an integer \a value from this fixed-point number.
-*/
-
-/*!
- \fn QFixedPt<PrecBits>& QFixedPt::operator-=(qreal value)
-
- Subtracts a floating-point \a value from this fixed-point number.
-*/
-
-/*!
- \fn QFixedPt<PrecBits>& QFixedPt::operator*=(const QFixedPt<PrecBits>& value)
-
- Multiplies this fixed-point number by \a value.
-*/
-
-/*!
- \fn QFixedPt<PrecBits>& QFixedPt::operator*=(int value)
-
- Multiplies this fixed-point number by an integer \a value.
-*/
-
-/*!
- \fn QFixedPt<PrecBits>& QFixedPt::operator*=(qreal value)
-
- Multiplies this fixed-point number by a floating-point \a value.
-*/
-
-/*!
- \fn QFixedPt<PrecBits>& QFixedPt::operator/=(const QFixedPt<PrecBits>& value)
-
- Divides this fixed-point number by \a value. Division by zero
- will result in zero.
-*/
-
-/*!
- \fn QFixedPt<PrecBits>& QFixedPt::operator/=(int value)
-
- Divides this fixed-point number by an integer \a value. Division
- by zero will result in zero.
-*/
-
-/*!
- \fn QFixedPt<PrecBits>& QFixedPt::operator/=(qreal value)
-
- Divides this fixed-point number by a floating-point \a value. Division
- by zero will result in zero.
-*/
-
-/*!
- \fn QFixedPt<PrecBits>& QFixedPt::operator<<=(int value)
-
- Shifts this fixed-point number left by \a value bits.
-*/
-
-/*!
- \fn QFixedPt<PrecBits>& QFixedPt::operator>>=(int value)
-
- Shifts this fixed-point number right by \a value bits.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> QFixedPt::operator<<(int value) const
-
- Returns the result of shifting this fixed-point number
- left by \a value bits.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> QFixedPt::operator>>(int value) const
-
- Returns the result of shifting this fixed-point number
- right by \a value bits.
-*/
-
-/*!
- \fn bool QFixedPt::operator==(const QFixedPt<PrecBits>& value) const
-
- Returns true if this fixed-point number is equal to \a value;
- false otherwise.
-*/
-
-/*!
- \fn bool operator==(const QFixedPt<PrecBits>& v1, int v2)
- \relates QFixedPt
-
- Returns true if \a v1 is equal to \a v2; false otherwise.
-*/
-
-/*!
- \fn bool operator==(int v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns true if \a v1 is equal to \a v2; false otherwise.
-*/
-
-/*!
- \fn bool operator==(const QFixedPt<PrecBits>& v1, qreal v2)
- \relates QFixedPt
-
- Returns true if \a v1 is equal to \a v2; false otherwise.
-*/
-
-/*!
- \fn bool operator==(qreal v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns true if \a v1 is equal to \a v2; false otherwise.
-*/
-
-/*!
- \fn bool QFixedPt::operator!=(const QFixedPt<PrecBits>& value) const
-
- Returns true if this fixed-point number is not equal to \a value;
- false otherwise.
-*/
-
-/*!
- \fn bool operator!=(const QFixedPt<PrecBits>& v1, int v2)
- \relates QFixedPt
-
- Returns true if \a v1 is not equal to \a v2; false otherwise.
-*/
-
-/*!
- \fn bool operator!=(int v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns true if \a v1 is not equal to \a v2; false otherwise.
-*/
-
-/*!
- \fn bool operator!=(const QFixedPt<PrecBits>& v1, qreal v2)
- \relates QFixedPt
-
- Returns true if \a v1 is not equal to \a v2; false otherwise.
-*/
-
-/*!
- \fn bool operator!=(qreal v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns true if \a v1 is not equal to \a v2; false otherwise.
-*/
-
-/*!
- \fn bool QFixedPt::operator<=(const QFixedPt<PrecBits>& value) const
-
- Returns true if this fixed-point number is less than or equal to
- \a value; false otherwise.
-*/
-
-/*!
- \fn bool operator<=(const QFixedPt<PrecBits>& v1, int v2)
- \relates QFixedPt
-
- Returns true if \a v1 is less than or equal to \a v2; false otherwise.
-*/
-
-/*!
- \fn bool operator<=(int v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns true if \a v1 is less than or equal to \a v2; false otherwise.
-*/
-
-/*!
- \fn bool operator<=(const QFixedPt<PrecBits>& v1, qreal v2)
- \relates QFixedPt
-
- Returns true if \a v1 is less than or equal to \a v2; false otherwise.
-*/
-
-/*!
- \fn bool operator<=(qreal v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns true if \a v1 is less than or equal to \a v2; false otherwise.
-*/
-
-/*!
- \fn bool QFixedPt::operator<(const QFixedPt<PrecBits>& value) const
-
- Returns true if this fixed-point number is less than \a value;
- false otherwise.
-*/
-
-/*!
- \fn bool operator<(const QFixedPt<PrecBits>& v1, int v2)
- \relates QFixedPt
-
- Returns true if \a v1 is less than \a v2; false otherwise.
-*/
-
-/*!
- \fn bool operator<(int v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns true if \a v1 is less than \a v2; false otherwise.
-*/
-
-/*!
- \fn bool operator<(const QFixedPt<PrecBits>& v1, qreal v2)
- \relates QFixedPt
-
- Returns true if \a v1 is less than \a v2; false otherwise.
-*/
-
-/*!
- \fn bool operator<(qreal v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns true if \a v1 is less than \a v2; false otherwise.
-*/
-
-/*!
- \fn bool QFixedPt::operator>=(const QFixedPt<PrecBits>& value) const
-
- Returns true if this fixed-point number is greater than or equal to
- \a value; false otherwise.
-*/
-
-/*!
- \fn bool operator>=(const QFixedPt<PrecBits>& v1, int v2)
- \relates QFixedPt
-
- Returns true if \a v1 is greater than or equal to \a v2; false otherwise.
-*/
-
-/*!
- \fn bool operator>=(int v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns true if \a v1 is greater than or equal to \a v2; false otherwise.
-*/
-
-/*!
- \fn bool operator>=(const QFixedPt<PrecBits>& v1, qreal v2)
- \relates QFixedPt
-
- Returns true if \a v1 is greater than or equal to \a v2; false otherwise.
-*/
-
-/*!
- \fn bool operator>=(qreal v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns true if \a v1 is greater than or equal to \a v2; false otherwise.
-*/
-
-/*!
- \fn bool QFixedPt::operator>(const QFixedPt<PrecBits>& value) const
-
- Returns true if this fixed-point number is greater than \a value;
- false otherwise.
-*/
-
-/*!
- \fn bool operator>(const QFixedPt<PrecBits>& v1, int v2)
- \relates QFixedPt
-
- Returns true if \a v1 is greater than \a v2; false otherwise.
-*/
-
-/*!
- \fn bool operator>(int v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns true if \a v1 is greater than \a v2; false otherwise.
-*/
-
-/*!
- \fn bool operator>(const QFixedPt<PrecBits>& v1, qreal v2)
- \relates QFixedPt
-
- Returns true if \a v1 is greater than \a v2; false otherwise.
-*/
-
-/*!
- \fn bool operator>(qreal v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns true if \a v1 is greater than \a v2; false otherwise.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> QFixedPt::operator+(const QFixedPt<PrecBits>& value) const
-
- Returns the result of adding this fixed-point number and \a value.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> QFixedPt::operator+(int value) const
-
- Returns the result of adding this fixed-point number and \a value.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> QFixedPt::operator+(qreal value) const
-
- Returns the result of adding this fixed-point number and \a value.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> operator+(int v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns the result of adding \a v1 and \a v2.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> operator+(qreal v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns the result of adding \a v1 and \a v2.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> QFixedPt::operator-(const QFixedPt<PrecBits>& value) const
-
- Returns the result of subtracting \a value from this fixed-point number.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> QFixedPt::operator-(int value) const
-
- Returns the result of subtracting \a value from this fixed-point number.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> QFixedPt::operator-(qreal value) const
-
- Returns the result of subtracting \a value from this fixed-point number.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> operator-(int v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns the result of subtracting \a v2 from \a v1.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> operator-(qreal v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns the result of subtracting \a v2 from \a v1.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> QFixedPt::operator*(const QFixedPt<PrecBits>& value) const
-
- Returns the result of multiplying this fixed-point number by \a value.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> QFixedPt::operator*(int value) const
-
- Returns the result of multiplying this fixed-point number by \a value.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> QFixedPt::operator*(qreal value) const
-
- Returns the result of multiplying this fixed-point number by \a value.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> operator*(int v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns the result of multiplying \a v1 by \a v2.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> operator*(qreal v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns the result of multiplying \a v1 by \a v2.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> QFixedPt::operator/(const QFixedPt<PrecBits>& value) const
-
- Returns the result of dividing this fixed-point number by \a value.
- Division by zero will result in zero.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> QFixedPt::operator/(int value) const
-
- Returns the result of dividing this fixed-point number by \a value.
- Division by zero will result in zero.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> QFixedPt::operator/(qreal value) const
-
- Returns the result of dividing this fixed-point number by \a value.
- Division by zero will result in zero.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> operator/(int v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns the result of dividing \a v1 by \a v2. Division by zero will
- result in zero.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> operator/(qreal v1, const QFixedPt<PrecBits>& v2)
- \relates QFixedPt
-
- Returns the result of dividing \a v1 by \a v2. Division by zero will
- result in zero.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> QFixedPt::operator-() const
-
- Returns the negation of this fixed-point number.
-*/
-
-/*!
- \fn QFixedPt<PrecBits> QFixedPt::sqrt() const
-
- Returns the square root of this fixed-point number.
-
- \sa sqrtF()
-*/
-
-/*!
- \fn qreal QFixedPt::sqrtF() const
-
- Return the square root of this fixed-point number as a
- floating-point value.
-
- \sa sqrt()
-*/
-
-/*!
- \fn QFixedPt<PrecBits> QFixedPt::round() const
-
- Returns this fixed-point number, rounded to the nearest integer.
-
- \sa floor(), ceil(), truncate()
-*/
-
-/*!
- \fn QFixedPt<PrecBits> QFixedPt::floor() const;
-
- Returns the largest integer that is less than or equal to
- this fixed-point number.
-
- \sa round(), ceil(), truncate()
-*/
-
-/*!
- \fn QFixedPt<PrecBits> QFixedPt::ceil() const
-
- Returns the smallest integer that is greater than or equal to
- this fixed-point number.
-
- \sa round(), floor(), truncate()
-*/
-
-/*!
- \fn int QFixedPt::truncate() const
-
- Returns this fixed-point number with the bits after the
- decimal point truncated.
-
- \sa round(), floor(), ceil()
-*/
-
-/*!
- \fn int QFixedPt::toInt() const
-
- Returns this fixed-point number, rounded to the nearest integer.
-
- \sa toReal()
-*/
-
-/*!
- \fn qreal QFixedPt::toReal() const
-
- Returns this fixed-point number as a floating-point value.
-
- \sa toInt()
-*/
-
-/*!
- \fn int qCeil(const QFixedPt<PrecBits>& value)
- \relates QFixedPt
-
- Returns the smallest integer that is greater than or equal to
- \a value.
-
- \sa qFloor(), qRound(), QFixedPt::ceil()
-*/
-
-/*!
- \fn int qFloor(const QFixedPt<PrecBits>& value)
- \relates QFixedPt
-
- Returns the largest integer that is less than or equal to
- \a value.
-
- \sa qCeil(), qRound(), QFixedPt::floor()
-*/
-
-/*!
- \fn int qRound(const QFixedPt<PrecBits>& value)
- \relates QFixedPt
-
- Returns \a value, rounded to the nearest integer.
-
- \sa qCeil(), qFloor(), QFixedPt::round()
-*/
-
-/*!
- \fn bool qFuzzyCompare(const QFixedPt<PrecBits>& v1, const QFixedPt<PrecBits>& v2, int compareBits)
- \relates QFixedPt
-
- Returns true if \a v1 is almost equal to \a v2; false otherwise.
- The \a compareBits parameter specifies the number of bits of precision
- that should be considered relevant when performing the comparison.
- By default, \a compareBits is PrecBits / 4.
-*/
-
-/*!
- \fn bool qIsNull(const QFixedPt<PrecBits>& v)
- \relates QFixedPt
-
- Returns true if \a v is zero; false otherwise.
-*/
-
-QT_END_NAMESPACE
diff --git a/src/gui/math3d/qfixedpt.h b/src/gui/math3d/qfixedpt.h
deleted file mode 100644
index 142f62f..0000000
--- a/src/gui/math3d/qfixedpt.h
+++ /dev/null
@@ -1,551 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (qt-info@nokia.com)
-**
-** This file is part of the $MODULE$ of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at qt-sales@nokia.com.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QFIXEDPT_H
-#define QFIXEDPT_H
-
-#include <QtCore/qglobal.h>
-#include <QtCore/qdebug.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-Q_GUI_EXPORT qint64 qt_math3d_fixed_sqrt(qint64 value);
-
-// Should be called QFixed or QFixedPoint, but both of those
-// are already in use in src/gui/painting/qfixed_p.h.
-template <int PrecBits>
-class QFixedPt
-{
-public:
- inline QFixedPt() {} // Deliberately not initialized - don't change this.
- inline QFixedPt(int value) : val(value << PrecBits) {}
- inline QFixedPt(qreal value) : val(int(value * (1 << PrecBits))) {}
-
- inline QFixedPt<PrecBits>& operator=(int value)
- { val = value << PrecBits; return *this; }
- inline QFixedPt<PrecBits>& operator=(qreal value)
- { val = int(value * (1 << PrecBits)); return *this; }
-
- inline int bits() const { return val; }
- inline void setBits(int value) { val = value; }
-
-#if !defined(QT_NO_MEMBER_TEMPLATES) || defined(Q_QDOC)
- template <int Prec>
- inline QFixedPt<Prec> toPrecision() const
- {
- QFixedPt<Prec> result;
- if (Prec < PrecBits)
- result.setBits(shiftRight(val, (PrecBits - Prec)));
- else
- result.setBits(shiftLeft(val, (Prec - PrecBits)));
- return result;
- }
-#endif
-
- inline QFixedPt<PrecBits>& operator+=(const QFixedPt<PrecBits>& value)
- { val += value.val; return *this; }
- inline QFixedPt<PrecBits>& operator+=(int value)
- { val += (value << PrecBits); return *this; }
- inline QFixedPt<PrecBits>& operator+=(qreal value)
- { val += int(value * (1 << PrecBits)); return *this; }
-
- inline QFixedPt<PrecBits>& operator-=(const QFixedPt<PrecBits>& value)
- { val -= value.val; return *this; }
- inline QFixedPt<PrecBits>& operator-=(int value)
- { val -= (value << PrecBits); return *this; }
- inline QFixedPt<PrecBits>& operator-=(qreal value)
- { val -= int(value * (1 << PrecBits)); return *this; }
-
- inline QFixedPt<PrecBits>& operator*=(const QFixedPt<PrecBits>& value)
- { val = mul(val, value.val); return *this; }
- inline QFixedPt<PrecBits>& operator*=(int value)
- { val = mul(val, (value << PrecBits)); return *this; }
- inline QFixedPt<PrecBits>& operator*=(qreal value)
- { val = mul(val, int(value * (1 << PrecBits))); return *this; }
-
- inline QFixedPt<PrecBits>& operator/=(const QFixedPt<PrecBits>& value)
- { val = div(val, value.val); return *this; }
- inline QFixedPt<PrecBits>& operator/=(int value)
- { val = div(val, (value << PrecBits)); return *this; }
- inline QFixedPt<PrecBits>& operator/=(qreal value)
- { val = div(val, int(value * (1 << PrecBits))); return *this; }
-
- inline QFixedPt<PrecBits>& operator<<=(int value)
- { val <<= value; return *this; }
- inline QFixedPt<PrecBits>& operator>>=(int value)
- { val >>= value; return *this; }
-
- inline QFixedPt<PrecBits> operator<<(int value) const
- { QFixedPt<PrecBits> result; result.val = val << value; return result; }
- inline QFixedPt<PrecBits> operator>>(int value) const
- { QFixedPt<PrecBits> result; result.val = val >> value; return result; }
-
- inline bool operator==(const QFixedPt<PrecBits>& value) const
- { return val == value.val; }
- inline bool operator!=(const QFixedPt<PrecBits>& value) const
- { return val != value.val; }
- inline bool operator<=(const QFixedPt<PrecBits>& value) const
- { return val <= value.val; }
- inline bool operator<(const QFixedPt<PrecBits>& value) const
- { return val < value.val; }
- inline bool operator>=(const QFixedPt<PrecBits>& value) const
- { return val >= value.val; }
- inline bool operator>(const QFixedPt<PrecBits>& value) const
- { return val > value.val; }
-
- inline QFixedPt<PrecBits> operator+(const QFixedPt<PrecBits>& value) const
- { QFixedPt<PrecBits> result;
- result.val = val + value.val; return result; }
- inline QFixedPt<PrecBits> operator+(int value) const
- { QFixedPt<PrecBits> result;
- result.val = val + (value << PrecBits); return result; }
- inline QFixedPt<PrecBits> operator+(qreal value) const
- { QFixedPt<PrecBits> result;
- result.val = val + int(value * (1 << PrecBits)); return result; }
-
- inline QFixedPt<PrecBits> operator-(const QFixedPt<PrecBits>& value) const
- { QFixedPt<PrecBits> result;
- result.val = val - value.val; return result; }
- inline QFixedPt<PrecBits> operator-(int value) const
- { QFixedPt<PrecBits> result;
- result.val = val - (value << PrecBits); return result; }
- inline QFixedPt<PrecBits> operator-(qreal value) const
- { QFixedPt<PrecBits> result;
- result.val = val - int(value * (1 << PrecBits)); return result; }
-
- inline QFixedPt<PrecBits> operator*(const QFixedPt<PrecBits>& value) const
- { QFixedPt<PrecBits> result;
- result.val = mul(val, value.val); return result; }
- inline QFixedPt<PrecBits> operator*(int value) const
- { QFixedPt<PrecBits> result;
- result.val = mul(val, (value << PrecBits)); return result; }
- inline QFixedPt<PrecBits> operator*(qreal value) const
- { QFixedPt<PrecBits> result;
- result.val = mul(val, int(value * (1 << PrecBits))); return result; }
-
- inline QFixedPt<PrecBits> operator/(const QFixedPt<PrecBits>& value) const
- { QFixedPt<PrecBits> result;
- result.val = div(val, value.val); return result; }
- inline QFixedPt<PrecBits> operator/(int value) const
- { QFixedPt<PrecBits> result;
- result.val = div(val, (value << PrecBits)); return result; }
- inline QFixedPt<PrecBits> operator/(qreal value) const
- { QFixedPt<PrecBits> result;
- result.val = div(val, int(value * (1 << PrecBits))); return result; }
-
- inline QFixedPt<PrecBits> operator-() const
- { QFixedPt<PrecBits> result; result.val = -val; return result; }
-
- inline QFixedPt<PrecBits> sqrt() const;
- inline qreal sqrtF() const;
- inline QFixedPt<PrecBits> round() const;
- inline QFixedPt<PrecBits> floor() const;
- inline QFixedPt<PrecBits> ceil() const;
- inline int truncate() const { return val >> PrecBits; }
-
- inline int toInt() const { return (val + (1 << (PrecBits - 1))) >> PrecBits; }
- inline qreal toReal() const { return qreal(val) / qreal(1 << PrecBits); }
-
-#if !defined(Q_NO_TEMPLATE_FRIENDS)
- template <int Prec>
- friend QFixedPt<Prec> operator/(int v1, const QFixedPt<Prec>& v2);
- template <int Prec>
- friend QFixedPt<Prec> operator/(qreal v1, const QFixedPt<Prec>& v2);
-
-private:
-#endif
- int val;
-
- inline static int mul(int v1, int v2)
- {
- return int((qint64(v1) * qint64(v2)) >> PrecBits);
- }
-
- inline static int div(int v1, int v2)
- {
- if (v2)
- return int((qint64(v1) << PrecBits) / qint64(v2));
- else
- return 0;
- }
-
- // These are used by toPrecision() to avoid a silly gcc compiler warning
- // related to negative shift values that will never actually be used.
- inline static int shiftRight(int val, int shift)
- {
- return val >> shift;
- }
- inline static int shiftLeft(int val, int shift)
- {
- return val << shift;
- }
-
-#if !defined(Q_NO_TEMPLATE_FRIENDS)
- template <int Prec, int Prec2>
- friend QFixedPt<Prec> qFixedPtToPrecision(const QFixedPt<Prec2>& value);
-#endif
-};
-
-template <int PrecBits>
-inline bool operator==(const QFixedPt<PrecBits>& v1, int v2)
-{
- return v1.bits() == (v2 << PrecBits);
-}
-
-template <int PrecBits>
-inline bool operator==(int v1, const QFixedPt<PrecBits>& v2)
-{
- return (v1 << PrecBits) == v2.bits();
-}
-
-template <int PrecBits>
-inline bool operator==(const QFixedPt<PrecBits>& v1, qreal v2)
-{
- return v1.bits() == int(v2 * (1 << PrecBits));
-}
-
-template <int PrecBits>
-inline bool operator==(qreal v1, const QFixedPt<PrecBits>& v2)
-{
- return int(v1 * (1 << PrecBits)) == v2.bits();
-}
-
-template <int PrecBits>
-inline bool operator!=(const QFixedPt<PrecBits>& v1, int v2)
-{
- return v1.bits() != (v2 << PrecBits);
-}
-
-template <int PrecBits>
-inline bool operator!=(int v1, const QFixedPt<PrecBits>& v2)
-{
- return (v1 << PrecBits) != v2.bits();
-}
-
-template <int PrecBits>
-inline bool operator!=(const QFixedPt<PrecBits>& v1, qreal v2)
-{
- return v1.bits() != int(v2 * (1 << PrecBits));
-}
-
-template <int PrecBits>
-inline bool operator!=(qreal v1, const QFixedPt<PrecBits>& v2)
-{
- return int(v1 * (1 << PrecBits)) != v2.bits();
-}
-
-template <int PrecBits>
-inline bool operator<=(const QFixedPt<PrecBits>& v1, int v2)
-{
- return v1.bits() <= (v2 << PrecBits);
-}
-
-template <int PrecBits>
-inline bool operator<=(int v1, const QFixedPt<PrecBits>& v2)
-{
- return (v1 << PrecBits) <= v2.bits();
-}
-
-template <int PrecBits>
-inline bool operator<=(const QFixedPt<PrecBits>& v1, qreal v2)
-{
- return v1.bits() <= int(v2 * (1 << PrecBits));
-}
-
-template <int PrecBits>
-inline bool operator<=(qreal v1, const QFixedPt<PrecBits>& v2)
-{
- return int(v1 * (1 << PrecBits)) <= v2.bits();
-}
-
-template <int PrecBits>
-inline bool operator<(const QFixedPt<PrecBits>& v1, int v2)
-{
- return v1.bits() < (v2 << PrecBits);
-}
-
-template <int PrecBits>
-inline bool operator<(int v1, const QFixedPt<PrecBits>& v2)
-{
- return (v1 << PrecBits) < v2.bits();
-}
-
-template <int PrecBits>
-inline bool operator<(const QFixedPt<PrecBits>& v1, qreal v2)
-{
- return v1.bits() < int(v2 * (1 << PrecBits));
-}
-
-template <int PrecBits>
-inline bool operator<(qreal v1, const QFixedPt<PrecBits>& v2)
-{
- return int(v1 * (1 << PrecBits)) < v2.bits();
-}
-
-template <int PrecBits>
-inline bool operator>=(const QFixedPt<PrecBits>& v1, int v2)
-{
- return v1.bits() >= (v2 << PrecBits);
-}
-
-template <int PrecBits>
-inline bool operator>=(int v1, const QFixedPt<PrecBits>& v2)
-{
- return (v1 << PrecBits) >= v2.bits();
-}
-
-template <int PrecBits>
-inline bool operator>=(const QFixedPt<PrecBits>& v1, qreal v2)
-{
- return v1.bits() >= int(v2 * (1 << PrecBits));
-}
-
-template <int PrecBits>
-inline bool operator>=(qreal v1, const QFixedPt<PrecBits>& v2)
-{
- return int(v1 * (1 << PrecBits)) >= v2.bits();
-}
-
-template <int PrecBits>
-inline bool operator>(const QFixedPt<PrecBits>& v1, int v2)
-{
- return v1.bits() > (v2 << PrecBits);
-}
-
-template <int PrecBits>
-inline bool operator>(int v1, const QFixedPt<PrecBits>& v2)
-{
- return (v1 << PrecBits) > v2.bits();
-}
-
-template <int PrecBits>
-inline bool operator>(const QFixedPt<PrecBits>& v1, qreal v2)
-{
- return v1.bits() > int(v2 * (1 << PrecBits));
-}
-
-template <int PrecBits>
-inline bool operator>(qreal v1, const QFixedPt<PrecBits>& v2)
-{
- return int(v1 * (1 << PrecBits)) > v2.bits();
-}
-
-template <int PrecBits>
-inline QFixedPt<PrecBits> operator+(int v1, const QFixedPt<PrecBits>& v2)
-{
- return v2 + v1;
-}
-
-template <int PrecBits>
-inline QFixedPt<PrecBits> operator+(qreal v1, const QFixedPt<PrecBits>& v2)
-{
- return v2 + v1;
-}
-
-template <int PrecBits>
-inline QFixedPt<PrecBits> operator-(int v1, const QFixedPt<PrecBits>& v2)
-{
- return -(v2 - v1);
-}
-
-template <int PrecBits>
-inline QFixedPt<PrecBits> operator-(qreal v1, const QFixedPt<PrecBits>& v2)
-{
- return -(v2 - v1);
-}
-
-template <int PrecBits>
-inline QFixedPt<PrecBits> operator*(int v1, const QFixedPt<PrecBits>& v2)
-{
- return v2 * v1;
-}
-
-template <int PrecBits>
-inline QFixedPt<PrecBits> operator*(qreal v1, const QFixedPt<PrecBits>& v2)
-{
- return v2 * v1;
-}
-
-template <int PrecBits>
-inline QFixedPt<PrecBits> operator/(int v1, const QFixedPt<PrecBits>& v2)
-{
- QFixedPt<PrecBits> result;
- result.val = QFixedPt<PrecBits>::div(v1 << PrecBits, v2.val);
- return result;
-}
-
-template <int PrecBits>
-inline QFixedPt<PrecBits> operator/(qreal v1, const QFixedPt<PrecBits>& v2)
-{
- QFixedPt<PrecBits> result;
- result.val = QFixedPt<PrecBits>::div(int(v1 * (1 << PrecBits)), v2.val);
- return result;
-}
-
-template <int PrecBits>
-inline QFixedPt<PrecBits> QFixedPt<PrecBits>::sqrt() const
-{
- QFixedPt<PrecBits> result;
- result.val = int(qt_math3d_fixed_sqrt
- (qint64(val) << (PrecBits * 2)) >> (PrecBits / 2));
- return result;
-}
-
-template <int PrecBits>
-inline qreal QFixedPt<PrecBits>::sqrtF() const
-{
- return qt_math3d_fixed_sqrt
- (qint64(val) << (PrecBits * 2)) / (qreal)(1 << (PrecBits + (PrecBits / 2)));
-}
-
-template <int PrecBits>
-inline QFixedPt<PrecBits> QFixedPt<PrecBits>::round() const
-{
- QFixedPt<PrecBits> result;
- result.val = (val + (1 << (PrecBits - 1))) & ~((1 << PrecBits) - 1);
- return result;
-}
-
-template <int PrecBits>
-inline QFixedPt<PrecBits> QFixedPt<PrecBits>::floor() const
-{
- QFixedPt<PrecBits> result;
- result.val = val & ~((1 << PrecBits) - 1);
- return result;
-}
-
-template <int PrecBits>
-inline QFixedPt<PrecBits> QFixedPt<PrecBits>::ceil() const
-{
- QFixedPt<PrecBits> result;
- result.val = (val + (1 << PrecBits) - 1) & ~((1 << PrecBits) - 1);
- return result;
-}
-
-template <int PrecBits>
-inline int qCeil(const QFixedPt<PrecBits>& value)
-{
- return value.ceil().bits() >> PrecBits;
-}
-
-template <int PrecBits>
-inline int qFloor(const QFixedPt<PrecBits>& value)
-{
- return value.floor().bits() >> PrecBits;
-}
-
-template <int PrecBits>
-inline int qRound(const QFixedPt<PrecBits>& value)
-{
- return value.round().bits() >> PrecBits;
-}
-
-template <int PrecBits>
-inline bool qFuzzyCompare(const QFixedPt<PrecBits>& v1, const QFixedPt<PrecBits>& v2, int compareBits = (PrecBits / 4))
-{
- return ((v1.bits() ^ v2.bits()) & ~((1 << compareBits) - 1)) == 0;
-}
-
-template <int PrecBits>
-inline bool qIsNull(const QFixedPt<PrecBits>& v)
-{
- return v.bits() == 0;
-}
-
-template <int Prec, int PrecBits>
-QFixedPt<Prec> qFixedPtToPrecision(const QFixedPt<PrecBits>& value)
-{
- QFixedPt<Prec> result;
- if (Prec < PrecBits)
- result.setBits(QFixedPt<PrecBits>::shiftRight(value.bits(), (PrecBits - Prec)));
- else
- result.setBits(QFixedPt<PrecBits>::shiftLeft(value.bits(), (Prec - PrecBits)));
- return result;
-}
-
-template <int PrecBits>
-inline QDebug &operator<<(QDebug &dbg, const QFixedPt<PrecBits> &f)
-{
- return dbg << f.toReal();
-}
-
-Q_DECLARE_TYPEINFO(QFixedPt<0>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<1>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<2>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<3>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<4>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<5>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<6>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<7>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<8>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<9>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<10>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<11>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<12>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<13>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<14>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<15>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<16>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<17>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<18>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<19>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<20>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<21>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<22>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<23>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<24>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<25>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<26>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<27>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<28>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<29>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<30>, Q_PRIMITIVE_TYPE);
-Q_DECLARE_TYPEINFO(QFixedPt<31>, Q_PRIMITIVE_TYPE);
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/gui/math3d/qgenericmatrix.h b/src/gui/math3d/qgenericmatrix.h
index dbeaaf3..d0b22de 100644
--- a/src/gui/math3d/qgenericmatrix.h
+++ b/src/gui/math3d/qgenericmatrix.h
@@ -42,8 +42,8 @@
#ifndef QGENERICMATRIX_H
#define QGENERICMATRIX_H
-#include <QtGui/qmath3dglobal.h>
#include <QtCore/qmetatype.h>
+#include <QtCore/qdebug.h>
QT_BEGIN_HEADER
@@ -134,7 +134,7 @@ template <int N, int M, typename T, typename InnerT>
Q_INLINE_TEMPLATE T QGenericMatrix<N, M, T, InnerT>::operator()(int row, int column) const
{
Q_ASSERT(row >= 0 && row < M && column >= 0 && column < N);
- return qt_math3d_convert<T, InnerT>(m[column][row]);
+ return T(m[column][row]);
}
template <int N, int M, typename T, typename InnerT>
@@ -323,18 +323,18 @@ Q_OUTOFLINE_TEMPLATE void QGenericMatrix<N, M, T, InnerT>::toValueArray(T *value
{
for (int col = 0; col < N; ++col)
for (int row = 0; row < M; ++row)
- values[row * N + col] = qt_math3d_convert<T, InnerT>(m[col][row]);
+ values[row * N + col] = T(m[col][row]);
}
// Define aliases for the useful variants of QGenericMatrix.
-typedef QGenericMatrix<2, 2, qreal, qrealinner> QMatrix2x2;
-typedef QGenericMatrix<2, 3, qreal, qrealinner> QMatrix2x3;
-typedef QGenericMatrix<2, 4, qreal, qrealinner> QMatrix2x4;
-typedef QGenericMatrix<3, 2, qreal, qrealinner> QMatrix3x2;
-typedef QGenericMatrix<3, 3, qreal, qrealinner> QMatrix3x3;
-typedef QGenericMatrix<3, 4, qreal, qrealinner> QMatrix3x4;
-typedef QGenericMatrix<4, 2, qreal, qrealinner> QMatrix4x2;
-typedef QGenericMatrix<4, 3, qreal, qrealinner> QMatrix4x3;
+typedef QGenericMatrix<2, 2, qreal, float> QMatrix2x2;
+typedef QGenericMatrix<2, 3, qreal, float> QMatrix2x3;
+typedef QGenericMatrix<2, 4, qreal, float> QMatrix2x4;
+typedef QGenericMatrix<3, 2, qreal, float> QMatrix3x2;
+typedef QGenericMatrix<3, 3, qreal, float> QMatrix3x3;
+typedef QGenericMatrix<3, 4, qreal, float> QMatrix3x4;
+typedef QGenericMatrix<4, 2, qreal, float> QMatrix4x2;
+typedef QGenericMatrix<4, 3, qreal, float> QMatrix4x3;
#ifndef QT_NO_DEBUG_STREAM
diff --git a/src/gui/math3d/qmath3dglobal.h b/src/gui/math3d/qmath3dglobal.h
deleted file mode 100644
index c2f7184..0000000
--- a/src/gui/math3d/qmath3dglobal.h
+++ /dev/null
@@ -1,102 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (qt-info@nokia.com)
-**
-** This file is part of the $MODULE$ of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at qt-sales@nokia.com.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMATH3DGLOBAL_H
-#define QMATH3DGLOBAL_H
-
-#include <QtCore/qglobal.h>
-#include <QtGui/qfixedpt.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-// Detect the presence of a fixed-point OpenGL implementation.
-#if defined(QT_OPENGL_ES_1_CL) || defined(QT_NO_GL_FLOAT)
-#ifndef QT_GL_FIXED_PREFERRED
-#define QT_GL_FIXED_PREFERRED 1
-#endif
-#endif
-
-// QT_GL_FIXED_PREFERRED indicates that fixed-point should be
-// preferred over floating-point for operations requiring high performance.
-//
-// qreal is the floating-point type that should be used in
-// user-visible functions. qrealinner is used internally where
-// values may be stored as either floating-point or fixed-point.
-// qrealinner will typically be the same size as GLfloat or GLfixed.
-#if defined(QT_GL_FIXED_PREFERRED)
-typedef QFixedPt<16> qrealinner;
-#else
-typedef float qrealinner;
-#endif
-
-// Explicit conversion operator, primarily for converting from
-// fixed point back to floating-point. This is safer than
-// declaring conversion operators in the QFixedPt class.
-template <typename T1, typename T2>
-T1 qt_math3d_convert(T2 v)
-{
- return T1(v);
-}
-template <>
-inline float qt_math3d_convert< float, QFixedPt<16> >(QFixedPt<16> v)
-{
- return float(v.toReal());
-}
-template <>
-inline double qt_math3d_convert< double, QFixedPt<16> >(QFixedPt<16> v)
-{
- return double(v.toReal());
-}
-template <>
-inline int qt_math3d_convert< int, QFixedPt<16> >(QFixedPt<16> v)
-{
- return v.toInt();
-}
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/gui/math3d/qmath3dutil.cpp b/src/gui/math3d/qmath3dutil.cpp
deleted file mode 100644
index ad84162..0000000
--- a/src/gui/math3d/qmath3dutil.cpp
+++ /dev/null
@@ -1,194 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (qt-info@nokia.com)
-**
-** This file is part of the $MODULE$ of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at qt-sales@nokia.com.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmath3dutil_p.h"
-
-QT_BEGIN_NAMESPACE
-
-#ifdef QT_GL_FIXED_PREFERRED
-
-// The table that follows was automatically generated by the following code:
-//
-//#include <math.h>
-//#include <stdio.h>
-//
-//int main()
-//{
-// double angle;
-// int count = 0;
-// for (angle = 0.0; angle < 360.0; angle += 1.0) {
-// if ((count % 4) == 0)
-// printf(" ");
-// printf(" qf2vt(%f)", sin(angle * M_PI / 180.0));
-// ++count;
-// if (count != 360)
-// printf(",");
-// if ((count % 4) == 0)
-// printf("\n");
-// }
-// return 0;
-//}
-
-#define qf2vt(x) (int((x) * 65536.0))
-
-static int const sinTable[360] = {
- qf2vt(0.000000), qf2vt(0.017452), qf2vt(0.034899), qf2vt(0.052336),
- qf2vt(0.069756), qf2vt(0.087156), qf2vt(0.104528), qf2vt(0.121869),
- qf2vt(0.139173), qf2vt(0.156434), qf2vt(0.173648), qf2vt(0.190809),
- qf2vt(0.207912), qf2vt(0.224951), qf2vt(0.241922), qf2vt(0.258819),
- qf2vt(0.275637), qf2vt(0.292372), qf2vt(0.309017), qf2vt(0.325568),
- qf2vt(0.342020), qf2vt(0.358368), qf2vt(0.374607), qf2vt(0.390731),
- qf2vt(0.406737), qf2vt(0.422618), qf2vt(0.438371), qf2vt(0.453990),
- qf2vt(0.469472), qf2vt(0.484810), qf2vt(0.500000), qf2vt(0.515038),
- qf2vt(0.529919), qf2vt(0.544639), qf2vt(0.559193), qf2vt(0.573576),
- qf2vt(0.587785), qf2vt(0.601815), qf2vt(0.615661), qf2vt(0.629320),
- qf2vt(0.642788), qf2vt(0.656059), qf2vt(0.669131), qf2vt(0.681998),
- qf2vt(0.694658), qf2vt(0.707107), qf2vt(0.719340), qf2vt(0.731354),
- qf2vt(0.743145), qf2vt(0.754710), qf2vt(0.766044), qf2vt(0.777146),
- qf2vt(0.788011), qf2vt(0.798636), qf2vt(0.809017), qf2vt(0.819152),
- qf2vt(0.829038), qf2vt(0.838671), qf2vt(0.848048), qf2vt(0.857167),
- qf2vt(0.866025), qf2vt(0.874620), qf2vt(0.882948), qf2vt(0.891007),
- qf2vt(0.898794), qf2vt(0.906308), qf2vt(0.913545), qf2vt(0.920505),
- qf2vt(0.927184), qf2vt(0.933580), qf2vt(0.939693), qf2vt(0.945519),
- qf2vt(0.951057), qf2vt(0.956305), qf2vt(0.961262), qf2vt(0.965926),
- qf2vt(0.970296), qf2vt(0.974370), qf2vt(0.978148), qf2vt(0.981627),
- qf2vt(0.984808), qf2vt(0.987688), qf2vt(0.990268), qf2vt(0.992546),
- qf2vt(0.994522), qf2vt(0.996195), qf2vt(0.997564), qf2vt(0.998630),
- qf2vt(0.999391), qf2vt(0.999848), qf2vt(1.000000), qf2vt(0.999848),
- qf2vt(0.999391), qf2vt(0.998630), qf2vt(0.997564), qf2vt(0.996195),
- qf2vt(0.994522), qf2vt(0.992546), qf2vt(0.990268), qf2vt(0.987688),
- qf2vt(0.984808), qf2vt(0.981627), qf2vt(0.978148), qf2vt(0.974370),
- qf2vt(0.970296), qf2vt(0.965926), qf2vt(0.961262), qf2vt(0.956305),
- qf2vt(0.951057), qf2vt(0.945519), qf2vt(0.939693), qf2vt(0.933580),
- qf2vt(0.927184), qf2vt(0.920505), qf2vt(0.913545), qf2vt(0.906308),
- qf2vt(0.898794), qf2vt(0.891007), qf2vt(0.882948), qf2vt(0.874620),
- qf2vt(0.866025), qf2vt(0.857167), qf2vt(0.848048), qf2vt(0.838671),
- qf2vt(0.829038), qf2vt(0.819152), qf2vt(0.809017), qf2vt(0.798636),
- qf2vt(0.788011), qf2vt(0.777146), qf2vt(0.766044), qf2vt(0.754710),
- qf2vt(0.743145), qf2vt(0.731354), qf2vt(0.719340), qf2vt(0.707107),
- qf2vt(0.694658), qf2vt(0.681998), qf2vt(0.669131), qf2vt(0.656059),
- qf2vt(0.642788), qf2vt(0.629320), qf2vt(0.615661), qf2vt(0.601815),
- qf2vt(0.587785), qf2vt(0.573576), qf2vt(0.559193), qf2vt(0.544639),
- qf2vt(0.529919), qf2vt(0.515038), qf2vt(0.500000), qf2vt(0.484810),
- qf2vt(0.469472), qf2vt(0.453990), qf2vt(0.438371), qf2vt(0.422618),
- qf2vt(0.406737), qf2vt(0.390731), qf2vt(0.374607), qf2vt(0.358368),
- qf2vt(0.342020), qf2vt(0.325568), qf2vt(0.309017), qf2vt(0.292372),
- qf2vt(0.275637), qf2vt(0.258819), qf2vt(0.241922), qf2vt(0.224951),
- qf2vt(0.207912), qf2vt(0.190809), qf2vt(0.173648), qf2vt(0.156434),
- qf2vt(0.139173), qf2vt(0.121869), qf2vt(0.104528), qf2vt(0.087156),
- qf2vt(0.069756), qf2vt(0.052336), qf2vt(0.034899), qf2vt(0.017452),
- qf2vt(0.000000), qf2vt(-0.017452), qf2vt(-0.034899), qf2vt(-0.052336),
- qf2vt(-0.069756), qf2vt(-0.087156), qf2vt(-0.104528), qf2vt(-0.121869),
- qf2vt(-0.139173), qf2vt(-0.156434), qf2vt(-0.173648), qf2vt(-0.190809),
- qf2vt(-0.207912), qf2vt(-0.224951), qf2vt(-0.241922), qf2vt(-0.258819),
- qf2vt(-0.275637), qf2vt(-0.292372), qf2vt(-0.309017), qf2vt(-0.325568),
- qf2vt(-0.342020), qf2vt(-0.358368), qf2vt(-0.374607), qf2vt(-0.390731),
- qf2vt(-0.406737), qf2vt(-0.422618), qf2vt(-0.438371), qf2vt(-0.453990),
- qf2vt(-0.469472), qf2vt(-0.484810), qf2vt(-0.500000), qf2vt(-0.515038),
- qf2vt(-0.529919), qf2vt(-0.544639), qf2vt(-0.559193), qf2vt(-0.573576),
- qf2vt(-0.587785), qf2vt(-0.601815), qf2vt(-0.615661), qf2vt(-0.629320),
- qf2vt(-0.642788), qf2vt(-0.656059), qf2vt(-0.669131), qf2vt(-0.681998),
- qf2vt(-0.694658), qf2vt(-0.707107), qf2vt(-0.719340), qf2vt(-0.731354),
- qf2vt(-0.743145), qf2vt(-0.754710), qf2vt(-0.766044), qf2vt(-0.777146),
- qf2vt(-0.788011), qf2vt(-0.798636), qf2vt(-0.809017), qf2vt(-0.819152),
- qf2vt(-0.829038), qf2vt(-0.838671), qf2vt(-0.848048), qf2vt(-0.857167),
- qf2vt(-0.866025), qf2vt(-0.874620), qf2vt(-0.882948), qf2vt(-0.891007),
- qf2vt(-0.898794), qf2vt(-0.906308), qf2vt(-0.913545), qf2vt(-0.920505),
- qf2vt(-0.927184), qf2vt(-0.933580), qf2vt(-0.939693), qf2vt(-0.945519),
- qf2vt(-0.951057), qf2vt(-0.956305), qf2vt(-0.961262), qf2vt(-0.965926),
- qf2vt(-0.970296), qf2vt(-0.974370), qf2vt(-0.978148), qf2vt(-0.981627),
- qf2vt(-0.984808), qf2vt(-0.987688), qf2vt(-0.990268), qf2vt(-0.992546),
- qf2vt(-0.994522), qf2vt(-0.996195), qf2vt(-0.997564), qf2vt(-0.998630),
- qf2vt(-0.999391), qf2vt(-0.999848), qf2vt(-1.000000), qf2vt(-0.999848),
- qf2vt(-0.999391), qf2vt(-0.998630), qf2vt(-0.997564), qf2vt(-0.996195),
- qf2vt(-0.994522), qf2vt(-0.992546), qf2vt(-0.990268), qf2vt(-0.987688),
- qf2vt(-0.984808), qf2vt(-0.981627), qf2vt(-0.978148), qf2vt(-0.974370),
- qf2vt(-0.970296), qf2vt(-0.965926), qf2vt(-0.961262), qf2vt(-0.956305),
- qf2vt(-0.951057), qf2vt(-0.945519), qf2vt(-0.939693), qf2vt(-0.933580),
- qf2vt(-0.927184), qf2vt(-0.920505), qf2vt(-0.913545), qf2vt(-0.906308),
- qf2vt(-0.898794), qf2vt(-0.891007), qf2vt(-0.882948), qf2vt(-0.874620),
- qf2vt(-0.866025), qf2vt(-0.857167), qf2vt(-0.848048), qf2vt(-0.838671),
- qf2vt(-0.829038), qf2vt(-0.819152), qf2vt(-0.809017), qf2vt(-0.798636),
- qf2vt(-0.788011), qf2vt(-0.777146), qf2vt(-0.766044), qf2vt(-0.754710),
- qf2vt(-0.743145), qf2vt(-0.731354), qf2vt(-0.719340), qf2vt(-0.707107),
- qf2vt(-0.694658), qf2vt(-0.681998), qf2vt(-0.669131), qf2vt(-0.656059),
- qf2vt(-0.642788), qf2vt(-0.629320), qf2vt(-0.615661), qf2vt(-0.601815),
- qf2vt(-0.587785), qf2vt(-0.573576), qf2vt(-0.559193), qf2vt(-0.544639),
- qf2vt(-0.529919), qf2vt(-0.515038), qf2vt(-0.500000), qf2vt(-0.484810),
- qf2vt(-0.469472), qf2vt(-0.453990), qf2vt(-0.438371), qf2vt(-0.422618),
- qf2vt(-0.406737), qf2vt(-0.390731), qf2vt(-0.374607), qf2vt(-0.358368),
- qf2vt(-0.342020), qf2vt(-0.325568), qf2vt(-0.309017), qf2vt(-0.292372),
- qf2vt(-0.275637), qf2vt(-0.258819), qf2vt(-0.241922), qf2vt(-0.224951),
- qf2vt(-0.207912), qf2vt(-0.190809), qf2vt(-0.173648), qf2vt(-0.156434),
- qf2vt(-0.139173), qf2vt(-0.121869), qf2vt(-0.104528), qf2vt(-0.087156),
- qf2vt(-0.069756), qf2vt(-0.052336), qf2vt(-0.034899), qf2vt(-0.017452)
-};
-
-void qt_math3d_sincos(qreal angle, qrealinner *s, qrealinner *c)
-{
- if (angle == qFloor(angle)) {
- // The angle is an integer number of degrees, so look up the results.
- int a = (int)angle;
- if (a >= 0)
- a = (a % 360);
- else
- a = 360 - (-a % 360);
- s->setBits(sinTable[a]);
- c->setBits(sinTable[(a + 90) % 360]);
- } else {
- qreal a = angle * M_PI / 180.0f;
- *s = qSin(a);
- *c = qCos(a);
- }
-}
-
-#else
-
-void qt_math3d_sincos(qreal angle, qrealinner *s, qrealinner *c)
-{
- qreal a = angle * M_PI / 180.0f;
- *s = qSin(a);
- *c = qCos(a);
-}
-
-#endif
-
-QT_END_NAMESPACE
diff --git a/src/gui/math3d/qmath3dutil_p.h b/src/gui/math3d/qmath3dutil_p.h
deleted file mode 100644
index fa4c156..0000000
--- a/src/gui/math3d/qmath3dutil_p.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (qt-info@nokia.com)
-**
-** This file is part of the $MODULE$ of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at qt-sales@nokia.com.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMATH3DUTIL_P_H
-#define QMATH3DUTIL_P_H
-
-#include <QtGui/qmath3dglobal.h>
-#include <QtCore/qmath.h>
-
-QT_BEGIN_NAMESPACE
-
-#ifdef QT_GL_FIXED_PREFERRED
-#define qvtsqrt(x) ((x).sqrtF())
-#else
-#define qvtsqrt(x) qSqrt((x))
-#endif
-
-#ifndef M_PI
-#define M_PI 3.14159265358979323846
-#endif
-
-void qt_math3d_sincos(qreal degrees, qrealinner *s, qrealinner *c);
-
-#ifdef QT_GL_FIXED_PREFERRED
-
-inline qrealinner qf2vt_round(qreal x)
-{
- QFixedPt<16> result;
- if (x >= 0.0f)
- result.setBits(int(x * 65536.0f + 0.5f));
- else
- result.setBits(int(x * 65536.0f - 0.5f));
- return result;
-}
-
-// Helper macros for computing dot products without losing precision.
-// In fixed-point mode, a 64-bit intermediate result is used.
-#define qvtmul64(x,y) ((qint64((x).bits())) * (qint64((y).bits())))
-#define qvtsqrt64(x) \
- (qt_math3d_fixed_sqrt((x) << 16) / (qreal)(1 << 24))
-#define qvtdot64(x) ((x) / (qreal)(((qint64)1) << 32))
-
-#else
-
-inline qrealinner qf2vt_round(qreal x)
-{
- return x;
-}
-
-#define qvtmul64(x,y) ((x) * (y))
-#define qvtsqrt64(x) (qvtsqrt((x)))
-#define qvtdot64(x) ((x))
-
-#endif
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/gui/math3d/qmatrix4x4.cpp b/src/gui/math3d/qmatrix4x4.cpp
index bcb3066..649532d 100644
--- a/src/gui/math3d/qmatrix4x4.cpp
+++ b/src/gui/math3d/qmatrix4x4.cpp
@@ -40,7 +40,6 @@
****************************************************************************/
#include "qmatrix4x4.h"
-#include "qmath3dutil_p.h"
#include <QtCore/qmath.h>
#include <QtGui/qmatrix.h>
#include <QtGui/qtransform.h>
@@ -106,7 +105,7 @@ QMatrix4x4::QMatrix4x4(const qreal *values)
#if !defined(QT_NO_MEMBER_TEMPLATES) || defined(Q_QDOC)
/*!
- \fn QMatrix4x4::QMatrix4x4(const QGenericMatrix<N, M, qreal, qrealinner>& matrix)
+ \fn QMatrix4x4::QMatrix4x4(const QGenericMatrix<N, M, qreal, float>& matrix)
Constructs a 4x4 matrix from the left-most 4 columns and top-most
4 rows of \a matrix. If \a matrix has less than 4 columns or rows,
@@ -117,7 +116,7 @@ QMatrix4x4::QMatrix4x4(const qreal *values)
*/
/*!
- \fn QGenericMatrix<N, M, qreal, qrealinner> QMatrix4x4::toGenericMatrix() const
+ \fn QGenericMatrix<N, M, qreal, float> QMatrix4x4::toGenericMatrix() const
Constructs a NxM generic matrix from the left-most N columns and
top-most M rows of this 4x4 matrix. If N or M is greater than 4,
@@ -130,7 +129,7 @@ QMatrix4x4::QMatrix4x4(const qreal *values)
#endif
/*!
- \fn QMatrix4x4 qGenericMatrixToMatrix4x4(const QGenericMatrix<N, M, qreal, qrealinner>& matrix)
+ \fn QMatrix4x4 qGenericMatrixToMatrix4x4(const QGenericMatrix<N, M, qreal, float>& matrix)
\relates QMatrix4x4
Returns a 4x4 matrix constructed from the left-most 4 columns and
@@ -142,7 +141,7 @@ QMatrix4x4::QMatrix4x4(const qreal *values)
*/
/*!
- \fn QGenericMatrix<N, M, qreal, qrealinner> qGenericMatrixFromMatrix4x4(const QMatrix4x4& matrix)
+ \fn QGenericMatrix<N, M, qreal, float> qGenericMatrixFromMatrix4x4(const QMatrix4x4& matrix)
\relates QMatrix4x4
Returns a NxM generic matrix constructed from the left-most N columns
@@ -156,7 +155,7 @@ QMatrix4x4::QMatrix4x4(const qreal *values)
/*!
\internal
*/
-QMatrix4x4::QMatrix4x4(const qrealinner *values, int cols, int rows)
+QMatrix4x4::QMatrix4x4(const float *values, int cols, int rows)
{
for (int col = 0; col < 4; ++col) {
for (int row = 0; row < 4; ++row) {
@@ -244,7 +243,7 @@ QMatrix4x4::QMatrix4x4(const QTransform& transform)
*/
/*!
- \fn qrealinner& QMatrix4x4::operator()(int row, int column)
+ \fn float& QMatrix4x4::operator()(int row, int column)
Returns a reference to the element at position (\a row, \a column)
in this matrix so that the element can be assigned to.
@@ -316,8 +315,8 @@ QMatrix4x4::QMatrix4x4(const QTransform& transform)
// | A B C |
// M = | D E F | det(M) = A * (EI - HF) - B * (DI - GF) + C * (DH - GE)
// | G H I |
-static inline qrealinner matrixDet3
- (const qrealinner m[4][4], int col0, int col1, int col2,
+static inline float matrixDet3
+ (const float m[4][4], int col0, int col1, int col2,
int row0, int row1, int row2)
{
return m[col0][row0] *
@@ -332,9 +331,9 @@ static inline qrealinner matrixDet3
}
// Calculate the determinant of a 4x4 matrix.
-static inline qrealinner matrixDet4(const qrealinner m[4][4])
+static inline float matrixDet4(const float m[4][4])
{
- qrealinner det;
+ float det;
det = m[0][0] * matrixDet3(m, 1, 2, 3, 1, 2, 3);
det -= m[1][0] * matrixDet3(m, 0, 2, 3, 1, 2, 3);
det += m[2][0] * matrixDet3(m, 0, 1, 3, 1, 2, 3);
@@ -347,7 +346,7 @@ static inline qrealinner matrixDet4(const qrealinner m[4][4])
*/
qreal QMatrix4x4::determinant() const
{
- return qt_math3d_convert<qreal, qrealinner>(matrixDet4(m));
+ return qreal(matrixDet4(m));
}
/*!
@@ -386,13 +385,13 @@ QMatrix4x4 QMatrix4x4::inverted(bool *invertible) const
QMatrix4x4 inv(1); // The "1" says to not load the identity.
- qrealinner det = matrixDet4(m);
+ float det = matrixDet4(m);
if (det == 0.0f) {
if (invertible)
*invertible = false;
return QMatrix4x4();
}
- det = qrealinner(1.0f) / det;
+ det = 1.0f / det;
inv.m[0][0] = matrixDet3(m, 1, 2, 3, 1, 2, 3) * det;
inv.m[0][1] = -matrixDet3(m, 0, 2, 3, 1, 2, 3) * det;
@@ -434,18 +433,18 @@ QMatrix3x3 QMatrix4x4::normalMatrix() const
} else if (flagBits == Scale || flagBits == (Translation | Scale)) {
if (m[0][0] == 0.0f || m[1][1] == 0.0f || m[2][2] == 0.0f)
return inv;
- inv.data()[0] = qrealinner(1.0f) / m[0][0];
- inv.data()[4] = qrealinner(1.0f) / m[1][1];
- inv.data()[8] = qrealinner(1.0f) / m[2][2];
+ inv.data()[0] = 1.0f / m[0][0];
+ inv.data()[4] = 1.0f / m[1][1];
+ inv.data()[8] = 1.0f / m[2][2];
return inv;
}
- qrealinner det = matrixDet3(m, 0, 1, 2, 0, 1, 2);
+ float det = matrixDet3(m, 0, 1, 2, 0, 1, 2);
if (det == 0.0f)
return inv;
- det = qrealinner(1.0f) / det;
+ det = 1.0f / det;
- qrealinner *invm = inv.data();
+ float *invm = inv.data();
// Invert and transpose in a single step.
invm[0 + 0 * 3] = (m[1][1] * m[2][2] - m[2][1] * m[1][2]) * det;
@@ -507,23 +506,22 @@ QMatrix4x4 QMatrix4x4::transposed() const
*/
QMatrix4x4& QMatrix4x4::operator/=(qreal divisor)
{
- qrealinner d(divisor);
- m[0][0] /= d;
- m[0][1] /= d;
- m[0][2] /= d;
- m[0][3] /= d;
- m[1][0] /= d;
- m[1][1] /= d;
- m[1][2] /= d;
- m[1][3] /= d;
- m[2][0] /= d;
- m[2][1] /= d;
- m[2][2] /= d;
- m[2][3] /= d;
- m[3][0] /= d;
- m[3][1] /= d;
- m[3][2] /= d;
- m[3][3] /= d;
+ m[0][0] /= divisor;
+ m[0][1] /= divisor;
+ m[0][2] /= divisor;
+ m[0][3] /= divisor;
+ m[1][0] /= divisor;
+ m[1][1] /= divisor;
+ m[1][2] /= divisor;
+ m[1][3] /= divisor;
+ m[2][0] /= divisor;
+ m[2][1] /= divisor;
+ m[2][2] /= divisor;
+ m[2][3] /= divisor;
+ m[3][0] /= divisor;
+ m[3][1] /= divisor;
+ m[3][2] /= divisor;
+ m[3][3] /= divisor;
flagBits = General;
return *this;
}
@@ -665,23 +663,22 @@ QMatrix4x4& QMatrix4x4::operator/=(qreal divisor)
QMatrix4x4 operator/(const QMatrix4x4& matrix, qreal divisor)
{
QMatrix4x4 m(1); // The "1" says to not load the identity.
- qrealinner d(divisor);
- m.m[0][0] = matrix.m[0][0] / d;
- m.m[0][1] = matrix.m[0][1] / d;
- m.m[0][2] = matrix.m[0][2] / d;
- m.m[0][3] = matrix.m[0][3] / d;
- m.m[1][0] = matrix.m[1][0] / d;
- m.m[1][1] = matrix.m[1][1] / d;
- m.m[1][2] = matrix.m[1][2] / d;
- m.m[1][3] = matrix.m[1][3] / d;
- m.m[2][0] = matrix.m[2][0] / d;
- m.m[2][1] = matrix.m[2][1] / d;
- m.m[2][2] = matrix.m[2][2] / d;
- m.m[2][3] = matrix.m[2][3] / d;
- m.m[3][0] = matrix.m[3][0] / d;
- m.m[3][1] = matrix.m[3][1] / d;
- m.m[3][2] = matrix.m[3][2] / d;
- m.m[3][3] = matrix.m[3][3] / d;
+ m.m[0][0] = matrix.m[0][0] / divisor;
+ m.m[0][1] = matrix.m[0][1] / divisor;
+ m.m[0][2] = matrix.m[0][2] / divisor;
+ m.m[0][3] = matrix.m[0][3] / divisor;
+ m.m[1][0] = matrix.m[1][0] / divisor;
+ m.m[1][1] = matrix.m[1][1] / divisor;
+ m.m[1][2] = matrix.m[1][2] / divisor;
+ m.m[1][3] = matrix.m[1][3] / divisor;
+ m.m[2][0] = matrix.m[2][0] / divisor;
+ m.m[2][1] = matrix.m[2][1] / divisor;
+ m.m[2][2] = matrix.m[2][2] / divisor;
+ m.m[2][3] = matrix.m[2][3] / divisor;
+ m.m[3][0] = matrix.m[3][0] / divisor;
+ m.m[3][1] = matrix.m[3][1] / divisor;
+ m.m[3][2] = matrix.m[3][2] / divisor;
+ m.m[3][3] = matrix.m[3][3] / divisor;
return m;
}
@@ -703,9 +700,9 @@ QMatrix4x4 operator/(const QMatrix4x4& matrix, qreal divisor)
*/
QMatrix4x4& QMatrix4x4::scale(const QVector3D& vector)
{
- qrealinner vx = vector.xp;
- qrealinner vy = vector.yp;
- qrealinner vz = vector.zp;
+ float vx = vector.xp;
+ float vy = vector.yp;
+ float vz = vector.zp;
if (flagBits == Identity) {
m[0][0] = vx;
m[1][1] = vy;
@@ -749,9 +746,9 @@ QMatrix4x4& QMatrix4x4::scale(const QVector3D& vector)
*/
QMatrix4x4& QMatrix4x4::scale(qreal x, qreal y, qreal z)
{
- qrealinner vx(x);
- qrealinner vy(y);
- qrealinner vz(z);
+ float vx(x);
+ float vy(y);
+ float vz(z);
if (flagBits == Identity) {
m[0][0] = vx;
m[1][1] = vy;
@@ -794,34 +791,33 @@ QMatrix4x4& QMatrix4x4::scale(qreal x, qreal y, qreal z)
*/
QMatrix4x4& QMatrix4x4::scale(qreal factor)
{
- qrealinner f(factor);
if (flagBits == Identity) {
- m[0][0] = f;
- m[1][1] = f;
- m[2][2] = f;
+ m[0][0] = factor;
+ m[1][1] = factor;
+ m[2][2] = factor;
flagBits = Scale;
} else if (flagBits == Scale || flagBits == (Scale | Translation)) {
- m[0][0] *= f;
- m[1][1] *= f;
- m[2][2] *= f;
+ m[0][0] *= factor;
+ m[1][1] *= factor;
+ m[2][2] *= factor;
} else if (flagBits == Translation) {
- m[0][0] = f;
- m[1][1] = f;
- m[2][2] = f;
+ m[0][0] = factor;
+ m[1][1] = factor;
+ m[2][2] = factor;
flagBits |= Scale;
} else {
- m[0][0] *= f;
- m[0][1] *= f;
- m[0][2] *= f;
- m[0][3] *= f;
- m[1][0] *= f;
- m[1][1] *= f;
- m[1][2] *= f;
- m[1][3] *= f;
- m[2][0] *= f;
- m[2][1] *= f;
- m[2][2] *= f;
- m[2][3] *= f;
+ m[0][0] *= factor;
+ m[0][1] *= factor;
+ m[0][2] *= factor;
+ m[0][3] *= factor;
+ m[1][0] *= factor;
+ m[1][1] *= factor;
+ m[1][2] *= factor;
+ m[1][3] *= factor;
+ m[2][0] *= factor;
+ m[2][1] *= factor;
+ m[2][2] *= factor;
+ m[2][3] *= factor;
flagBits = General;
}
return *this;
@@ -836,9 +832,9 @@ QMatrix4x4& QMatrix4x4::scale(qreal factor)
*/
QMatrix4x4& QMatrix4x4::translate(const QVector3D& vector)
{
- qrealinner vx = vector.xp;
- qrealinner vy = vector.yp;
- qrealinner vz = vector.zp;
+ float vx = vector.xp;
+ float vy = vector.yp;
+ float vz = vector.zp;
if (flagBits == Identity) {
m[3][0] = vx;
m[3][1] = vy;
@@ -882,9 +878,9 @@ QMatrix4x4& QMatrix4x4::translate(const QVector3D& vector)
*/
QMatrix4x4& QMatrix4x4::translate(qreal x, qreal y, qreal z)
{
- qrealinner vx(x);
- qrealinner vy(y);
- qrealinner vz(z);
+ float vx(x);
+ float vy(y);
+ float vz(z);
if (flagBits == Identity) {
m[3][0] = vx;
m[3][1] = vy;
@@ -931,6 +927,10 @@ QMatrix4x4& QMatrix4x4::rotate(qreal angle, const QVector3D& vector)
#endif
+#ifndef M_PI
+#define M_PI 3.14159265358979323846
+#endif
+
/*!
\overload
@@ -942,8 +942,10 @@ QMatrix4x4& QMatrix4x4::rotate(qreal angle, const QVector3D& vector)
QMatrix4x4& QMatrix4x4::rotate(qreal angle, qreal x, qreal y, qreal z)
{
QMatrix4x4 m(1); // The "1" says to not load the identity.
- qrealinner c, s, ic;
- qt_math3d_sincos(angle, &s, &c);
+ qreal a = angle * M_PI / 180.0f;
+ qreal c = qCos(a);
+ qreal s = qSin(a);
+ qreal ic;
bool quick = false;
if (x == 0.0f) {
if (y == 0.0f) {
@@ -993,27 +995,25 @@ QMatrix4x4& QMatrix4x4::rotate(qreal angle, qreal x, qreal y, qreal z)
quick = true;
}
if (!quick) {
- qrealinner vx(x);
- qrealinner vy(y);
- qrealinner vz(z);
- qrealinner len(qvtsqrt(vx * vx + vy * vy + vz * vz));
- if (len != 0) {
- vx /= len;
- vy /= len;
- vz /= len;
+ qreal len = x * x + y * y + z * z;
+ if (!qFuzzyIsNull(len - 1.0f) && !qFuzzyIsNull(len)) {
+ len = qSqrt(len);
+ x /= len;
+ y /= len;
+ z /= len;
}
ic = 1.0f - c;
- m.m[0][0] = vx * vx * ic + c;
- m.m[1][0] = vx * vy * ic - vz * s;
- m.m[2][0] = vx * vz * ic + vy * s;
+ m.m[0][0] = x * x * ic + c;
+ m.m[1][0] = x * y * ic - z * s;
+ m.m[2][0] = x * z * ic + y * s;
m.m[3][0] = 0.0f;
- m.m[0][1] = vy * vx * ic + vz * s;
- m.m[1][1] = vy * vy * ic + c;
- m.m[2][1] = vy * vz * ic - vx * s;
+ m.m[0][1] = y * x * ic + z * s;
+ m.m[1][1] = y * y * ic + c;
+ m.m[2][1] = y * z * ic - x * s;
m.m[3][1] = 0.0f;
- m.m[0][2] = vx * vz * ic - vy * s;
- m.m[1][2] = vy * vz * ic + vx * s;
- m.m[2][2] = vz * vz * ic + c;
+ m.m[0][2] = x * z * ic - y * s;
+ m.m[1][2] = y * z * ic + x * s;
+ m.m[2][2] = z * z * ic + c;
m.m[3][2] = 0.0f;
m.m[0][3] = 0.0f;
m.m[1][3] = 0.0f;
@@ -1043,15 +1043,15 @@ QMatrix4x4& QMatrix4x4::rotate(const QQuaternion& quaternion)
// Algorithm from:
// http://www.j3d.org/matrix_faq/matrfaq_latest.html#Q54
QMatrix4x4 m(1);
- qrealinner xx = quaternion.xp * quaternion.xp;
- qrealinner xy = quaternion.xp * quaternion.yp;
- qrealinner xz = quaternion.xp * quaternion.zp;
- qrealinner xw = quaternion.xp * quaternion.wp;
- qrealinner yy = quaternion.yp * quaternion.yp;
- qrealinner yz = quaternion.yp * quaternion.zp;
- qrealinner yw = quaternion.yp * quaternion.wp;
- qrealinner zz = quaternion.zp * quaternion.zp;
- qrealinner zw = quaternion.zp * quaternion.wp;
+ float xx = quaternion.xp * quaternion.xp;
+ float xy = quaternion.xp * quaternion.yp;
+ float xz = quaternion.xp * quaternion.zp;
+ float xw = quaternion.xp * quaternion.wp;
+ float yy = quaternion.yp * quaternion.yp;
+ float yz = quaternion.yp * quaternion.zp;
+ float yw = quaternion.yp * quaternion.wp;
+ float zz = quaternion.zp * quaternion.zp;
+ float zw = quaternion.zp * quaternion.wp;
m.m[0][0] = 1.0f - 2 * (yy + zz);
m.m[1][0] = 2 * (xy - zw);
m.m[2][0] = 2 * (xz + yw);
@@ -1137,33 +1137,33 @@ QMatrix4x4& QMatrix4x4::ortho(qreal left, qreal right, qreal bottom, qreal top,
// which will be more efficient to modify with further
// transformations than producing a "General" matrix.
translate(QVector3D
- (qf2vt_round(-(left + right) / width),
- qf2vt_round(-(top + bottom) / invheight),
+ (-(left + right) / width,
+ -(top + bottom) / invheight,
0.0f, 1));
scale(QVector3D
- (qf2vt_round(2.0f / width),
- qf2vt_round(2.0f / invheight),
+ (2.0f / width,
+ 2.0f / invheight,
-1.0f, 1));
return *this;
}
#endif
QMatrix4x4 m(1);
- m.m[0][0] = qf2vt_round(2.0f / width);
- m.m[1][0] = qf2vt_round(0.0f);
- m.m[2][0] = qf2vt_round(0.0f);
- m.m[3][0] = qf2vt_round(-(left + right) / width);
- m.m[0][1] = qf2vt_round(0.0f);
- m.m[1][1] = qf2vt_round(2.0f / invheight);
- m.m[2][1] = qf2vt_round(0.0f);
- m.m[3][1] = qf2vt_round(-(top + bottom) / invheight);
- m.m[0][2] = qf2vt_round(0.0f);
- m.m[1][2] = qf2vt_round(0.0f);
- m.m[2][2] = qf2vt_round(-2.0f / clip);
- m.m[3][2] = qf2vt_round(-(nearPlane + farPlane) / clip);
- m.m[0][3] = qf2vt_round(0.0f);
- m.m[1][3] = qf2vt_round(0.0f);
- m.m[2][3] = qf2vt_round(0.0f);
- m.m[3][3] = qf2vt_round(1.0f);
+ m.m[0][0] = 2.0f / width;
+ m.m[1][0] = 0.0f;
+ m.m[2][0] = 0.0f;
+ m.m[3][0] = -(left + right) / width;
+ m.m[0][1] = 0.0f;
+ m.m[1][1] = 2.0f / invheight;
+ m.m[2][1] = 0.0f;
+ m.m[3][1] = -(top + bottom) / invheight;
+ m.m[0][2] = 0.0f;
+ m.m[1][2] = 0.0f;
+ m.m[2][2] = -2.0f / clip;
+ m.m[3][2] = -(nearPlane + farPlane) / clip;
+ m.m[0][3] = 0.0f;
+ m.m[1][3] = 0.0f;
+ m.m[2][3] = 0.0f;
+ m.m[3][3] = 1.0f;
// Apply the projection.
*this *= m;
@@ -1189,22 +1189,22 @@ QMatrix4x4& QMatrix4x4::frustum(qreal left, qreal right, qreal bottom, qreal top
qreal width = right - left;
qreal invheight = top - bottom;
qreal clip = farPlane - nearPlane;
- m.m[0][0] = qf2vt_round(2.0f * nearPlane / width);
- m.m[1][0] = qf2vt_round(0.0f);
- m.m[2][0] = qf2vt_round((left + right) / width);
- m.m[3][0] = qf2vt_round(0.0f);
- m.m[0][1] = qf2vt_round(0.0f);
- m.m[1][1] = qf2vt_round(2.0f * nearPlane / invheight);
- m.m[2][1] = qf2vt_round((top + bottom) / invheight);
- m.m[3][1] = qf2vt_round(0.0f);
- m.m[0][2] = qf2vt_round(0.0f);
- m.m[1][2] = qf2vt_round(0.0f);
- m.m[2][2] = qf2vt_round(-(nearPlane + farPlane) / clip);
- m.m[3][2] = qf2vt_round(-(2.0f * nearPlane * farPlane) / clip);
- m.m[0][3] = qf2vt_round(0.0f);
- m.m[1][3] = qf2vt_round(0.0f);
- m.m[2][3] = qf2vt_round(-1.0f);
- m.m[3][3] = qf2vt_round(0.0f);
+ m.m[0][0] = 2.0f * nearPlane / width;
+ m.m[1][0] = 0.0f;
+ m.m[2][0] = (left + right) / width;
+ m.m[3][0] = 0.0f;
+ m.m[0][1] = 0.0f;
+ m.m[1][1] = 2.0f * nearPlane / invheight;
+ m.m[2][1] = (top + bottom) / invheight;
+ m.m[3][1] = 0.0f;
+ m.m[0][2] = 0.0f;
+ m.m[1][2] = 0.0f;
+ m.m[2][2] = -(nearPlane + farPlane) / clip;
+ m.m[3][2] = -2.0f * nearPlane * farPlane / clip;
+ m.m[0][3] = 0.0f;
+ m.m[1][3] = 0.0f;
+ m.m[2][3] = -1.0f;
+ m.m[3][3] = 0.0f;
// Apply the projection.
*this *= m;
@@ -1234,22 +1234,22 @@ QMatrix4x4& QMatrix4x4::perspective(qreal angle, qreal aspect, qreal nearPlane,
return *this;
qreal cotan = qCos(radians) / sine;
qreal clip = farPlane - nearPlane;
- m.m[0][0] = qf2vt_round(cotan / aspect);
- m.m[1][0] = qf2vt_round(0.0f);
- m.m[2][0] = qf2vt_round(0.0f);
- m.m[3][0] = qf2vt_round(0.0f);
- m.m[0][1] = qf2vt_round(0.0f);
- m.m[1][1] = qf2vt_round(cotan);
- m.m[2][1] = qf2vt_round(0.0f);
- m.m[3][1] = qf2vt_round(0.0f);
- m.m[0][2] = qf2vt_round(0.0f);
- m.m[1][2] = qf2vt_round(0.0f);
- m.m[2][2] = qf2vt_round(-(nearPlane + farPlane) / clip);
- m.m[3][2] = qf2vt_round(-(2.0f * nearPlane * farPlane) / clip);
- m.m[0][3] = qf2vt_round(0.0f);
- m.m[1][3] = qf2vt_round(0.0f);
- m.m[2][3] = qf2vt_round(-1.0f);
- m.m[3][3] = qf2vt_round(0.0f);
+ m.m[0][0] = cotan / aspect;
+ m.m[1][0] = 0.0f;
+ m.m[2][0] = 0.0f;
+ m.m[3][0] = 0.0f;
+ m.m[0][1] = 0.0f;
+ m.m[1][1] = cotan;
+ m.m[2][1] = 0.0f;
+ m.m[3][1] = 0.0f;
+ m.m[0][2] = 0.0f;
+ m.m[1][2] = 0.0f;
+ m.m[2][2] = -(nearPlane + farPlane) / clip;
+ m.m[3][2] = -(2.0f * nearPlane * farPlane) / clip;
+ m.m[0][3] = 0.0f;
+ m.m[1][3] = 0.0f;
+ m.m[2][3] = -1.0f;
+ m.m[3][3] = 0.0f;
// Apply the projection.
*this *= m;
@@ -1339,7 +1339,7 @@ void QMatrix4x4::toValueArray(qreal *values) const
{
for (int row = 0; row < 4; ++row)
for (int col = 0; col < 4; ++col)
- values[row * 4 + col] = qt_math3d_convert<qreal, qrealinner>(m[col][row]);
+ values[row * 4 + col] = qreal(m[col][row]);
}
/*!
@@ -1351,12 +1351,9 @@ void QMatrix4x4::toValueArray(qreal *values) const
*/
QMatrix QMatrix4x4::toAffine() const
{
- return QMatrix(qt_math3d_convert<qreal, qrealinner>(m[0][0]),
- qt_math3d_convert<qreal, qrealinner>(m[0][1]),
- qt_math3d_convert<qreal, qrealinner>(m[1][0]),
- qt_math3d_convert<qreal, qrealinner>(m[1][1]),
- qt_math3d_convert<qreal, qrealinner>(m[3][0]),
- qt_math3d_convert<qreal, qrealinner>(m[3][1]));
+ return QMatrix(qreal(m[0][0]), qreal(m[0][1]),
+ qreal(m[1][0]), qreal(m[1][1]),
+ qreal(m[3][0]), qreal(m[3][1]));
}
/*!
@@ -1368,15 +1365,9 @@ QMatrix QMatrix4x4::toAffine() const
*/
QTransform QMatrix4x4::toTransform() const
{
- return QTransform(qt_math3d_convert<qreal, qrealinner>(m[0][0]),
- qt_math3d_convert<qreal, qrealinner>(m[0][1]),
- qt_math3d_convert<qreal, qrealinner>(m[0][3]),
- qt_math3d_convert<qreal, qrealinner>(m[1][0]),
- qt_math3d_convert<qreal, qrealinner>(m[1][1]),
- qt_math3d_convert<qreal, qrealinner>(m[1][3]),
- qt_math3d_convert<qreal, qrealinner>(m[3][0]),
- qt_math3d_convert<qreal, qrealinner>(m[3][1]),
- qt_math3d_convert<qreal, qrealinner>(m[3][3]));
+ return QTransform(qreal(m[0][0]), qreal(m[0][1]), qreal(m[0][3]),
+ qreal(m[1][0]), qreal(m[1][1]), qreal(m[1][3]),
+ qreal(m[3][0]), qreal(m[3][1]), qreal(m[3][3]));
}
/*!
@@ -1442,7 +1433,7 @@ QTransform QMatrix4x4::toTransform() const
*/
/*!
- \fn qrealinner *QMatrix4x4::data()
+ \fn float *QMatrix4x4::data()
Returns a pointer to the raw data of this matrix. This is indended
for use with raw GL functions.
@@ -1451,7 +1442,7 @@ QTransform QMatrix4x4::toTransform() const
*/
/*!
- \fn const qrealinner *QMatrix4x4::data() const
+ \fn const float *QMatrix4x4::data() const
Returns a constant pointer to the raw data of this matrix.
This is indended for use with raw GL functions.
@@ -1460,7 +1451,7 @@ QTransform QMatrix4x4::toTransform() const
*/
/*!
- \fn const qrealinner *QMatrix4x4::constData() const
+ \fn const float *QMatrix4x4::constData() const
Returns a constant pointer to the raw data of this matrix.
This is indended for use with raw GL functions.
@@ -1519,12 +1510,12 @@ void QMatrix4x4::extractAxisRotation(qreal &angle, QVector3D &axis) const
{
// Orientation is dependent on the upper 3x3 matrix; subtract the
// homogeneous scaling element from the trace of the 4x4 matrix
- qrealinner tr = m[0][0] + m[1][1] + m[2][2];
- qreal cosa = qt_math3d_convert<qreal, qrealinner>(0.5f * (tr - 1.0f));
+ float tr = m[0][0] + m[1][1] + m[2][2];
+ qreal cosa = qreal(0.5f * (tr - 1.0f));
angle = acos(cosa) * 180.0f / M_PI;
// Any axis will work if r is zero (means no rotation)
- if (qFuzzyCompare(angle, (qreal)0.0f)) {
+ if (qFuzzyIsNull(angle)) {
axis.setX(1.0f);
axis.setY(0.0f);
axis.setZ(0.0f);
@@ -1540,11 +1531,11 @@ void QMatrix4x4::extractAxisRotation(qreal &angle, QVector3D &axis) const
}
// rads == PI
- qrealinner tmp;
+ float tmp;
// r00 is maximum
if ((m[0][0] >= m[2][2]) && (m[0][0] >= m[1][1])) {
- axis.xp = 0.5f * qvtsqrt(m[0][0] - m[1][1] - m[2][2] + 1.0f);
+ axis.xp = 0.5f * qSqrt(m[0][0] - m[1][1] - m[2][2] + 1.0f);
tmp = 0.5f / axis.x();
axis.yp = m[1][0] * tmp;
axis.zp = m[2][0] * tmp;
@@ -1552,7 +1543,7 @@ void QMatrix4x4::extractAxisRotation(qreal &angle, QVector3D &axis) const
// r11 is maximum
if ((m[1][1] >= m[2][2]) && (m[1][1] >= m[0][0])) {
- axis.yp = 0.5f * qvtsqrt(m[1][1] - m[0][0] - m[2][2] + 1.0f);
+ axis.yp = 0.5f * qSqrt(m[1][1] - m[0][0] - m[2][2] + 1.0f);
tmp = 0.5f / axis.y();
axis.xp = tmp * m[1][0];
axis.zp = tmp * m[2][1];
@@ -1560,7 +1551,7 @@ void QMatrix4x4::extractAxisRotation(qreal &angle, QVector3D &axis) const
// r22 is maximum
if ((m[2][2] >= m[1][1]) && (m[2][2] >= m[0][0])) {
- axis.zp = 0.5f * qvtsqrt(m[2][2] - m[0][0] - m[1][1] + 1.0f);
+ axis.zp = 0.5f * qSqrt(m[2][2] - m[0][0] - m[1][1] + 1.0f);
tmp = 0.5f / axis.z();
axis.xp = m[2][0]*tmp;
axis.yp = m[2][1]*tmp;
diff --git a/src/gui/math3d/qmatrix4x4.h b/src/gui/math3d/qmatrix4x4.h
index 6428b20..2b485c1 100644
--- a/src/gui/math3d/qmatrix4x4.h
+++ b/src/gui/math3d/qmatrix4x4.h
@@ -70,14 +70,14 @@ public:
qreal m41, qreal m42, qreal m43, qreal m44);
#if !defined(QT_NO_MEMBER_TEMPLATES) || defined(Q_QDOC)
template <int N, int M>
- explicit QMatrix4x4(const QGenericMatrix<N, M, qreal, qrealinner>& matrix);
+ explicit QMatrix4x4(const QGenericMatrix<N, M, qreal, float>& matrix);
#endif
- QMatrix4x4(const qrealinner *values, int cols, int rows);
+ QMatrix4x4(const float *values, int cols, int rows);
QMatrix4x4(const QTransform& transform);
QMatrix4x4(const QMatrix& matrix);
inline qreal operator()(int row, int column) const;
- inline qrealinner& operator()(int row, int column);
+ inline float& operator()(int row, int column);
inline QVector4D column(int index) const;
inline void setColumn(int index, const QVector4D& value);
@@ -171,12 +171,12 @@ public:
#if !defined(QT_NO_MEMBER_TEMPLATES) || defined(Q_QDOC)
template <int N, int M>
- QGenericMatrix<N, M, qreal, qrealinner> toGenericMatrix() const;
+ QGenericMatrix<N, M, qreal, float> toGenericMatrix() const;
#endif
- inline qrealinner *data();
- inline const qrealinner *data() const { return m[0]; }
- inline const qrealinner *constData() const { return m[0]; }
+ inline float *data();
+ inline const float *data() const { return m[0]; }
+ inline const float *constData() const { return m[0]; }
void inferSpecialType();
@@ -185,7 +185,7 @@ public:
#endif
private:
- qrealinner m[4][4]; // Column-major order to match OpenGL.
+ float m[4][4]; // Column-major order to match OpenGL.
int flagBits; // Flag bits from the enum below.
enum {
@@ -219,9 +219,9 @@ inline QMatrix4x4::QMatrix4x4
template <int N, int M>
Q_INLINE_TEMPLATE QMatrix4x4::QMatrix4x4
- (const QGenericMatrix<N, M, qreal, qrealinner>& matrix)
+ (const QGenericMatrix<N, M, qreal, float>& matrix)
{
- const qrealinner *values = matrix.constData();
+ const float *values = matrix.constData();
for (int col = 0; col < 4; ++col) {
for (int row = 0; row < 4; ++row) {
if (col < N && row < M)
@@ -236,10 +236,10 @@ Q_INLINE_TEMPLATE QMatrix4x4::QMatrix4x4
}
template <int N, int M>
-QGenericMatrix<N, M, qreal, qrealinner> QMatrix4x4::toGenericMatrix() const
+QGenericMatrix<N, M, qreal, float> QMatrix4x4::toGenericMatrix() const
{
- QGenericMatrix<N, M, qreal, qrealinner> result;
- qrealinner *values = result.data();
+ QGenericMatrix<N, M, qreal, float> result;
+ float *values = result.data();
for (int col = 0; col < N; ++col) {
for (int row = 0; row < M; ++row) {
if (col < 4 && row < 4)
@@ -258,10 +258,10 @@ QGenericMatrix<N, M, qreal, qrealinner> QMatrix4x4::toGenericMatrix() const
inline qreal QMatrix4x4::operator()(int row, int column) const
{
Q_ASSERT(row >= 0 && row < 4 && column >= 0 && column < 4);
- return qt_math3d_convert<qreal, qrealinner>(m[column][row]);
+ return qreal(m[column][row]);
}
-inline qrealinner& QMatrix4x4::operator()(int row, int column)
+inline float& QMatrix4x4::operator()(int row, int column)
{
Q_ASSERT(row >= 0 && row < 4 && column >= 0 && column < 4);
flagBits = General;
@@ -420,23 +420,22 @@ inline QMatrix4x4& QMatrix4x4::operator*=(const QMatrix4x4& other)
inline QMatrix4x4& QMatrix4x4::operator*=(qreal factor)
{
- qrealinner f(factor);
- m[0][0] *= f;
- m[0][1] *= f;
- m[0][2] *= f;
- m[0][3] *= f;
- m[1][0] *= f;
- m[1][1] *= f;
- m[1][2] *= f;
- m[1][3] *= f;
- m[2][0] *= f;
- m[2][1] *= f;
- m[2][2] *= f;
- m[2][3] *= f;
- m[3][0] *= f;
- m[3][1] *= f;
- m[3][2] *= f;
- m[3][3] *= f;
+ m[0][0] *= factor;
+ m[0][1] *= factor;
+ m[0][2] *= factor;
+ m[0][3] *= factor;
+ m[1][0] *= factor;
+ m[1][1] *= factor;
+ m[1][2] *= factor;
+ m[1][3] *= factor;
+ m[2][0] *= factor;
+ m[2][1] *= factor;
+ m[2][2] *= factor;
+ m[2][3] *= factor;
+ m[3][0] *= factor;
+ m[3][1] *= factor;
+ m[3][2] *= factor;
+ m[3][3] *= factor;
flagBits = General;
return *this;
}
@@ -604,7 +603,7 @@ inline QMatrix4x4 operator*(const QMatrix4x4& m1, const QMatrix4x4& m2)
inline QVector3D operator*(const QVector3D& vector, const QMatrix4x4& matrix)
{
- qrealinner x, y, z, w;
+ float x, y, z, w;
x = vector.xp * matrix.m[0][0] +
vector.yp * matrix.m[0][1] +
vector.zp * matrix.m[0][2] +
@@ -629,7 +628,7 @@ inline QVector3D operator*(const QVector3D& vector, const QMatrix4x4& matrix)
inline QVector3D operator*(const QMatrix4x4& matrix, const QVector3D& vector)
{
- qrealinner x, y, z, w;
+ float x, y, z, w;
x = vector.xp * matrix.m[0][0] +
vector.yp * matrix.m[1][0] +
vector.zp * matrix.m[2][0] +
@@ -658,7 +657,7 @@ inline QVector3D operator*(const QMatrix4x4& matrix, const QVector3D& vector)
inline QVector4D operator*(const QVector4D& vector, const QMatrix4x4& matrix)
{
- qrealinner x, y, z, w;
+ float x, y, z, w;
x = vector.xp * matrix.m[0][0] +
vector.yp * matrix.m[0][1] +
vector.zp * matrix.m[0][2] +
@@ -680,7 +679,7 @@ inline QVector4D operator*(const QVector4D& vector, const QMatrix4x4& matrix)
inline QVector4D operator*(const QMatrix4x4& matrix, const QVector4D& vector)
{
- qrealinner x, y, z, w;
+ float x, y, z, w;
x = vector.xp * matrix.m[0][0] +
vector.yp * matrix.m[1][0] +
vector.zp * matrix.m[2][0] +
@@ -704,8 +703,8 @@ inline QVector4D operator*(const QMatrix4x4& matrix, const QVector4D& vector)
inline QPoint operator*(const QPoint& point, const QMatrix4x4& matrix)
{
- qrealinner xin, yin;
- qrealinner x, y, w;
+ float xin, yin;
+ float x, y, w;
xin = point.x();
yin = point.y();
x = xin * matrix.m[0][0] +
@@ -725,8 +724,8 @@ inline QPoint operator*(const QPoint& point, const QMatrix4x4& matrix)
inline QPointF operator*(const QPointF& point, const QMatrix4x4& matrix)
{
- qrealinner xin, yin;
- qrealinner x, y, w;
+ float xin, yin;
+ float x, y, w;
xin = point.x();
yin = point.y();
x = xin * matrix.m[0][0] +
@@ -739,18 +738,16 @@ inline QPointF operator*(const QPointF& point, const QMatrix4x4& matrix)
yin * matrix.m[3][1] +
matrix.m[3][3];
if (w == 1.0f) {
- return QPointF(qt_math3d_convert<qreal, qrealinner>(x),
- qt_math3d_convert<qreal, qrealinner>(y));
+ return QPointF(qreal(x), qreal(y));
} else {
- return QPointF(qt_math3d_convert<qreal, qrealinner>(x / w),
- qt_math3d_convert<qreal, qrealinner>(y / w));
+ return QPointF(qreal(x / w), qreal(y / w));
}
}
inline QPoint operator*(const QMatrix4x4& matrix, const QPoint& point)
{
- qrealinner xin, yin;
- qrealinner x, y, w;
+ float xin, yin;
+ float x, y, w;
xin = point.x();
yin = point.y();
x = xin * matrix.m[0][0] +
@@ -770,8 +767,8 @@ inline QPoint operator*(const QMatrix4x4& matrix, const QPoint& point)
inline QPointF operator*(const QMatrix4x4& matrix, const QPointF& point)
{
- qrealinner xin, yin;
- qrealinner x, y, w;
+ float xin, yin;
+ float x, y, w;
xin = point.x();
yin = point.y();
x = xin * matrix.m[0][0] +
@@ -784,11 +781,9 @@ inline QPointF operator*(const QMatrix4x4& matrix, const QPointF& point)
yin * matrix.m[1][3] +
matrix.m[3][3];
if (w == 1.0f) {
- return QPointF(qt_math3d_convert<qreal, qrealinner>(x),
- qt_math3d_convert<qreal, qrealinner>(y));
+ return QPointF(qreal(x), qreal(y));
} else {
- return QPointF(qt_math3d_convert<qreal, qrealinner>(x / w),
- qt_math3d_convert<qreal, qrealinner>(y / w));
+ return QPointF(qreal(x / w), qreal(y / w));
}
}
@@ -817,46 +812,44 @@ inline QMatrix4x4 operator-(const QMatrix4x4& matrix)
inline QMatrix4x4 operator*(qreal factor, const QMatrix4x4& matrix)
{
QMatrix4x4 m(1);
- qrealinner f(factor);
- m.m[0][0] = matrix.m[0][0] * f;
- m.m[0][1] = matrix.m[0][1] * f;
- m.m[0][2] = matrix.m[0][2] * f;
- m.m[0][3] = matrix.m[0][3] * f;
- m.m[1][0] = matrix.m[1][0] * f;
- m.m[1][1] = matrix.m[1][1] * f;
- m.m[1][2] = matrix.m[1][2] * f;
- m.m[1][3] = matrix.m[1][3] * f;
- m.m[2][0] = matrix.m[2][0] * f;
- m.m[2][1] = matrix.m[2][1] * f;
- m.m[2][2] = matrix.m[2][2] * f;
- m.m[2][3] = matrix.m[2][3] * f;
- m.m[3][0] = matrix.m[3][0] * f;
- m.m[3][1] = matrix.m[3][1] * f;
- m.m[3][2] = matrix.m[3][2] * f;
- m.m[3][3] = matrix.m[3][3] * f;
+ m.m[0][0] = matrix.m[0][0] * factor;
+ m.m[0][1] = matrix.m[0][1] * factor;
+ m.m[0][2] = matrix.m[0][2] * factor;
+ m.m[0][3] = matrix.m[0][3] * factor;
+ m.m[1][0] = matrix.m[1][0] * factor;
+ m.m[1][1] = matrix.m[1][1] * factor;
+ m.m[1][2] = matrix.m[1][2] * factor;
+ m.m[1][3] = matrix.m[1][3] * factor;
+ m.m[2][0] = matrix.m[2][0] * factor;
+ m.m[2][1] = matrix.m[2][1] * factor;
+ m.m[2][2] = matrix.m[2][2] * factor;
+ m.m[2][3] = matrix.m[2][3] * factor;
+ m.m[3][0] = matrix.m[3][0] * factor;
+ m.m[3][1] = matrix.m[3][1] * factor;
+ m.m[3][2] = matrix.m[3][2] * factor;
+ m.m[3][3] = matrix.m[3][3] * factor;
return m;
}
inline QMatrix4x4 operator*(const QMatrix4x4& matrix, qreal factor)
{
QMatrix4x4 m(1);
- qrealinner f(factor);
- m.m[0][0] = matrix.m[0][0] * f;
- m.m[0][1] = matrix.m[0][1] * f;
- m.m[0][2] = matrix.m[0][2] * f;
- m.m[0][3] = matrix.m[0][3] * f;
- m.m[1][0] = matrix.m[1][0] * f;
- m.m[1][1] = matrix.m[1][1] * f;
- m.m[1][2] = matrix.m[1][2] * f;
- m.m[1][3] = matrix.m[1][3] * f;
- m.m[2][0] = matrix.m[2][0] * f;
- m.m[2][1] = matrix.m[2][1] * f;
- m.m[2][2] = matrix.m[2][2] * f;
- m.m[2][3] = matrix.m[2][3] * f;
- m.m[3][0] = matrix.m[3][0] * f;
- m.m[3][1] = matrix.m[3][1] * f;
- m.m[3][2] = matrix.m[3][2] * f;
- m.m[3][3] = matrix.m[3][3] * f;
+ m.m[0][0] = matrix.m[0][0] * factor;
+ m.m[0][1] = matrix.m[0][1] * factor;
+ m.m[0][2] = matrix.m[0][2] * factor;
+ m.m[0][3] = matrix.m[0][3] * factor;
+ m.m[1][0] = matrix.m[1][0] * factor;
+ m.m[1][1] = matrix.m[1][1] * factor;
+ m.m[1][2] = matrix.m[1][2] * factor;
+ m.m[1][3] = matrix.m[1][3] * factor;
+ m.m[2][0] = matrix.m[2][0] * factor;
+ m.m[2][1] = matrix.m[2][1] * factor;
+ m.m[2][2] = matrix.m[2][2] * factor;
+ m.m[2][3] = matrix.m[2][3] * factor;
+ m.m[3][0] = matrix.m[3][0] * factor;
+ m.m[3][1] = matrix.m[3][1] * factor;
+ m.m[3][2] = matrix.m[3][2] * factor;
+ m.m[3][3] = matrix.m[3][3] * factor;
return m;
}
@@ -934,7 +927,7 @@ inline QRectF QMatrix4x4::mapRect(const QRectF& rect) const
return QRectF(QPointF(xmin, ymin), QPointF(xmax, ymax));
}
-inline qrealinner *QMatrix4x4::data()
+inline float *QMatrix4x4::data()
{
// We have to assume that the caller will modify the matrix elements,
// so we flip it over to "General" mode.
@@ -947,17 +940,17 @@ Q_GUI_EXPORT QDebug operator<<(QDebug dbg, const QMatrix4x4 &m);
#endif
template <int N, int M>
-QMatrix4x4 qGenericMatrixToMatrix4x4(const QGenericMatrix<N, M, qreal, qrealinner>& matrix)
+QMatrix4x4 qGenericMatrixToMatrix4x4(const QGenericMatrix<N, M, qreal, float>& matrix)
{
return QMatrix4x4(matrix.constData(), N, M);
}
template <int N, int M>
-QGenericMatrix<N, M, qreal, qrealinner> qGenericMatrixFromMatrix4x4(const QMatrix4x4& matrix)
+QGenericMatrix<N, M, qreal, float> qGenericMatrixFromMatrix4x4(const QMatrix4x4& matrix)
{
- QGenericMatrix<N, M, qreal, qrealinner> result;
- const qrealinner *m = matrix.constData();
- qrealinner *values = result.data();
+ QGenericMatrix<N, M, qreal, float> result;
+ const float *m = matrix.constData();
+ float *values = result.data();
for (int col = 0; col < N; ++col) {
for (int row = 0; row < M; ++row) {
if (col < 4 && row < 4)
diff --git a/src/gui/math3d/qquaternion.cpp b/src/gui/math3d/qquaternion.cpp
index 121ff51..96659ea 100644
--- a/src/gui/math3d/qquaternion.cpp
+++ b/src/gui/math3d/qquaternion.cpp
@@ -40,8 +40,8 @@
****************************************************************************/
#include "qquaternion.h"
-#include "qmath3dutil_p.h"
#include <QtCore/qmath.h>
+#include <QtCore/qdebug.h>
QT_BEGIN_NAMESPACE
@@ -74,13 +74,6 @@ QT_BEGIN_NAMESPACE
and \a scalar.
*/
-/*!
- \fn QQuaternion::QQuaternion(int scalar, int xpos, int ypos, int zpos)
-
- Constructs a quaternion with the vector (\a xpos, \a ypos, \a zpos)
- and \a scalar.
-*/
-
#ifndef QT_NO_VECTOR3D
/*!
@@ -223,8 +216,7 @@ QT_BEGIN_NAMESPACE
*/
qreal QQuaternion::length() const
{
- return qvtsqrt64(qvtmul64(xp, xp) + qvtmul64(yp, yp) +
- qvtmul64(zp, zp) + qvtmul64(wp, wp));
+ return qSqrt(xp * xp + yp * yp + zp * zp + wp * wp);
}
/*!
@@ -234,45 +226,50 @@ qreal QQuaternion::length() const
*/
qreal QQuaternion::lengthSquared() const
{
- return qvtdot64(qvtmul64(xp, xp) + qvtmul64(yp, yp) +
- qvtmul64(zp, zp) + qvtmul64(wp, wp));
+ return xp * xp + yp * yp + zp * zp + wp * wp;
}
/*!
- Returns the normalized unit form of this quaternion. If this quaternion
- is not null, the returned quaternion is guaranteed to be 1.0 in length.
+ Returns the normalized unit form of this quaternion.
+
If this quaternion is null, then a null quaternion is returned.
+ If the length of the quaternion is very close to 1, then the quaternion
+ will be returned as-is. Otherwise the normalized form of the
+ quaternion of length 1 will be returned.
\sa length(), normalize()
*/
QQuaternion QQuaternion::normalized() const
{
- qreal len = length();
- if (!qIsNull(len))
- return *this / len;
+ qreal len = lengthSquared();
+ if (qFuzzyIsNull(len - 1.0f))
+ return *this;
+ else if (!qFuzzyIsNull(len))
+ return *this / qSqrt(len);
else
return QQuaternion(0.0f, 0.0f, 0.0f, 0.0f);
}
/*!
Normalizes the currect quaternion in place. Nothing happens if this
- is a null quaternion.
+ is a null quaternion or the length of the quaternion is very close to 1.
\sa length(), normalized()
*/
void QQuaternion::normalize()
{
- qreal len = length();
- if (qIsNull(len))
+ qreal len = lengthSquared();
+ if (qFuzzyIsNull(len - 1.0f) || qFuzzyIsNull(len))
return;
+ len = qSqrt(len);
+
xp /= len;
yp /= len;
zp /= len;
wp /= len;
}
-
/*!
\fn QQuaternion QQuaternion::conjugate() const
@@ -342,6 +339,10 @@ QVector3D QQuaternion::rotateVector(const QVector3D& vector) const
\sa operator*=()
*/
+#ifndef M_PI
+#define M_PI 3.14159265358979323846
+#endif
+
#ifndef QT_NO_VECTOR3D
/*!
@@ -354,9 +355,10 @@ QQuaternion QQuaternion::fromAxisAndAngle(const QVector3D& axis, qreal angle)
// http://www.j3d.org/matrix_faq/matrfaq_latest.html#Q56
// We normalize the result just in case the values are close
// to zero, as suggested in the above FAQ.
- qrealinner s, c;
+ qreal a = (angle / 2.0f) * M_PI / 180.0f;
+ qreal s = qSin(a);
+ qreal c = qCos(a);
QVector3D ax = axis.normalized();
- qt_math3d_sincos(angle / 2.0f, &s, &c);
return QQuaternion(c, ax.xp * s, ax.yp * s, ax.zp * s, 1).normalized();
}
@@ -369,17 +371,18 @@ QQuaternion QQuaternion::fromAxisAndAngle(const QVector3D& axis, qreal angle)
QQuaternion QQuaternion::fromAxisAndAngle
(qreal x, qreal y, qreal z, qreal angle)
{
- qrealinner xp = x;
- qrealinner yp = y;
- qrealinner zp = z;
- qrealinner s, c;
- qreal length = qvtsqrt(xp * xp + yp * yp + zp * zp);
+ float xp = x;
+ float yp = y;
+ float zp = z;
+ qreal length = qSqrt(xp * xp + yp * yp + zp * zp);
if (!qIsNull(length)) {
xp /= length;
yp /= length;
zp /= length;
}
- qt_math3d_sincos(angle / 2.0f, &s, &c);
+ qreal a = (angle / 2.0f) * M_PI / 180.0f;
+ qreal s = qSin(a);
+ qreal c = qCos(a);
return QQuaternion(c, xp * s, yp * s, zp * s, 1).normalized();
}
@@ -487,8 +490,10 @@ QQuaternion QQuaternion::fromAxisAndAngle
If \a t is less than or equal to 0, then \a q1 will be returned.
If \a t is greater than or equal to 1, then \a q2 will be returned.
+
+ \sa nlerp()
*/
-QQuaternion QQuaternion::interpolate
+QQuaternion QQuaternion::slerp
(const QQuaternion& q1, const QQuaternion& q2, qreal t)
{
// Handle the easy cases first.
@@ -500,8 +505,7 @@ QQuaternion QQuaternion::interpolate
// Determine the angle between the two quaternions.
QQuaternion q2b;
qreal dot;
- dot = qvtdot64(qvtmul64(q1.xp, q2.xp) + qvtmul64(q1.yp, q2.yp) +
- qvtmul64(q1.zp, q2.zp) + qvtmul64(q1.wp, q2.wp));
+ dot = q1.xp * q2.xp + q1.yp * q2.yp + q1.zp * q2.zp + q1.wp * q2.wp;
if (dot >= 0.0f) {
q2b = q2;
} else {
@@ -526,6 +530,43 @@ QQuaternion QQuaternion::interpolate
return q1 * factor1 + q2b * factor2;
}
+/*!
+ Interpolates along the shortest linear path between the rotational
+ positions \a q1 and \a q2. The value \a t should be between 0 and 1,
+ indicating the distance to travel between \a q1 and \a q2.
+ The result will be normalized().
+
+ If \a t is less than or equal to 0, then \a q1 will be returned.
+ If \a t is greater than or equal to 1, then \a q2 will be returned.
+
+ The nlerp() function is typically faster than slerp() and will
+ give approximate results to spherical interpolation that are
+ good enough for some applications.
+
+ \sa slerp()
+*/
+QQuaternion QQuaternion::nlerp
+ (const QQuaternion& q1, const QQuaternion& q2, qreal t)
+{
+ // Handle the easy cases first.
+ if (t <= 0.0f)
+ return q1;
+ else if (t >= 1.0f)
+ return q2;
+
+ // Determine the angle between the two quaternions.
+ QQuaternion q2b;
+ qreal dot;
+ dot = q1.xp * q2.xp + q1.yp * q2.yp + q1.zp * q2.zp + q1.wp * q2.wp;
+ if (dot >= 0.0f)
+ q2b = q2;
+ else
+ q2b = -q2;
+
+ // Perform the linear interpolation.
+ return (q1 * (1.0f - t) + q2b * t).normalized();
+}
+
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug dbg, const QQuaternion &q)
diff --git a/src/gui/math3d/qquaternion.h b/src/gui/math3d/qquaternion.h
index 6ba63ec..c05c641 100644
--- a/src/gui/math3d/qquaternion.h
+++ b/src/gui/math3d/qquaternion.h
@@ -60,7 +60,6 @@ class Q_GUI_EXPORT QQuaternion
public:
QQuaternion();
QQuaternion(qreal scalar, qreal xpos, qreal ypos, qreal zpos);
- QQuaternion(int scalar, int xpos, int ypos, int zpos);
#ifndef QT_NO_VECTOR3D
QQuaternion(qreal scalar, const QVector3D& vector);
#endif
@@ -125,15 +124,17 @@ public:
static QQuaternion fromAxisAndAngle
(qreal x, qreal y, qreal z, qreal angle);
- static QQuaternion interpolate
+ static QQuaternion slerp
+ (const QQuaternion& q1, const QQuaternion& q2, qreal t);
+ static QQuaternion nlerp
(const QQuaternion& q1, const QQuaternion& q2, qreal t);
private:
- qrealinner wp, xp, yp, zp;
+ float wp, xp, yp, zp;
friend class QMatrix4x4;
- QQuaternion(qrealinner scalar, qrealinner xpos, qrealinner ypos, qrealinner zpos, int dummy);
+ QQuaternion(float scalar, float xpos, float ypos, float zpos, int dummy);
};
inline QQuaternion::QQuaternion() : wp(1.0f), xp(0.0f), yp(0.0f), zp(0.0f) {}
@@ -141,9 +142,7 @@ inline QQuaternion::QQuaternion() : wp(1.0f), xp(0.0f), yp(0.0f), zp(0.0f) {}
inline QQuaternion::QQuaternion(qreal scalar, qreal xpos, qreal ypos, qreal zpos) : wp(scalar), xp(xpos), yp(ypos), zp(zpos) {}
-inline QQuaternion::QQuaternion(qrealinner scalar, qrealinner xpos, qrealinner ypos, qrealinner zpos, int) : wp(scalar), xp(xpos), yp(ypos), zp(zpos) {}
-
-inline QQuaternion::QQuaternion(int scalar, int xpos, int ypos, int zpos) : wp(scalar), xp(xpos), yp(ypos), zp(zpos) {}
+inline QQuaternion::QQuaternion(float scalar, float xpos, float ypos, float zpos, int) : wp(scalar), xp(xpos), yp(ypos), zp(zpos) {}
inline bool QQuaternion::isNull() const
{
@@ -155,10 +154,10 @@ inline bool QQuaternion::isIdentity() const
return qIsNull(xp) && qIsNull(yp) && qIsNull(zp) && wp == 1.0f;
}
-inline qreal QQuaternion::x() const { return qt_math3d_convert<qreal, qrealinner>(xp); }
-inline qreal QQuaternion::y() const { return qt_math3d_convert<qreal, qrealinner>(yp); }
-inline qreal QQuaternion::z() const { return qt_math3d_convert<qreal, qrealinner>(zp); }
-inline qreal QQuaternion::scalar() const { return qt_math3d_convert<qreal, qrealinner>(wp); }
+inline qreal QQuaternion::x() const { return qreal(xp); }
+inline qreal QQuaternion::y() const { return qreal(yp); }
+inline qreal QQuaternion::z() const { return qreal(zp); }
+inline qreal QQuaternion::scalar() const { return qreal(wp); }
inline void QQuaternion::setX(qreal x) { xp = x; }
inline void QQuaternion::setY(qreal y) { yp = y; }
@@ -190,11 +189,10 @@ inline QQuaternion &QQuaternion::operator-=(const QQuaternion &quaternion)
inline QQuaternion &QQuaternion::operator*=(qreal factor)
{
- qrealinner f(factor);
- xp *= f;
- yp *= f;
- zp *= f;
- wp *= f;
+ xp *= factor;
+ yp *= factor;
+ zp *= factor;
+ wp *= factor;
return *this;
}
@@ -202,19 +200,19 @@ inline const QQuaternion operator*(const QQuaternion &q1, const QQuaternion& q2)
{
// Algorithm from:
// http://www.j3d.org/matrix_faq/matrfaq_latest.html#Q53
- qrealinner x = q1.wp * q2.xp +
+ float x = q1.wp * q2.xp +
q1.xp * q2.wp +
q1.yp * q2.zp -
q1.zp * q2.yp;
- qrealinner y = q1.wp * q2.yp +
+ float y = q1.wp * q2.yp +
q1.yp * q2.wp +
q1.zp * q2.xp -
q1.xp * q2.zp;
- qrealinner z = q1.wp * q2.zp +
+ float z = q1.wp * q2.zp +
q1.zp * q2.wp +
q1.xp * q2.yp -
q1.yp * q2.xp;
- qrealinner w = q1.wp * q2.wp -
+ float w = q1.wp * q2.wp -
q1.xp * q2.xp -
q1.yp * q2.yp -
q1.zp * q2.zp;
@@ -229,11 +227,10 @@ inline QQuaternion &QQuaternion::operator*=(const QQuaternion &quaternion)
inline QQuaternion &QQuaternion::operator/=(qreal divisor)
{
- qrealinner d(divisor);
- xp /= d;
- yp /= d;
- zp /= d;
- wp /= d;
+ xp /= divisor;
+ yp /= divisor;
+ zp /= divisor;
+ wp /= divisor;
return *this;
}
@@ -259,14 +256,12 @@ inline const QQuaternion operator-(const QQuaternion &q1, const QQuaternion &q2)
inline const QQuaternion operator*(qreal factor, const QQuaternion &quaternion)
{
- qrealinner f(factor);
- return QQuaternion(quaternion.wp * f, quaternion.xp * f, quaternion.yp * f, quaternion.zp * f, 1);
+ return QQuaternion(quaternion.wp * factor, quaternion.xp * factor, quaternion.yp * factor, quaternion.zp * factor, 1);
}
inline const QQuaternion operator*(const QQuaternion &quaternion, qreal factor)
{
- qrealinner f(factor);
- return QQuaternion(quaternion.wp * f, quaternion.xp * f, quaternion.yp * f, quaternion.zp * f, 1);
+ return QQuaternion(quaternion.wp * factor, quaternion.xp * factor, quaternion.yp * factor, quaternion.zp * factor, 1);
}
inline const QQuaternion operator-(const QQuaternion &quaternion)
@@ -276,8 +271,7 @@ inline const QQuaternion operator-(const QQuaternion &quaternion)
inline const QQuaternion operator/(const QQuaternion &quaternion, qreal divisor)
{
- qrealinner d(divisor);
- return QQuaternion(quaternion.wp / d, quaternion.xp / d, quaternion.yp / d, quaternion.zp / d, 1);
+ return QQuaternion(quaternion.wp / divisor, quaternion.xp / divisor, quaternion.yp / divisor, quaternion.zp / divisor, 1);
}
inline bool qFuzzyCompare(const QQuaternion& q1, const QQuaternion& q2)
diff --git a/src/gui/math3d/qvector2d.cpp b/src/gui/math3d/qvector2d.cpp
index 0426fc5..c3aaa42 100644
--- a/src/gui/math3d/qvector2d.cpp
+++ b/src/gui/math3d/qvector2d.cpp
@@ -42,7 +42,8 @@
#include "qvector2d.h"
#include "qvector3d.h"
#include "qvector4d.h"
-#include "qmath3dutil_p.h"
+#include <QtCore/qdebug.h>
+#include <QtCore/qmath.h>
QT_BEGIN_NAMESPACE
@@ -74,12 +75,6 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \fn QVector2D::QVector2D(int xpos, int ypos)
-
- Constructs a vector with coordinates (\a xpos, \a ypos).
-*/
-
-/*!
\fn QVector2D::QVector2D(const QPoint& point)
Constructs a vector with x and y coordinates from a 2D \a point.
@@ -169,7 +164,7 @@ QVector2D::QVector2D(const QVector4D& vector)
*/
qreal QVector2D::length() const
{
- return qvtsqrt64(qvtmul64(xp, xp) + qvtmul64(yp, yp));
+ return qSqrt(xp * xp + yp * yp);
}
/*!
@@ -180,37 +175,43 @@ qreal QVector2D::length() const
*/
qreal QVector2D::lengthSquared() const
{
- return qvtdot64(qvtmul64(xp, xp) + qvtmul64(yp, yp));
+ return xp * xp + yp * yp;
}
/*!
- Returns the normalized unit vector form of this vector. If this vector
- is not null, the returned vector is guaranteed to be 1.0 in length.
- If this vector is null, then a null vector is returned.
+ Returns the normalized unit vector form of this vector.
+
+ If this vector is null, then a null vector is returned. If the length
+ of the vector is very close to 1, then the vector will be returned as-is.
+ Otherwise the normalized form of the vector of length 1 will be returned.
\sa length(), normalize()
*/
QVector2D QVector2D::normalized() const
{
- qreal len = length();
- if (!qIsNull(len))
- return *this / len;
+ qreal len = lengthSquared();
+ if (qFuzzyIsNull(len - 1.0f))
+ return *this;
+ else if (!qFuzzyIsNull(len))
+ return *this / qSqrt(len);
else
return QVector2D();
}
/*!
Normalizes the currect vector in place. Nothing happens if this
- vector is a null vector.
+ vector is a null vector or the length of the vector is very close to 1.
\sa length(), normalized()
*/
void QVector2D::normalize()
{
- qreal len = length();
- if (qIsNull(len))
+ qreal len = lengthSquared();
+ if (qFuzzyIsNull(len - 1.0f) || qFuzzyIsNull(len))
return;
+ len = qSqrt(len);
+
xp /= len;
yp /= len;
}
@@ -263,7 +264,7 @@ void QVector2D::normalize()
*/
qreal QVector2D::dotProduct(const QVector2D& v1, const QVector2D& v2)
{
- return qvtdot64(qvtmul64(v1.xp, v2.xp) + qvtmul64(v1.yp, v2.yp));
+ return v1.xp * v2.xp + v1.yp * v2.yp;
}
/*!
diff --git a/src/gui/math3d/qvector2d.h b/src/gui/math3d/qvector2d.h
index a72ecc5..b027df4 100644
--- a/src/gui/math3d/qvector2d.h
+++ b/src/gui/math3d/qvector2d.h
@@ -42,7 +42,6 @@
#ifndef QVECTOR2D_H
#define QVECTOR2D_H
-#include <QtGui/qmath3dglobal.h>
#include <QtCore/qpoint.h>
#include <QtCore/qmetatype.h>
@@ -62,7 +61,6 @@ class Q_GUI_EXPORT QVector2D
public:
QVector2D();
QVector2D(qreal xpos, qreal ypos);
- QVector2D(int xpos, int ypos);
explicit QVector2D(const QPoint& point);
explicit QVector2D(const QPointF& point);
#ifndef QT_NO_VECTOR3D
@@ -117,23 +115,20 @@ public:
QPointF toPointF() const;
private:
- qrealinner xp, yp;
+ float xp, yp;
- QVector2D(qrealinner xpos, qrealinner ypos, int dummy);
+ QVector2D(float xpos, float ypos, int dummy);
friend class QVector3D;
friend class QVector4D;
- friend class QVertexArray;
};
inline QVector2D::QVector2D() : xp(0.0f), yp(0.0f) {}
-inline QVector2D::QVector2D(qrealinner xpos, qrealinner ypos, int) : xp(xpos), yp(ypos) {}
+inline QVector2D::QVector2D(float xpos, float ypos, int) : xp(xpos), yp(ypos) {}
inline QVector2D::QVector2D(qreal xpos, qreal ypos) : xp(xpos), yp(ypos) {}
-inline QVector2D::QVector2D(int xpos, int ypos) : xp(xpos), yp(ypos) {}
-
inline QVector2D::QVector2D(const QPoint& point) : xp(point.x()), yp(point.y()) {}
inline QVector2D::QVector2D(const QPointF& point) : xp(point.x()), yp(point.y()) {}
@@ -143,8 +138,8 @@ inline bool QVector2D::isNull() const
return qIsNull(xp) && qIsNull(yp);
}
-inline qreal QVector2D::x() const { return qt_math3d_convert<qreal, qrealinner>(xp); }
-inline qreal QVector2D::y() const { return qt_math3d_convert<qreal, qrealinner>(yp); }
+inline qreal QVector2D::x() const { return qreal(xp); }
+inline qreal QVector2D::y() const { return qreal(yp); }
inline void QVector2D::setX(qreal x) { xp = x; }
inline void QVector2D::setY(qreal y) { yp = y; }
@@ -165,9 +160,8 @@ inline QVector2D &QVector2D::operator-=(const QVector2D &vector)
inline QVector2D &QVector2D::operator*=(qreal factor)
{
- qrealinner f(factor);
- xp *= f;
- yp *= f;
+ xp *= factor;
+ yp *= factor;
return *this;
}
@@ -180,9 +174,8 @@ inline QVector2D &QVector2D::operator*=(const QVector2D &vector)
inline QVector2D &QVector2D::operator/=(qreal divisor)
{
- qrealinner d(divisor);
- xp /= d;
- yp /= d;
+ xp /= divisor;
+ yp /= divisor;
return *this;
}
@@ -208,14 +201,12 @@ inline const QVector2D operator-(const QVector2D &v1, const QVector2D &v2)
inline const QVector2D operator*(qreal factor, const QVector2D &vector)
{
- qrealinner f(factor);
- return QVector2D(vector.xp * f, vector.yp * f, 1);
+ return QVector2D(vector.xp * factor, vector.yp * factor, 1);
}
inline const QVector2D operator*(const QVector2D &vector, qreal factor)
{
- qrealinner f(factor);
- return QVector2D(vector.xp * f, vector.yp * f, 1);
+ return QVector2D(vector.xp * factor, vector.yp * factor, 1);
}
inline const QVector2D operator*(const QVector2D &v1, const QVector2D &v2)
@@ -230,8 +221,7 @@ inline const QVector2D operator-(const QVector2D &vector)
inline const QVector2D operator/(const QVector2D &vector, qreal divisor)
{
- qrealinner d(divisor);
- return QVector2D(vector.xp / d, vector.yp / d, 1);
+ return QVector2D(vector.xp / divisor, vector.yp / divisor, 1);
}
inline bool qFuzzyCompare(const QVector2D& v1, const QVector2D& v2)
@@ -246,8 +236,7 @@ inline QPoint QVector2D::toPoint() const
inline QPointF QVector2D::toPointF() const
{
- return QPointF(qt_math3d_convert<qreal, qrealinner>(xp),
- qt_math3d_convert<qreal, qrealinner>(yp));
+ return QPointF(qreal(xp), qreal(yp));
}
#ifndef QT_NO_DEBUG_STREAM
diff --git a/src/gui/math3d/qvector3d.cpp b/src/gui/math3d/qvector3d.cpp
index 32068ee..c83cd60 100644
--- a/src/gui/math3d/qvector3d.cpp
+++ b/src/gui/math3d/qvector3d.cpp
@@ -42,8 +42,8 @@
#include "qvector3d.h"
#include "qvector2d.h"
#include "qvector4d.h"
-#include "qmath3dutil_p.h"
#include <QtCore/qmath.h>
+#include <QtCore/qdebug.h>
QT_BEGIN_NAMESPACE
@@ -79,12 +79,6 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \fn QVector3D::QVector3D(int xpos, int ypos, int zpos)
-
- Constructs a vector with coordinates (\a xpos, \a ypos, \a zpos).
-*/
-
-/*!
\fn QVector3D::QVector3D(const QPoint& point)
Constructs a vector with x and y coordinates from a 2D \a point, and a
@@ -201,33 +195,39 @@ QVector3D::QVector3D(const QVector4D& vector)
*/
/*!
- Returns the normalized unit vector form of this vector. If this vector
- is not null, the returned vector is guaranteed to be 1.0 in length.
- If this vector is null, then a null vector is returned.
+ Returns the normalized unit vector form of this vector.
+
+ If this vector is null, then a null vector is returned. If the length
+ of the vector is very close to 1, then the vector will be returned as-is.
+ Otherwise the normalized form of the vector of length 1 will be returned.
\sa length(), normalize()
*/
QVector3D QVector3D::normalized() const
{
- qreal len = length();
- if (!qIsNull(len))
- return *this / len;
+ qreal len = lengthSquared();
+ if (qFuzzyIsNull(len - 1.0f))
+ return *this;
+ else if (!qFuzzyIsNull(len))
+ return *this / qSqrt(len);
else
return QVector3D();
}
/*!
Normalizes the currect vector in place. Nothing happens if this
- vector is a null vector.
+ vector is a null vector or the length of the vector is very close to 1.
\sa length(), normalized()
*/
void QVector3D::normalize()
{
- qreal len = length();
- if (qIsNull(len))
+ qreal len = lengthSquared();
+ if (qFuzzyIsNull(len - 1.0f) || qFuzzyIsNull(len))
return;
+ len = qSqrt(len);
+
xp /= len;
yp /= len;
zp /= len;
@@ -287,7 +287,7 @@ void QVector3D::normalize()
*/
qreal QVector3D::dotProduct(const QVector3D& v1, const QVector3D& v2)
{
- return qvtdot64(qvtmul64(v1.xp, v2.xp) + qvtmul64(v1.yp, v2.yp) + qvtmul64(v1.zp, v2.zp));
+ return v1.xp * v2.xp + v1.yp * v2.yp + v1.zp * v2.zp;
}
/*!
@@ -535,7 +535,7 @@ QVector4D QVector3D::toVector4D() const
*/
qreal QVector3D::length() const
{
- return qvtsqrt64(qvtmul64(xp, xp) + qvtmul64(yp, yp) + qvtmul64(zp, zp));
+ return qSqrt(xp * xp + yp * yp + zp * zp);
}
/*!
@@ -546,7 +546,7 @@ qreal QVector3D::length() const
*/
qreal QVector3D::lengthSquared() const
{
- return qvtdot64(qvtmul64(xp, xp) + qvtmul64(yp, yp) + qvtmul64(zp, zp));
+ return xp * xp + yp * yp + zp * zp;
}
#ifndef QT_NO_DEBUG_STREAM
diff --git a/src/gui/math3d/qvector3d.h b/src/gui/math3d/qvector3d.h
index 8f8f3b4..02873f2 100644
--- a/src/gui/math3d/qvector3d.h
+++ b/src/gui/math3d/qvector3d.h
@@ -42,7 +42,6 @@
#ifndef QVECTOR3D_H
#define QVECTOR3D_H
-#include <QtGui/qmath3dglobal.h>
#include <QtCore/qpoint.h>
#include <QtCore/qmetatype.h>
@@ -64,7 +63,6 @@ class Q_GUI_EXPORT QVector3D
public:
QVector3D();
QVector3D(qreal xpos, qreal ypos, qreal zpos);
- QVector3D(int xpos, int ypos, int zpos);
explicit QVector3D(const QPoint& point);
explicit QVector3D(const QPointF& point);
#ifndef QT_NO_VECTOR2D
@@ -130,16 +128,14 @@ public:
QPointF toPointF() const;
private:
- qrealinner xp, yp, zp;
+ float xp, yp, zp;
- QVector3D(qrealinner xpos, qrealinner ypos, qrealinner zpos, int dummy);
+ QVector3D(float xpos, float ypos, float zpos, int dummy);
friend class QVector2D;
friend class QVector4D;
friend class QQuaternion;
friend class QMatrix4x4;
- friend class QVertexArray;
- friend class QGLPainter;
#ifndef QT_NO_MATRIX4X4
friend QVector3D operator*(const QVector3D& vector, const QMatrix4x4& matrix);
friend QVector3D operator*(const QMatrix4x4& matrix, const QVector3D& vector);
@@ -150,9 +146,7 @@ inline QVector3D::QVector3D() : xp(0.0f), yp(0.0f), zp(0.0f) {}
inline QVector3D::QVector3D(qreal xpos, qreal ypos, qreal zpos) : xp(xpos), yp(ypos), zp(zpos) {}
-inline QVector3D::QVector3D(qrealinner xpos, qrealinner ypos, qrealinner zpos, int) : xp(xpos), yp(ypos), zp(zpos) {}
-
-inline QVector3D::QVector3D(int xpos, int ypos, int zpos) : xp(xpos), yp(ypos), zp(zpos) {}
+inline QVector3D::QVector3D(float xpos, float ypos, float zpos, int) : xp(xpos), yp(ypos), zp(zpos) {}
inline QVector3D::QVector3D(const QPoint& point) : xp(point.x()), yp(point.y()), zp(0.0f) {}
@@ -163,9 +157,9 @@ inline bool QVector3D::isNull() const
return qIsNull(xp) && qIsNull(yp) && qIsNull(zp);
}
-inline qreal QVector3D::x() const { return qt_math3d_convert<qreal, qrealinner>(xp); }
-inline qreal QVector3D::y() const { return qt_math3d_convert<qreal, qrealinner>(yp); }
-inline qreal QVector3D::z() const { return qt_math3d_convert<qreal, qrealinner>(zp); }
+inline qreal QVector3D::x() const { return qreal(xp); }
+inline qreal QVector3D::y() const { return qreal(yp); }
+inline qreal QVector3D::z() const { return qreal(zp); }
inline void QVector3D::setX(qreal x) { xp = x; }
inline void QVector3D::setY(qreal y) { yp = y; }
@@ -189,10 +183,9 @@ inline QVector3D &QVector3D::operator-=(const QVector3D &vector)
inline QVector3D &QVector3D::operator*=(qreal factor)
{
- qrealinner f(factor);
- xp *= f;
- yp *= f;
- zp *= f;
+ xp *= factor;
+ yp *= factor;
+ zp *= factor;
return *this;
}
@@ -206,10 +199,9 @@ inline QVector3D &QVector3D::operator*=(const QVector3D& vector)
inline QVector3D &QVector3D::operator/=(qreal divisor)
{
- qrealinner d(divisor);
- xp /= d;
- yp /= d;
- zp /= d;
+ xp /= divisor;
+ yp /= divisor;
+ zp /= divisor;
return *this;
}
@@ -235,14 +227,12 @@ inline const QVector3D operator-(const QVector3D &v1, const QVector3D &v2)
inline const QVector3D operator*(qreal factor, const QVector3D &vector)
{
- qrealinner f(factor);
- return QVector3D(vector.xp * f, vector.yp * f, vector.zp * f, 1);
+ return QVector3D(vector.xp * factor, vector.yp * factor, vector.zp * factor, 1);
}
inline const QVector3D operator*(const QVector3D &vector, qreal factor)
{
- qrealinner f(factor);
- return QVector3D(vector.xp * f, vector.yp * f, vector.zp * f, 1);
+ return QVector3D(vector.xp * factor, vector.yp * factor, vector.zp * factor, 1);
}
inline const QVector3D operator*(const QVector3D &v1, const QVector3D& v2)
@@ -257,8 +247,7 @@ inline const QVector3D operator-(const QVector3D &vector)
inline const QVector3D operator/(const QVector3D &vector, qreal divisor)
{
- qrealinner d(divisor);
- return QVector3D(vector.xp / d, vector.yp / d, vector.zp / d, 1);
+ return QVector3D(vector.xp / divisor, vector.yp / divisor, vector.zp / divisor, 1);
}
inline bool qFuzzyCompare(const QVector3D& v1, const QVector3D& v2)
@@ -275,8 +264,7 @@ inline QPoint QVector3D::toPoint() const
inline QPointF QVector3D::toPointF() const
{
- return QPointF(qt_math3d_convert<qreal, qrealinner>(xp),
- qt_math3d_convert<qreal, qrealinner>(yp));
+ return QPointF(qreal(xp), qreal(yp));
}
#ifndef QT_NO_DEBUG_STREAM
diff --git a/src/gui/math3d/qvector4d.cpp b/src/gui/math3d/qvector4d.cpp
index 4287806..010fa53 100644
--- a/src/gui/math3d/qvector4d.cpp
+++ b/src/gui/math3d/qvector4d.cpp
@@ -42,7 +42,8 @@
#include "qvector4d.h"
#include "qvector3d.h"
#include "qvector2d.h"
-#include "qmath3dutil_p.h"
+#include <QtCore/qdebug.h>
+#include <QtCore/qmath.h>
QT_BEGIN_NAMESPACE
@@ -76,12 +77,6 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \fn QVector4D::QVector4D(int xpos, int ypos, int zpos, int wpos)
-
- Constructs a vector with coordinates (\a xpos, \a ypos, \a zpos, \a wpos).
-*/
-
-/*!
\fn QVector4D::QVector4D(const QPoint& point)
Constructs a vector with x and y coordinates from a 2D \a point, and
@@ -237,8 +232,7 @@ QVector4D::QVector4D(const QVector3D& vector, qreal wpos)
*/
qreal QVector4D::length() const
{
- return qvtsqrt64(qvtmul64(xp, xp) + qvtmul64(yp, yp) +
- qvtmul64(zp, zp) + qvtmul64(wp, wp));
+ return qSqrt(xp * xp + yp * yp + zp * zp + wp * wp);
}
/*!
@@ -249,45 +243,49 @@ qreal QVector4D::length() const
*/
qreal QVector4D::lengthSquared() const
{
- return qvtdot64(qvtmul64(xp, xp) + qvtmul64(yp, yp) +
- qvtmul64(zp, zp) + qvtmul64(wp, wp));
+ return xp * xp + yp * yp + zp * zp + wp * wp;
}
/*!
- Returns the normalized unit vector form of this vector. If this vector
- is not null, the returned vector is guaranteed to be 1.0 in length.
- If this vector is null, then a null vector is returned.
+ Returns the normalized unit vector form of this vector.
+
+ If this vector is null, then a null vector is returned. If the length
+ of the vector is very close to 1, then the vector will be returned as-is.
+ Otherwise the normalized form of the vector of length 1 will be returned.
\sa length(), normalize()
*/
QVector4D QVector4D::normalized() const
{
- qreal len = length();
- if (!qIsNull(len))
- return *this / len;
+ qreal len = lengthSquared();
+ if (qFuzzyIsNull(len - 1.0f))
+ return *this;
+ else if (!qFuzzyIsNull(len))
+ return *this / qSqrt(len);
else
return QVector4D();
}
/*!
Normalizes the currect vector in place. Nothing happens if this
- vector is a null vector.
+ vector is a null vector or the length of the vector is very close to 1.
\sa length(), normalized()
*/
void QVector4D::normalize()
{
- qreal len = length();
- if (qIsNull(len))
+ qreal len = lengthSquared();
+ if (qFuzzyIsNull(len - 1.0f) || qFuzzyIsNull(len))
return;
+ len = qSqrt(len);
+
xp /= len;
yp /= len;
zp /= len;
wp /= len;
}
-
/*!
\fn QVector4D &QVector4D::operator+=(const QVector4D &vector)
@@ -336,8 +334,7 @@ void QVector4D::normalize()
*/
qreal QVector4D::dotProduct(const QVector4D& v1, const QVector4D& v2)
{
- return qvtdot64(qvtmul64(v1.xp, v2.xp) + qvtmul64(v1.yp, v2.yp) +
- qvtmul64(v1.zp, v2.zp) + qvtmul64(v1.wp, v2.wp));
+ return v1.xp * v2.xp + v1.yp * v2.yp + v1.zp * v2.zp + v1.wp * v2.wp;
}
/*!
diff --git a/src/gui/math3d/qvector4d.h b/src/gui/math3d/qvector4d.h
index 4ac6ae8..8e673f3 100644
--- a/src/gui/math3d/qvector4d.h
+++ b/src/gui/math3d/qvector4d.h
@@ -42,7 +42,6 @@
#ifndef QVECTOR4D_H
#define QVECTOR4D_H
-#include <QtGui/qmath3dglobal.h>
#include <QtCore/qpoint.h>
#include <QtCore/qmetatype.h>
@@ -64,7 +63,6 @@ class Q_GUI_EXPORT QVector4D
public:
QVector4D();
QVector4D(qreal xpos, qreal ypos, qreal zpos, qreal wpos);
- QVector4D(int xpos, int ypos, int zpos, int wpos);
explicit QVector4D(const QPoint& point);
explicit QVector4D(const QPointF& point);
#ifndef QT_NO_VECTOR2D
@@ -127,15 +125,14 @@ public:
QPointF toPointF() const;
private:
- qrealinner xp, yp, zp, wp;
+ float xp, yp, zp, wp;
- QVector4D(qrealinner xpos, qrealinner ypos, qrealinner zpos, qrealinner wpos, int dummy);
+ QVector4D(float xpos, float ypos, float zpos, float wpos, int dummy);
friend class QVector2D;
friend class QVector3D;
friend class QQuaternion;
friend class QMatrix4x4;
- friend class QVertexArray;
#ifndef QT_NO_MATRIX4X4
friend QVector4D operator*(const QVector4D& vector, const QMatrix4x4& matrix);
friend QVector4D operator*(const QMatrix4x4& matrix, const QVector4D& vector);
@@ -146,9 +143,7 @@ inline QVector4D::QVector4D() : xp(0.0f), yp(0.0f), zp(0.0f), wp(0.0f) {}
inline QVector4D::QVector4D(qreal xpos, qreal ypos, qreal zpos, qreal wpos) : xp(xpos), yp(ypos), zp(zpos), wp(wpos) {}
-inline QVector4D::QVector4D(qrealinner xpos, qrealinner ypos, qrealinner zpos, qrealinner wpos, int) : xp(xpos), yp(ypos), zp(zpos), wp(wpos) {}
-
-inline QVector4D::QVector4D(int xpos, int ypos, int zpos, int wpos) : xp(xpos), yp(ypos), zp(zpos), wp(wpos) {}
+inline QVector4D::QVector4D(float xpos, float ypos, float zpos, float wpos, int) : xp(xpos), yp(ypos), zp(zpos), wp(wpos) {}
inline QVector4D::QVector4D(const QPoint& point) : xp(point.x()), yp(point.y()), zp(0.0f), wp(0.0f) {}
@@ -159,10 +154,10 @@ inline bool QVector4D::isNull() const
return qIsNull(xp) && qIsNull(yp) && qIsNull(zp) && qIsNull(wp);
}
-inline qreal QVector4D::x() const { return qt_math3d_convert<qreal, qrealinner>(xp); }
-inline qreal QVector4D::y() const { return qt_math3d_convert<qreal, qrealinner>(yp); }
-inline qreal QVector4D::z() const { return qt_math3d_convert<qreal, qrealinner>(zp); }
-inline qreal QVector4D::w() const { return qt_math3d_convert<qreal, qrealinner>(wp); }
+inline qreal QVector4D::x() const { return qreal(xp); }
+inline qreal QVector4D::y() const { return qreal(yp); }
+inline qreal QVector4D::z() const { return qreal(zp); }
+inline qreal QVector4D::w() const { return qreal(wp); }
inline void QVector4D::setX(qreal x) { xp = x; }
inline void QVector4D::setY(qreal y) { yp = y; }
@@ -189,11 +184,10 @@ inline QVector4D &QVector4D::operator-=(const QVector4D &vector)
inline QVector4D &QVector4D::operator*=(qreal factor)
{
- qrealinner f(factor);
- xp *= f;
- yp *= f;
- zp *= f;
- wp *= f;
+ xp *= factor;
+ yp *= factor;
+ zp *= factor;
+ wp *= factor;
return *this;
}
@@ -208,11 +202,10 @@ inline QVector4D &QVector4D::operator*=(const QVector4D &vector)
inline QVector4D &QVector4D::operator/=(qreal divisor)
{
- qrealinner d(divisor);
- xp /= d;
- yp /= d;
- zp /= d;
- wp /= d;
+ xp /= divisor;
+ yp /= divisor;
+ zp /= divisor;
+ wp /= divisor;
return *this;
}
@@ -238,14 +231,12 @@ inline const QVector4D operator-(const QVector4D &v1, const QVector4D &v2)
inline const QVector4D operator*(qreal factor, const QVector4D &vector)
{
- qrealinner f(factor);
- return QVector4D(vector.xp * f, vector.yp * f, vector.zp * f, vector.wp * f, 1);
+ return QVector4D(vector.xp * factor, vector.yp * factor, vector.zp * factor, vector.wp * factor, 1);
}
inline const QVector4D operator*(const QVector4D &vector, qreal factor)
{
- qrealinner f(factor);
- return QVector4D(vector.xp * f, vector.yp * f, vector.zp * f, vector.wp * f, 1);
+ return QVector4D(vector.xp * factor, vector.yp * factor, vector.zp * factor, vector.wp * factor, 1);
}
inline const QVector4D operator*(const QVector4D &v1, const QVector4D& v2)
@@ -260,8 +251,7 @@ inline const QVector4D operator-(const QVector4D &vector)
inline const QVector4D operator/(const QVector4D &vector, qreal divisor)
{
- qrealinner d(divisor);
- return QVector4D(vector.xp / d, vector.yp / d, vector.zp / d, vector.wp / d, 1);
+ return QVector4D(vector.xp / divisor, vector.yp / divisor, vector.zp / divisor, vector.wp / divisor, 1);
}
inline bool qFuzzyCompare(const QVector4D& v1, const QVector4D& v2)
@@ -279,8 +269,7 @@ inline QPoint QVector4D::toPoint() const
inline QPointF QVector4D::toPointF() const
{
- return QPointF(qt_math3d_convert<qreal, qrealinner>(xp),
- qt_math3d_convert<qreal, qrealinner>(yp));
+ return QPointF(qreal(xp), qreal(yp));
}
#ifndef QT_NO_DEBUG_STREAM
diff --git a/src/gui/painting/qbezier.cpp b/src/gui/painting/qbezier.cpp
index 8317dd8..7ed521e 100644
--- a/src/gui/painting/qbezier.cpp
+++ b/src/gui/painting/qbezier.cpp
@@ -127,13 +127,13 @@ static inline void flattenBezierWithoutInflections(QBezier &bez,
qreal dy = bez.y2 - bez.y1;
qreal normalized = qSqrt(dx * dx + dy * dy);
- if (qFuzzyCompare(normalized + 1, 1))
+ if (qFuzzyIsNull(normalized))
break;
qreal d = qAbs(dx * (bez.y3 - bez.y2) - dy * (bez.x3 - bez.x2));
qreal t = qSqrt(4. / 3. * normalized * flatness / d);
- if (t > 1 || qFuzzyCompare(t, (qreal)1.))
+ if (t > 1 || qFuzzyIsNull(t - (qreal)1.))
break;
bez.parameterSplitLeft(t, &left);
p->append(bez.pt1());
@@ -144,19 +144,19 @@ static inline void flattenBezierWithoutInflections(QBezier &bez,
static inline int quadraticRoots(qreal a, qreal b, qreal c,
qreal *x1, qreal *x2)
{
- if (qFuzzyCompare(a + 1, 1)) {
- if (qFuzzyCompare(b + 1, 1))
+ if (qFuzzyIsNull(a)) {
+ if (qFuzzyIsNull(b))
return 0;
*x1 = *x2 = (-c / b);
return 1;
} else {
const qreal det = b * b - 4 * a * c;
- if (qFuzzyCompare(det + 1, 1)) {
+ if (qFuzzyIsNull(det)) {
*x1 = *x2 = -b / (2 * a);
return 1;
}
if (det > 0) {
- if (qFuzzyCompare(b + 1, 1)) {
+ if (qFuzzyIsNull(b)) {
*x2 = qSqrt(-c / a);
*x1 = -(*x2);
return 2;
@@ -187,7 +187,7 @@ static inline bool findInflections(qreal a, qreal b, qreal c,
*t1 = r2;
*t2 = r1;
}
- if (!qFuzzyCompare(a + 1, 1))
+ if (!qFuzzyIsNull(a))
*tCups = 0.5 * (-b / a);
else
*tCups = 2;
@@ -243,7 +243,7 @@ void QBezier::addToPolygonMixed(QPolygonF *polygon) const
qreal b = 6 * (ay * cx - ax * cy);
qreal c = 2 * (by * cx - bx * cy);
- if ((qFuzzyCompare(a + 1, 1) && qFuzzyCompare(b + 1, 1)) ||
+ if ((qFuzzyIsNull(a) && qFuzzyIsNull(b)) ||
(b * b - 4 * a *c) < 0) {
QBezier bez(*this);
flattenBezierWithoutInflections(bez, polygon);
@@ -447,7 +447,7 @@ static ShiftResult shift(const QBezier *orig, QBezier *shifted, qreal offset, qr
qreal r = 1.0 + prev_normal.x() * next_normal.x()
+ prev_normal.y() * next_normal.y();
- if (qFuzzyCompare(r + 1, 1)) {
+ if (qFuzzyIsNull(r)) {
points_shifted[i] = points[i] + offset * prev_normal;
} else {
qreal k = offset / r;
@@ -477,12 +477,12 @@ static bool addCircle(const QBezier *b, qreal offset, QBezier *o)
normals[0] = QPointF(b->y2 - b->y1, b->x1 - b->x2);
qreal dist = qSqrt(normals[0].x()*normals[0].x() + normals[0].y()*normals[0].y());
- if (qFuzzyCompare(dist + 1, 1))
+ if (qFuzzyIsNull(dist))
return false;
normals[0] /= dist;
normals[2] = QPointF(b->y4 - b->y3, b->x3 - b->x4);
dist = qSqrt(normals[2].x()*normals[2].x() + normals[2].y()*normals[2].y());
- if (qFuzzyCompare(dist + 1, 1))
+ if (qFuzzyIsNull(dist))
return false;
normals[2] /= dist;
@@ -1022,7 +1022,7 @@ int QBezier::stationaryYPoints(qreal &t0, qreal &t1) const
QList<qreal> result;
- if (qFuzzyCompare(reciprocal + 1, 1)) {
+ if (qFuzzyIsNull(reciprocal)) {
t0 = -b / (2 * a);
return 1;
} else if (reciprocal > 0) {
diff --git a/src/gui/painting/qcolor.cpp b/src/gui/painting/qcolor.cpp
index 5d7d4ab..24d167e 100644
--- a/src/gui/painting/qcolor.cpp
+++ b/src/gui/painting/qcolor.cpp
@@ -1387,7 +1387,7 @@ QColor QColor::toHsv() const
const qreal min = Q_MIN_3(r, g, b);
const qreal delta = max - min;
color.ct.ahsv.value = qRound(max * USHRT_MAX);
- if (qFuzzyCompare(delta + 1, 1)) {
+ if (qFuzzyIsNull(delta)) {
// achromatic case, hue is undefined
color.ct.ahsv.hue = USHRT_MAX;
color.ct.ahsv.saturation = 0;
@@ -1441,7 +1441,7 @@ QColor QColor::toCmyk() const
// cmy -> cmyk
const qreal k = qMin(c, qMin(m, y));
- if (!qFuzzyCompare(k,1)) {
+ if (!qFuzzyIsNull(k - 1)) {
c = (c - k) / (1.0 - k);
m = (m - k) / (1.0 - k);
y = (y - k) / (1.0 - k);
diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp
index 789d96a..63e14ca 100644
--- a/src/gui/painting/qdrawhelper.cpp
+++ b/src/gui/painting/qdrawhelper.cpp
@@ -6933,6 +6933,12 @@ static void qt_alphamapblit_quint16(QRasterBuffer *rasterBuffer,
void qt_build_pow_tables() {
qreal smoothing = 1.7;
+#ifdef Q_WS_MAC
+ // decided by testing a few things on an iMac, should probably get this from the
+ // system...
+ smoothing = 2.0;
+#endif
+
#ifdef Q_WS_WIN
int winSmooth;
if (SystemParametersInfo(0x200C /* SPI_GETFONTSMOOTHINGCONTRAST */, 0, &winSmooth, 0))
diff --git a/src/gui/painting/qmatrix.cpp b/src/gui/painting/qmatrix.cpp
index 4439d52..31abcad 100644
--- a/src/gui/painting/qmatrix.cpp
+++ b/src/gui/painting/qmatrix.cpp
@@ -208,9 +208,13 @@ QT_BEGIN_NAMESPACE
*/
QMatrix::QMatrix()
+ : _m11(1.)
+ , _m12(0.)
+ , _m21(0.)
+ , _m22(1.)
+ , _dx(0.)
+ , _dy(0.)
{
- _m11 = _m22 = 1.0;
- _m12 = _m21 = _dx = _dy = 0.0;
}
/*!
@@ -220,12 +224,14 @@ QMatrix::QMatrix()
\sa setMatrix()
*/
-QMatrix::QMatrix(qreal m11, qreal m12, qreal m21, qreal m22,
- qreal dx, qreal dy)
+QMatrix::QMatrix(qreal m11, qreal m12, qreal m21, qreal m22, qreal dx, qreal dy)
+ : _m11(m11)
+ , _m12(m12)
+ , _m21(m21)
+ , _m22(m22)
+ , _dx(dx)
+ , _dy(dy)
{
- _m11 = m11; _m12 = m12;
- _m21 = m21; _m22 = m22;
- _dx = dx; _dy = dy;
}
@@ -233,8 +239,13 @@ QMatrix::QMatrix(qreal m11, qreal m12, qreal m21, qreal m22,
Constructs a matrix that is a copy of the given \a matrix.
*/
QMatrix::QMatrix(const QMatrix &matrix)
+ : _m11(matrix._m11)
+ , _m12(matrix._m12)
+ , _m21(matrix._m21)
+ , _m22(matrix._m22)
+ , _dx(matrix._dx)
+ , _dy(matrix._dy)
{
- *this = matrix;
}
/*!
@@ -249,12 +260,14 @@ QMatrix::QMatrix(const QMatrix &matrix)
\sa QMatrix()
*/
-void QMatrix::setMatrix(qreal m11, qreal m12, qreal m21, qreal m22,
- qreal dx, qreal dy)
+void QMatrix::setMatrix(qreal m11, qreal m12, qreal m21, qreal m22, qreal dx, qreal dy)
{
- _m11 = m11; _m12 = m12;
- _m21 = m21; _m22 = m22;
- _dx = dx; _dy = dy;
+ _m11 = m11;
+ _m12 = m12;
+ _m21 = m21;
+ _m22 = m22;
+ _dx = dx;
+ _dy = dy;
}
@@ -968,18 +981,17 @@ QMatrix QMatrix::inverted(bool *invertible) const
if (determinant == 0.0) {
if (invertible)
*invertible = false; // singular matrix
- QMatrix defaultMatrix;
- return defaultMatrix;
+ return QMatrix(true);
}
else { // invertible matrix
if (invertible)
*invertible = true;
qreal dinv = 1.0/determinant;
- QMatrix imatrix((_m22*dinv), (-_m12*dinv),
- (-_m21*dinv), (_m11*dinv),
- ((_m21*_dy - _m22*_dx)*dinv),
- ((_m12*_dx - _m11*_dy)*dinv));
- return imatrix;
+ return QMatrix((_m22*dinv), (-_m12*dinv),
+ (-_m21*dinv), (_m11*dinv),
+ ((_m21*_dy - _m22*_dx)*dinv),
+ ((_m12*_dx - _m11*_dy)*dinv),
+ true);
}
}
@@ -1054,9 +1066,14 @@ QMatrix &QMatrix::operator *=(const QMatrix &m)
QMatrix QMatrix::operator *(const QMatrix &m) const
{
- QMatrix result = *this;
- result *= m;
- return result;
+ qreal tm11 = _m11*m._m11 + _m12*m._m21;
+ qreal tm12 = _m11*m._m12 + _m12*m._m22;
+ qreal tm21 = _m21*m._m11 + _m22*m._m21;
+ qreal tm22 = _m21*m._m12 + _m22*m._m22;
+
+ qreal tdx = _dx*m._m11 + _dy*m._m21 + m._dx;
+ qreal tdy = _dx*m._m12 + _dy*m._m22 + m._dy;
+ return QMatrix(tm11, tm12, tm21, tm22, tdx, tdy, true);
}
/*!
diff --git a/src/gui/painting/qmatrix.h b/src/gui/painting/qmatrix.h
index bf53c32..1e5fbb4 100644
--- a/src/gui/painting/qmatrix.h
+++ b/src/gui/painting/qmatrix.h
@@ -99,7 +99,7 @@ public:
QMatrix &shear(qreal sh, qreal sv);
QMatrix &rotate(qreal a);
- bool isInvertible() const { return !qFuzzyCompare(_m11*_m22 - _m12*_m21 + 1, 1); }
+ bool isInvertible() const { return !qFuzzyIsNull(_m11*_m22 - _m12*_m21); }
qreal det() const { return _m11*_m22 - _m12*_m21; }
QMatrix inverted(bool *invertible = 0) const;
@@ -121,6 +121,20 @@ public:
#endif
private:
+ inline QMatrix(bool)
+ : _m11(1.)
+ , _m12(0.)
+ , _m21(0.)
+ , _m22(1.)
+ , _dx(0.)
+ , _dy(0.) {}
+ inline QMatrix(qreal m11, qreal m12, qreal m21, qreal m22, qreal dx, qreal dy, bool)
+ : _m11(m11)
+ , _m12(m12)
+ , _m21(m21)
+ , _m22(m22)
+ , _dx(dx)
+ , _dy(dy) {}
friend class QTransform;
qreal _m11, _m12;
qreal _m21, _m22;
@@ -147,8 +161,8 @@ Q_GUI_EXPORT QPainterPath operator *(const QPainterPath &p, const QMatrix &m);
inline bool QMatrix::isIdentity() const
{
- return qFuzzyCompare(_m11, 1) && qFuzzyCompare(_m22, 1) && qFuzzyCompare(_m12 + 1, 1)
- && qFuzzyCompare(_m21 + 1, 1) && qFuzzyCompare(_dx + 1, 1) && qFuzzyCompare(_dy + 1, 1);
+ return qFuzzyIsNull(_m11 - 1) && qFuzzyIsNull(_m22 - 1) && qFuzzyIsNull(_m12)
+ && qFuzzyIsNull(_m21) && qFuzzyIsNull(_dx) && qFuzzyIsNull(_dy);
}
/*****************************************************************************
diff --git a/src/gui/painting/qpaintengine_d3d.cpp b/src/gui/painting/qpaintengine_d3d.cpp
index bb81623..9a7638b 100644
--- a/src/gui/painting/qpaintengine_d3d.cpp
+++ b/src/gui/painting/qpaintengine_d3d.cpp
@@ -2506,8 +2506,8 @@ void QD3DDrawHelper::addTrap(const Trapezoid &trap)
qreal _rightA = (qreal)_w/_h;
qreal _rightB = topRightX - _rightA * topRightY;
- qreal invLeftA = qFuzzyCompare(_leftA + 1, 1) ? 0.0 : 1.0 / _leftA;
- qreal invRightA = qFuzzyCompare(_rightA + 1, 1) ? 0.0 : 1.0 / _rightA;
+ qreal invLeftA = qFuzzyIsNull(_leftA) ? 0.0 : 1.0 / _leftA;
+ qreal invRightA = qFuzzyIsNull(_rightA) ? 0.0 : 1.0 / _rightA;
vertex v1 = { {1.f, top - 1.f, 0.5f}, 0.f,
top, bottom, invLeftA, -invRightA,
@@ -2970,7 +2970,7 @@ qreal calculateAngle(qreal dx, qreal dy)
{
qreal angle;
- if (qFuzzyCompare(dx + 1, 1)) {
+ if (qFuzzyIsNull(dx)) {
angle = (dy < 0) ? -M_PI/2 : M_PI/2;
} else {
angle = atanf(dy/dx);
diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp
index 6dd5682..8e3d822 100644
--- a/src/gui/painting/qpaintengine_raster.cpp
+++ b/src/gui/painting/qpaintengine_raster.cpp
@@ -509,16 +509,20 @@ bool QRasterPaintEngine::begin(QPaintDevice *device)
if (d->mono_surface)
d->glyphCacheType = QFontEngineGlyphCache::Raster_Mono;
-#ifdef Q_WS_WIN
- else if (qt_cleartype_enabled) {
+#if defined(Q_WS_WIN)
+ else if (qt_cleartype_enabled)
+#elif defined (Q_WS_MAC)
+ else if (true)
+#else
+ else if (false)
+#endif
+ {
QImage::Format format = static_cast<QImage *>(d->device)->format();
if (format == QImage::Format_ARGB32_Premultiplied || format == QImage::Format_RGB32)
d->glyphCacheType = QFontEngineGlyphCache::Raster_RGBMask;
else
d->glyphCacheType = QFontEngineGlyphCache::Raster_A8;
- }
-#endif
- else
+ } else
d->glyphCacheType = QFontEngineGlyphCache::Raster_A8;
setActive(true);
@@ -618,22 +622,22 @@ void QRasterPaintEngine::updateMatrix(const QTransform &matrix)
d->isPlain45DegreeRotation = false;
if (txop >= QTransform::TxRotate) {
d->isPlain45DegreeRotation =
- (qFuzzyCompare(matrix.m11() + 1, qreal(1))
- && qFuzzyCompare(matrix.m12(), qreal(1))
- && qFuzzyCompare(matrix.m21(), qreal(-1))
- && qFuzzyCompare(matrix.m22() + 1, qreal(1))
+ (qFuzzyIsNull(matrix.m11())
+ && qFuzzyIsNull(matrix.m12() - qreal(1))
+ && qFuzzyIsNull(matrix.m21() + qreal(1))
+ && qFuzzyIsNull(matrix.m22())
)
||
- (qFuzzyCompare(matrix.m11(), qreal(-1))
- && qFuzzyCompare(matrix.m12() + 1, qreal(1))
- && qFuzzyCompare(matrix.m21() + 1, qreal(1))
- && qFuzzyCompare(matrix.m22(), qreal(-1))
+ (qFuzzyIsNull(matrix.m11() + qreal(1))
+ && qFuzzyIsNull(matrix.m12())
+ && qFuzzyIsNull(matrix.m21())
+ && qFuzzyIsNull(matrix.m22() + qreal(1))
)
||
- (qFuzzyCompare(matrix.m11() + 1, qreal(1))
- && qFuzzyCompare(matrix.m12(), qreal(-1))
- && qFuzzyCompare(matrix.m21(), qreal(1))
- && qFuzzyCompare(matrix.m22() + 1, qreal(1))
+ (qFuzzyIsNull(matrix.m11())
+ && qFuzzyIsNull(matrix.m12() + qreal(1))
+ && qFuzzyIsNull(matrix.m21() - qreal(1))
+ && qFuzzyIsNull(matrix.m22())
)
;
}
@@ -2355,11 +2359,6 @@ void QRasterPaintEngine::strokePolygonCosmetic(const QPoint *points, int pointCo
}
}
-#define IMAGE_FROM_PIXMAP(pixmap) \
- pixmap.data->classId() == QPixmapData::RasterClass \
- ? ((QRasterPixmapData *) pixmap.data)->image \
- : pixmap.toImage()
-
/*!
\internal
*/
@@ -2368,16 +2367,33 @@ void QRasterPaintEngine::drawPixmap(const QPointF &pos, const QPixmap &pixmap)
#ifdef QT_DEBUG_DRAW
qDebug() << " - QRasterPaintEngine::drawPixmap(), pos=" << pos << " pixmap=" << pixmap.size() << "depth=" << pixmap.depth();
#endif
- if (pixmap.depth() == 1) {
- Q_D(QRasterPaintEngine);
- QRasterPaintEngineState *s = state();
- if (s->matrix.type() <= QTransform::TxTranslate) {
- drawBitmap(pos + QPointF(s->matrix.dx(), s->matrix.dy()), pixmap, &s->penData);
+
+ if (pixmap.data->classId() == QPixmapData::RasterClass) {
+ const QImage &image = ((QRasterPixmapData *) pixmap.data)->image;
+ if (image.depth() == 1) {
+ Q_D(QRasterPaintEngine);
+ QRasterPaintEngineState *s = state();
+ if (s->matrix.type() <= QTransform::TxTranslate) {
+ drawBitmap(pos + QPointF(s->matrix.dx(), s->matrix.dy()), image, &s->penData);
+ } else {
+ drawImage(pos, d->rasterBuffer->colorizeBitmap(image, s->pen.color()));
+ }
} else {
- drawImage(pos, d->rasterBuffer->colorizeBitmap(IMAGE_FROM_PIXMAP(pixmap), s->pen.color()));
+ QRasterPaintEngine::drawImage(pos, image);
}
} else {
- QRasterPaintEngine::drawImage(pos, IMAGE_FROM_PIXMAP(pixmap));
+ const QImage image = pixmap.toImage();
+ if (pixmap.depth() == 1) {
+ Q_D(QRasterPaintEngine);
+ QRasterPaintEngineState *s = state();
+ if (s->matrix.type() <= QTransform::TxTranslate) {
+ drawBitmap(pos + QPointF(s->matrix.dx(), s->matrix.dy()), image, &s->penData);
+ } else {
+ drawImage(pos, d->rasterBuffer->colorizeBitmap(image, s->pen.color()));
+ }
+ } else {
+ QRasterPaintEngine::drawImage(pos, image);
+ }
}
}
@@ -2390,22 +2406,40 @@ void QRasterPaintEngine::drawPixmap(const QRectF &r, const QPixmap &pixmap, cons
qDebug() << " - QRasterPaintEngine::drawPixmap(), r=" << r << " sr=" << sr << " pixmap=" << pixmap.size() << "depth=" << pixmap.depth();
#endif
- Q_D(QRasterPaintEngine);
- QRasterPaintEngineState *s = state();
-
- if (pixmap.depth() == 1) {
- if (s->matrix.type() <= QTransform::TxTranslate
- && r.size() == sr.size()
- && r.size() == pixmap.size()) {
- ensurePen();
- drawBitmap(r.topLeft() + QPointF(s->matrix.dx(), s->matrix.dy()), pixmap, &s->penData);
- return;
+ if (pixmap.data->classId() == QPixmapData::RasterClass) {
+ const QImage &image = ((QRasterPixmapData *) pixmap.data)->image;
+ if (image.depth() == 1) {
+ Q_D(QRasterPaintEngine);
+ QRasterPaintEngineState *s = state();
+ if (s->matrix.type() <= QTransform::TxTranslate
+ && r.size() == sr.size()
+ && r.size() == pixmap.size()) {
+ ensurePen();
+ drawBitmap(r.topLeft() + QPointF(s->matrix.dx(), s->matrix.dy()), image, &s->penData);
+ return;
+ } else {
+ drawImage(r, d->rasterBuffer->colorizeBitmap(image, s->pen.color()), sr);
+ }
} else {
- drawImage(r, d->rasterBuffer->colorizeBitmap(IMAGE_FROM_PIXMAP(pixmap),
- s->pen.color()), sr);
+ drawImage(r, image, sr);
}
} else {
- drawImage(r, IMAGE_FROM_PIXMAP(pixmap), sr);
+ const QImage image = pixmap.toImage();
+ if (image.depth() == 1) {
+ Q_D(QRasterPaintEngine);
+ QRasterPaintEngineState *s = state();
+ if (s->matrix.type() <= QTransform::TxTranslate
+ && r.size() == sr.size()
+ && r.size() == pixmap.size()) {
+ ensurePen();
+ drawBitmap(r.topLeft() + QPointF(s->matrix.dx(), s->matrix.dy()), image, &s->penData);
+ return;
+ } else {
+ drawImage(r, d->rasterBuffer->colorizeBitmap(image, s->pen.color()), sr);
+ }
+ } else {
+ drawImage(r, image, sr);
+ }
}
}
@@ -2614,10 +2648,15 @@ void QRasterPaintEngine::drawTiledPixmap(const QRectF &r, const QPixmap &pixmap,
QRasterPaintEngineState *s = state();
QImage image;
- if (pixmap.depth() == 1)
- image = d->rasterBuffer->colorizeBitmap(IMAGE_FROM_PIXMAP(pixmap), s->pen.color());
- else
- image = IMAGE_FROM_PIXMAP(pixmap);
+
+ if (pixmap.data->classId() == QPixmapData::RasterClass) {
+ image = ((QRasterPixmapData *) pixmap.data)->image;
+ } else {
+ image = pixmap.toImage();
+ }
+
+ if (image.depth() == 1)
+ image = d->rasterBuffer->colorizeBitmap(image, s->pen.color());
if (s->matrix.type() > QTransform::TxTranslate) {
QTransform copy = s->matrix;
@@ -3650,14 +3689,13 @@ void QRasterPaintEngine::drawBufferSpan(const uint *buffer, int bufsize,
}
#endif // Q_WS_QWS
-void QRasterPaintEngine::drawBitmap(const QPointF &pos, const QPixmap &pm, QSpanData *fg)
+void QRasterPaintEngine::drawBitmap(const QPointF &pos, const QImage &image, QSpanData *fg)
{
Q_ASSERT(fg);
if (!fg->blend)
return;
Q_D(QRasterPaintEngine);
- const QImage image = IMAGE_FROM_PIXMAP(pm);
Q_ASSERT(image.depth() == 1);
const int spanCount = 256;
@@ -3665,8 +3703,8 @@ void QRasterPaintEngine::drawBitmap(const QPointF &pos, const QPixmap &pm, QSpan
int n = 0;
// Boundaries
- int w = pm.width();
- int h = pm.height();
+ int w = image.width();
+ int h = image.height();
int ymax = qMin(qRound(pos.y() + h), d->rasterBuffer->height());
int ymin = qMax(qRound(pos.y()), 0);
int xmax = qMin(qRound(pos.x() + w), d->rasterBuffer->width());
diff --git a/src/gui/painting/qpaintengine_raster_p.h b/src/gui/painting/qpaintengine_raster_p.h
index 0f8060a..26a2b3f 100644
--- a/src/gui/painting/qpaintengine_raster_p.h
+++ b/src/gui/painting/qpaintengine_raster_p.h
@@ -256,7 +256,7 @@ private:
void init();
void fillRect(const QRectF &rect, QSpanData *data);
- void drawBitmap(const QPointF &pos, const QPixmap &image, QSpanData *fill);
+ void drawBitmap(const QPointF &pos, const QImage &image, QSpanData *fill);
void drawCachedGlyphs(const QPointF &p, const QTextItemInt &ti);
diff --git a/src/gui/painting/qpaintengine_x11.cpp b/src/gui/painting/qpaintengine_x11.cpp
index d931f55..39ce59f 100644
--- a/src/gui/painting/qpaintengine_x11.cpp
+++ b/src/gui/painting/qpaintengine_x11.cpp
@@ -1760,7 +1760,10 @@ void QX11PaintEngine::drawPath(const QPainterPath &path)
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) {
- stroker.setWidth(width == 0 ? 1 : width * d->xform_scale);
+ 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())
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp
index fe6cc69..82c22c2 100644
--- a/src/gui/painting/qpainter.cpp
+++ b/src/gui/painting/qpainter.cpp
@@ -1465,8 +1465,8 @@ bool QPainter::isActive() const
/*!
Initializes the painters pen, background and font to the same as
- the given \a widget. Call this function after begin() while the
- painter is active.
+ the given \a widget. This function is called automatically when the
+ painter is opened on a QWidget.
\sa begin(), {QPainter#Settings}{Settings}
*/
@@ -2371,6 +2371,11 @@ void QPainter::setClipping(bool enable)
Returns the currently set clip region. Note that the clip region
is given in logical coordinates.
+ \warning QPainter does not store the combined clip explicitly as
+ this is handled by the underlying QPaintEngine, so the path is
+ recreated on demand and transformed to the current logical
+ coordinate system. This is potentially an expensive operation.
+
\sa setClipRegion(), clipPath(), setClipping()
*/
@@ -2486,6 +2491,11 @@ extern QPainterPath qt_regionToPath(const QRegion &region);
Returns the currently clip as a path. Note that the clip path is
given in logical coordinates.
+ \warning QPainter does not store the combined clip explicitly as
+ this is handled by the underlying QPaintEngine, so the path is
+ recreated on demand and transformed to the current logical
+ coordinate system. This is potentially an expensive operation.
+
\sa setClipPath(), clipRegion(), setClipping()
*/
QPainterPath QPainter::clipPath() const
@@ -5155,9 +5165,6 @@ void QPainter::drawPixmap(const QPointF &p, const QPixmap &pm)
Q_D(QPainter);
- if (!d->engine || pm.isNull())
- return;
-
#ifndef QT_NO_DEBUG
qt_painter_thread_test(d->device->devType(), "drawPixmap()");
#endif
@@ -5167,12 +5174,18 @@ void QPainter::drawPixmap(const QPointF &p, const QPixmap &pm)
return;
}
+ if (!d->engine)
+ return;
+
qreal x = p.x();
qreal y = p.y();
int w = pm.width();
int h = pm.height();
+ if (w <= 0)
+ return;
+
// Emulate opaque background for bitmaps
if (d->state->bgMode == Qt::OpaqueMode && pm.isQBitmap()) {
fillRect(QRectF(x, y, w, h), d->state->bgBrush.color());
@@ -6042,22 +6055,22 @@ void QPainter::drawTextItem(const QPointF &p, const QTextItem &_ti)
const QTransform &m = d->state->matrix;
if (d->state->matrix.type() < QTransform::TxShear) {
bool isPlain90DegreeRotation =
- (qFuzzyCompare(m.m11() + 1, qreal(1))
- && qFuzzyCompare(m.m12(), qreal(1))
- && qFuzzyCompare(m.m21(), qreal(-1))
- && qFuzzyCompare(m.m22() + 1, qreal(1))
+ (qFuzzyIsNull(m.m11())
+ && qFuzzyIsNull(m.m12() - qreal(1))
+ && qFuzzyIsNull(m.m21() + qreal(1))
+ && qFuzzyIsNull(m.m22())
)
||
- (qFuzzyCompare(m.m11(), qreal(-1))
- && qFuzzyCompare(m.m12() + 1, qreal(1))
- && qFuzzyCompare(m.m21() + 1, qreal(1))
- && qFuzzyCompare(m.m22(), qreal(-1))
+ (qFuzzyIsNull(m.m11() + qreal(1))
+ && qFuzzyIsNull(m.m12())
+ && qFuzzyIsNull(m.m21())
+ && qFuzzyIsNull(m.m22() + qreal(1))
)
||
- (qFuzzyCompare(m.m11() + 1, qreal(1))
- && qFuzzyCompare(m.m12(), qreal(-1))
- && qFuzzyCompare(m.m21(), qreal(1))
- && qFuzzyCompare(m.m22() + 1, qreal(1))
+ (qFuzzyIsNull(m.m11())
+ && qFuzzyIsNull(m.m12() + qreal(1))
+ && qFuzzyIsNull(m.m21() - qreal(1))
+ && qFuzzyIsNull(m.m22())
)
;
aa = !isPlain90DegreeRotation;
diff --git a/src/gui/painting/qpainterpath.cpp b/src/gui/painting/qpainterpath.cpp
index b5e092c..d471aaa 100644
--- a/src/gui/painting/qpainterpath.cpp
+++ b/src/gui/painting/qpainterpath.cpp
@@ -1299,10 +1299,10 @@ static QRectF qt_painterpath_bezier_extrema(const QBezier &b)
qreal bx = QT_BEZIER_B(b, x);
qreal cx = QT_BEZIER_C(b, x);
// specialcase quadratic curves to avoid div by zero
- if (qFuzzyCompare(ax + 1, 1)) {
+ if (qFuzzyIsNull(ax)) {
// linear curves are covered by initialization.
- if (!qFuzzyCompare(bx + 1, 1)) {
+ if (!qFuzzyIsNull(bx)) {
qreal t = -cx / bx;
QT_BEZIER_CHECK_T(b, t);
}
@@ -1329,10 +1329,10 @@ static QRectF qt_painterpath_bezier_extrema(const QBezier &b)
qreal cy = QT_BEZIER_C(b, y);
// specialcase quadratic curves to avoid div by zero
- if (qFuzzyCompare(ay + 1, 1)) {
+ if (qFuzzyIsNull(ay)) {
// linear curves are covered by initialization.
- if (!qFuzzyCompare(by + 1, 1)) {
+ if (!qFuzzyIsNull(by)) {
qreal t = -cy / by;
QT_BEZIER_CHECK_T(b, t);
}
@@ -1725,7 +1725,7 @@ static void qt_painterpath_isect_curve(const QBezier &bezier, const QPointF &pt,
*/
bool QPainterPath::contains(const QPointF &pt) const
{
- if (isEmpty())
+ if (isEmpty() || !controlPointRect().contains(pt))
return false;
QPainterPathData *d = d_func();
diff --git a/src/gui/painting/qpathclipper.cpp b/src/gui/painting/qpathclipper.cpp
index 297cdd3..9ef3eb7 100644
--- a/src/gui/painting/qpathclipper.cpp
+++ b/src/gui/painting/qpathclipper.cpp
@@ -138,11 +138,11 @@ bool QIntersectionFinder::linesIntersect(const QLineF &a, const QLineF &b) const
const qreal par = pDelta.x() * qDelta.y() - pDelta.y() * qDelta.x();
- if (qFuzzyCompare(par + 1, 1)) {
+ if (qFuzzyIsNull(par)) {
const QPointF normal(-pDelta.y(), pDelta.x());
// coinciding?
- if (qFuzzyCompare(dot(normal, q1 - p1) + 1, 1)) {
+ if (qFuzzyIsNull(dot(normal, q1 - p1))) {
const qreal dp = dot(pDelta, pDelta);
const qreal tq1 = dot(pDelta, q1 - p1);
@@ -202,13 +202,13 @@ void QIntersectionFinder::intersectBeziers(const QBezier &one, const QBezier &tw
qreal alpha_q = t.at(i).second;
QPointF pt;
- if (qFuzzyCompare(alpha_p + 1, 1)) {
+ if (qFuzzyIsNull(alpha_p)) {
pt = one.pt1();
- } else if (qFuzzyCompare(alpha_p, 1)) {
+ } else if (qFuzzyIsNull(alpha_p - 1)) {
pt = one.pt4();
- } else if (qFuzzyCompare(alpha_q + 1, 1)) {
+ } else if (qFuzzyIsNull(alpha_q)) {
pt = two.pt1();
- } else if (qFuzzyCompare(alpha_q, 1)) {
+ } else if (qFuzzyIsNull(alpha_q - 1)) {
pt = two.pt4();
} else {
pt = one.pointAt(alpha_p);
@@ -250,11 +250,11 @@ void QIntersectionFinder::intersectLines(const QLineF &a, const QLineF &b, QData
const qreal par = pDelta.x() * qDelta.y() - pDelta.y() * qDelta.x();
- if (qFuzzyCompare(par + 1, 1)) {
+ if (qFuzzyIsNull(par)) {
const QPointF normal(-pDelta.y(), pDelta.x());
// coinciding?
- if (qFuzzyCompare(dot(normal, q1 - p1) + 1, 1)) {
+ if (qFuzzyIsNull(dot(normal, q1 - p1))) {
const qreal invDp = 1 / dot(pDelta, pDelta);
const qreal tq1 = dot(pDelta, q1 - p1) * invDp;
@@ -315,11 +315,11 @@ void QIntersectionFinder::intersectLines(const QLineF &a, const QLineF &b, QData
if (tp<0 || tp>1 || tq<0 || tq>1)
return;
- const bool p_zero = qFuzzyCompare(tp + 1, 1);
- const bool p_one = qFuzzyCompare(tp, 1);
+ const bool p_zero = qFuzzyIsNull(tp);
+ const bool p_one = qFuzzyIsNull(tp - 1);
- const bool q_zero = qFuzzyCompare(tq + 1, 1);
- const bool q_one = qFuzzyCompare(tq, 1);
+ const bool q_zero = qFuzzyIsNull(tq);
+ const bool q_one = qFuzzyIsNull(tq - 1);
if ((q_zero || q_one) && (p_zero || p_one))
return;
@@ -922,7 +922,7 @@ qreal QWingedEdge::delta(int vertex, int a, int b) const
qreal result = b_angle - a_angle;
- if (qFuzzyCompare(result + 1, 1) || qFuzzyCompare(result, 128))
+ if (qFuzzyIsNull(result) || qFuzzyCompare(result, 128))
return 0;
if (result < 0)
@@ -951,7 +951,7 @@ static inline QPointF tangentAt(const QWingedEdge &list, int vi, int ei)
if (ep->bezier) {
normal = ep->bezier->derivedAt(t);
- if (qFuzzyCompare(normal.x() + 1, 1) && qFuzzyCompare(normal.y() + 1, 1))
+ if (qFuzzyIsNull(normal.x()) && qFuzzyIsNull(normal.y()))
normal = ep->bezier->secondDerivedAt(t);
} else {
const QPointF a = *list.vertex(ep->first);
@@ -1080,7 +1080,7 @@ QWingedEdge::TraversalStatus QWingedEdge::findInsertStatus(int vi, int ei) const
qDebug() << "Delta to edge" << status.edge << d2 << ", angles: " << op->angle << op->invAngle;
#endif
- if (!(qFuzzyCompare(d2 + 1, 1) && isLeftOf(*this, vi, status.edge, ei))
+ if (!(qFuzzyIsNull(d2) && isLeftOf(*this, vi, status.edge, ei))
&& (d2 < d || (qFuzzyCompare(d2, d) && isLeftOf(*this, vi, status.edge, position)))) {
position = status.edge;
d = d2;
@@ -1232,10 +1232,10 @@ int QWingedEdge::addEdge(int fi, int si, const QBezier *bezier, qreal t0, qreal
QPointF aTangent = bezier->derivedAt(t0);
QPointF bTangent = -bezier->derivedAt(t1);
- if (qFuzzyCompare(aTangent.x() + 1, 1) && qFuzzyCompare(aTangent.y() + 1, 1))
+ if (qFuzzyIsNull(aTangent.x()) && qFuzzyIsNull(aTangent.y()))
aTangent = bezier->secondDerivedAt(t0);
- if (qFuzzyCompare(bTangent.x() + 1, 1) && qFuzzyCompare(bTangent.y() + 1, 1))
+ if (qFuzzyIsNull(bTangent.x()) && qFuzzyIsNull(bTangent.y()))
bTangent = bezier->secondDerivedAt(t1);
ep->angle = computeAngle(aTangent);
@@ -1400,7 +1400,7 @@ static void addLineTo(QPainterPath &path, const QPointF &point)
const QPointF p(-d1.y(), d1.x());
- if (qFuzzyCompare(dot(p, d2) + 1, 1)) {
+ if (qFuzzyIsNull(dot(p, d2))) {
path.setElementPositionAt(elementCount - 1, point.x(), point.y());
return;
}
diff --git a/src/gui/painting/qprinter.cpp b/src/gui/painting/qprinter.cpp
index 6c309c7..4f3e71c 100644
--- a/src/gui/painting/qprinter.cpp
+++ b/src/gui/painting/qprinter.cpp
@@ -284,6 +284,10 @@ void QPrinterPrivate::addToManualSetList(QPrintEngine::PrintEnginePropertyKey ke
to send PostScript or 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.
+
+ Note that setting parameters like paper size and resolution on an
+ invalid printer is undefined. You can use QPrinter::isValid() to
+ verify this before changing any parameters.
QPrinter supports a number of parameters, most of which can be
changed by the end user through a \l{QPrintDialog}{print dialog}. In
diff --git a/src/gui/painting/qstroker.cpp b/src/gui/painting/qstroker.cpp
index b894c62..5fffc72 100644
--- a/src/gui/painting/qstroker.cpp
+++ b/src/gui/painting/qstroker.cpp
@@ -763,7 +763,7 @@ template <class Iterator> bool qt_stroke_side(Iterator *it,
qreal qt_t_for_arc_angle(qreal angle)
{
- if (qFuzzyCompare(angle + 1, qreal(1)))
+ if (qFuzzyIsNull(angle))
return 0;
if (qFuzzyCompare(angle, qreal(90)))
@@ -904,13 +904,13 @@ QPointF qt_curves_for_arc(const QRectF &rect, qreal startAngle, qreal sweepLengt
}
// avoid empty start segment
- if (qFuzzyCompare(startT, qreal(1))) {
+ if (qFuzzyIsNull(startT - qreal(1))) {
startT = 0;
startSegment += delta;
}
// avoid empty end segment
- if (qFuzzyCompare(endT + 1, qreal(1))) {
+ if (qFuzzyIsNull(endT)) {
endT = 1;
endSegment -= delta;
}
@@ -918,8 +918,8 @@ QPointF qt_curves_for_arc(const QRectF &rect, qreal startAngle, qreal sweepLengt
startT = qt_t_for_arc_angle(startT * 90);
endT = qt_t_for_arc_angle(endT * 90);
- const bool splitAtStart = !qFuzzyCompare(startT + 1, qreal(1));
- const bool splitAtEnd = !qFuzzyCompare(endT, qreal(1));
+ const bool splitAtStart = !qFuzzyIsNull(startT);
+ const bool splitAtEnd = !qFuzzyIsNull(endT - qreal(1));
const int end = endSegment + delta;
@@ -1018,7 +1018,7 @@ void QDashStroker::processCurrentSubpath()
sumLength += dashes[i];
}
- if (qFuzzyCompare(sumLength + 1, qreal(1)))
+ if (qFuzzyIsNull(sumLength))
return;
Q_ASSERT(dashCount > 0);
diff --git a/src/gui/painting/qtessellator.cpp b/src/gui/painting/qtessellator.cpp
index e02f02d..ce5ab74 100644
--- a/src/gui/painting/qtessellator.cpp
+++ b/src/gui/painting/qtessellator.cpp
@@ -1436,7 +1436,7 @@ void QTessellator::tessellateRect(const QPointF &a_, const QPointF &b_, qreal wi
QPointF perp(pb.y() - pa.y(), pa.x() - pb.x());
qreal length = qSqrt(perp.x() * perp.x() + perp.y() * perp.y());
- if (qFuzzyCompare(length + 1, static_cast<qreal>(1)))
+ if (qFuzzyIsNull(length))
return;
// need the half of the width
diff --git a/src/gui/painting/qtransform.cpp b/src/gui/painting/qtransform.cpp
index b25146d..d06107f 100644
--- a/src/gui/painting/qtransform.cpp
+++ b/src/gui/painting/qtransform.cpp
@@ -238,11 +238,11 @@ QT_BEGIN_NAMESPACE
\sa reset()
*/
QTransform::QTransform()
- : m_13(0), m_23(0), m_33(1)
+ : affine(true)
+ , m_13(0), m_23(0), m_33(1)
, m_type(TxNone)
, m_dirty(TxNone)
{
-
}
/*!
@@ -256,12 +256,11 @@ QTransform::QTransform()
QTransform::QTransform(qreal h11, qreal h12, qreal h13,
qreal h21, qreal h22, qreal h23,
qreal h31, qreal h32, qreal h33)
- : affine(h11, h12, h21, h22, h31, h32),
- m_13(h13), m_23(h23), m_33(h33)
+ : affine(h11, h12, h21, h22, h31, h32, true)
+ , m_13(h13), m_23(h23), m_33(h33)
, m_type(TxNone)
, m_dirty(TxProject)
{
-
}
/*!
@@ -273,12 +272,11 @@ QTransform::QTransform(qreal h11, qreal h12, qreal h13,
*/
QTransform::QTransform(qreal h11, qreal h12, qreal h21,
qreal h22, qreal dx, qreal dy)
- : affine(h11, h12, h21, h22, dx, dy),
- m_13(0), m_23(0), m_33(1)
+ : affine(h11, h12, h21, h22, dx, dy, true)
+ , m_13(0), m_23(0), m_33(1)
, m_type(TxNone)
, m_dirty(TxShear)
{
-
}
/*!
@@ -289,12 +287,11 @@ QTransform::QTransform(qreal h11, qreal h12, qreal h21,
and 1 respectively.
*/
QTransform::QTransform(const QMatrix &mtx)
- : affine(mtx),
+ : affine(mtx._m11, mtx._m12, mtx._m21, mtx._m22, mtx._dx, mtx._dy, true),
m_13(0), m_23(0), m_33(1)
, m_type(TxNone)
, m_dirty(TxShear)
{
-
}
/*!
@@ -317,7 +314,7 @@ QTransform QTransform::adjoint() const
return QTransform(h11, h12, h13,
h21, h22, h23,
- h31, h32, h33);
+ h31, h32, h33, true);
}
/*!
@@ -327,7 +324,7 @@ QTransform QTransform::transposed() const
{
QTransform t(affine._m11, affine._m21, affine._dx,
affine._m12, affine._m22, affine._dy,
- m_13, m_23, m_33);
+ m_13, m_23, m_33, true);
t.m_type = m_type;
t.m_dirty = m_dirty;
return t;
@@ -345,11 +342,10 @@ QTransform QTransform::transposed() const
*/
QTransform QTransform::inverted(bool *invertible) const
{
- QTransform invert;
+ QTransform invert(true);
bool inv = true;
- qreal det;
- switch(type()) {
+ switch(inline_type()) {
case TxNone:
break;
case TxTranslate:
@@ -357,11 +353,11 @@ QTransform QTransform::inverted(bool *invertible) const
invert.affine._dy = -affine._dy;
break;
case TxScale:
- inv = !qFuzzyCompare(affine._m11 + 1, 1);
- inv &= !qFuzzyCompare(affine._m22 + 1, 1);
+ inv = !qFuzzyIsNull(affine._m11);
+ inv &= !qFuzzyIsNull(affine._m22);
if (inv) {
- invert.affine._m11 = 1 / affine._m11;
- invert.affine._m22 = 1 / affine._m22;
+ invert.affine._m11 = 1. / affine._m11;
+ invert.affine._m22 = 1. / affine._m22;
invert.affine._dx = -affine._dx * invert.affine._m11;
invert.affine._dy = -affine._dy * invert.affine._m22;
}
@@ -372,8 +368,8 @@ QTransform QTransform::inverted(bool *invertible) const
break;
default:
// general case
- det = determinant();
- inv = !qFuzzyCompare(det + 1, 1);
+ qreal det = determinant();
+ inv = !qFuzzyIsNull(det);
if (inv)
invert = adjoint() / det;
break;
@@ -397,12 +393,12 @@ QTransform QTransform::inverted(bool *invertible) const
\sa setMatrix()
*/
-QTransform & QTransform::translate(qreal dx, qreal dy)
+QTransform &QTransform::translate(qreal dx, qreal dy)
{
if (dx == 0 && dy == 0)
return *this;
- switch(type()) {
+ switch(inline_type()) {
case TxNone:
affine._dx = dx;
affine._dy = dy;
@@ -437,7 +433,7 @@ QTransform & QTransform::translate(qreal dx, qreal dy)
*/
QTransform QTransform::fromTranslate(qreal dx, qreal dy)
{
- QTransform transform(1, 0, 0, 1, dx, dy);
+ QTransform transform(1, 0, 0, 0, 1, 0, dx, dy, 1, true);
if (dx == 0 && dy == 0)
transform.m_dirty = TxNone;
else
@@ -456,7 +452,7 @@ QTransform & QTransform::scale(qreal sx, qreal sy)
if (sx == 1 && sy == 1)
return *this;
- switch(type()) {
+ switch(inline_type()) {
case TxNone:
case TxTranslate:
affine._m11 = sx;
@@ -489,8 +485,8 @@ QTransform & QTransform::scale(qreal sx, qreal sy)
*/
QTransform QTransform::fromScale(qreal sx, qreal sy)
{
- QTransform transform(sx, 0, 0, sy, 0, 0);
- if (sx == 1 && sy == 1)
+ QTransform transform(sx, 0, 0, 0, sy, 0, 0, 0, 1, true);
+ if (sx == 1. && sy == 1.)
transform.m_dirty = TxNone;
else
transform.m_dirty = TxScale;
@@ -505,7 +501,7 @@ QTransform QTransform::fromScale(qreal sx, qreal sy)
*/
QTransform & QTransform::shear(qreal sh, qreal sv)
{
- switch(type()) {
+ switch(inline_type()) {
case TxNone:
case TxTranslate:
affine._m12 = sv;
@@ -574,7 +570,7 @@ QTransform & QTransform::rotate(qreal a, Qt::Axis axis)
}
if (axis == Qt::ZAxis) {
- switch(type()) {
+ switch(inline_type()) {
case TxNone:
case TxTranslate:
affine._m11 = cosa;
@@ -646,7 +642,7 @@ QTransform & QTransform::rotateRadians(qreal a, Qt::Axis axis)
qreal cosa = qCos(a);
if (axis == Qt::ZAxis) {
- switch(type()) {
+ switch(inline_type()) {
case TxNone:
case TxTranslate:
affine._m11 = cosa;
@@ -730,11 +726,11 @@ bool QTransform::operator!=(const QTransform &o) const
*/
QTransform & QTransform::operator*=(const QTransform &o)
{
- const TransformationType otherType = o.type();
+ const TransformationType otherType = o.inline_type();
if (otherType == TxNone)
return *this;
- const TransformationType thisType = type();
+ const TransformationType thisType = inline_type();
if (thisType == TxNone)
return operator=(o);
@@ -812,9 +808,77 @@ QTransform & QTransform::operator*=(const QTransform &o)
*/
QTransform QTransform::operator*(const QTransform &m) const
{
- QTransform result = *this;
- result *= m;
- return result;
+ const TransformationType otherType = m.inline_type();
+ if (otherType == TxNone)
+ return *this;
+
+ const TransformationType thisType = inline_type();
+ if (thisType == TxNone)
+ return m;
+
+ QTransform t(true);
+ TransformationType type = qMax(thisType, otherType);
+ switch(type) {
+ case TxNone:
+ break;
+ case TxTranslate:
+ t.affine._dx = affine._dx + m.affine._dx;
+ t.affine._dy += affine._dy + m.affine._dy;
+ break;
+ case TxScale:
+ {
+ qreal m11 = affine._m11*m.affine._m11;
+ qreal m22 = affine._m22*m.affine._m22;
+
+ qreal m31 = affine._dx*m.affine._m11 + m.affine._dx;
+ qreal m32 = affine._dy*m.affine._m22 + m.affine._dy;
+
+ t.affine._m11 = m11;
+ t.affine._m22 = m22;
+ t.affine._dx = m31; t.affine._dy = m32;
+ break;
+ }
+ case TxRotate:
+ case TxShear:
+ {
+ qreal m11 = affine._m11*m.affine._m11 + affine._m12*m.affine._m21;
+ qreal m12 = affine._m11*m.affine._m12 + affine._m12*m.affine._m22;
+
+ qreal m21 = affine._m21*m.affine._m11 + affine._m22*m.affine._m21;
+ qreal m22 = affine._m21*m.affine._m12 + affine._m22*m.affine._m22;
+
+ qreal m31 = affine._dx*m.affine._m11 + affine._dy*m.affine._m21 + m.affine._dx;
+ qreal m32 = affine._dx*m.affine._m12 + affine._dy*m.affine._m22 + m.affine._dy;
+
+ t.affine._m11 = m11; t.affine._m12 = m12;
+ t.affine._m21 = m21; t.affine._m22 = m22;
+ t.affine._dx = m31; t.affine._dy = m32;
+ break;
+ }
+ case TxProject:
+ {
+ qreal m11 = affine._m11*m.affine._m11 + affine._m12*m.affine._m21 + m_13*m.affine._dx;
+ qreal m12 = affine._m11*m.affine._m12 + affine._m12*m.affine._m22 + m_13*m.affine._dy;
+ qreal m13 = affine._m11*m.m_13 + affine._m12*m.m_23 + m_13*m.m_33;
+
+ qreal m21 = affine._m21*m.affine._m11 + affine._m22*m.affine._m21 + m_23*m.affine._dx;
+ qreal m22 = affine._m21*m.affine._m12 + affine._m22*m.affine._m22 + m_23*m.affine._dy;
+ qreal m23 = affine._m21*m.m_13 + affine._m22*m.m_23 + m_23*m.m_33;
+
+ qreal m31 = affine._dx*m.affine._m11 + affine._dy*m.affine._m21 + m_33*m.affine._dx;
+ qreal m32 = affine._dx*m.affine._m12 + affine._dy*m.affine._m22 + m_33*m.affine._dy;
+ qreal m33 = affine._dx*m.m_13 + affine._dy*m.m_23 + m_33*m.m_33;
+
+ t.affine._m11 = m11; t.affine._m12 = m12; t.m_13 = m13;
+ t.affine._m21 = m21; t.affine._m22 = m22; t.m_23 = m23;
+ t.affine._dx = m31; t.affine._dy = m32; t.m_33 = m33;
+ }
+ }
+
+ t.m_dirty = type;
+ t.m_type = type;
+
+ return t;
}
/*!
@@ -976,7 +1040,7 @@ QPoint QTransform::map(const QPoint &p) const
qreal x = 0, y = 0;
- TransformationType t = type();
+ TransformationType t = inline_type();
switch(t) {
case TxNone:
x = fx;
@@ -1027,7 +1091,7 @@ QPointF QTransform::map(const QPointF &p) const
qreal x = 0, y = 0;
- TransformationType t = type();
+ TransformationType t = inline_type();
switch(t) {
case TxNone:
x = fx;
@@ -1098,7 +1162,7 @@ QLine QTransform::map(const QLine &l) const
qreal x1 = 0, y1 = 0, x2 = 0, y2 = 0;
- TransformationType t = type();
+ TransformationType t = inline_type();
switch(t) {
case TxNone:
x1 = fx1;
@@ -1157,7 +1221,7 @@ QLineF QTransform::map(const QLineF &l) const
qreal x1 = 0, y1 = 0, x2 = 0, y2 = 0;
- TransformationType t = type();
+ TransformationType t = inline_type();
switch(t) {
case TxNone:
x1 = fx1;
@@ -1245,7 +1309,7 @@ static QPolygonF mapProjective(const QTransform &transform, const QPolygonF &pol
*/
QPolygonF QTransform::map(const QPolygonF &a) const
{
- TransformationType t = type();
+ TransformationType t = inline_type();
if (t <= TxTranslate)
return a.translated(affine._dx, affine._dy);
@@ -1275,7 +1339,7 @@ QPolygonF QTransform::map(const QPolygonF &a) const
*/
QPolygon QTransform::map(const QPolygon &a) const
{
- TransformationType t = type();
+ TransformationType t = inline_type();
if (t <= TxTranslate)
return a.translated(qRound(affine._dx), qRound(affine._dy));
@@ -1320,7 +1384,7 @@ extern QPainterPath qt_regionToPath(const QRegion &region);
*/
QRegion QTransform::map(const QRegion &r) const
{
- TransformationType t = type();
+ TransformationType t = inline_type();
if (t == TxNone)
return r;
if (t == TxTranslate) {
@@ -1343,7 +1407,7 @@ struct QHomogeneousCoordinate
QHomogeneousCoordinate(qreal x_, qreal y_, qreal w_) : x(x_), y(y_), w(w_) {}
const QPointF toPoint() const {
- qreal iw = 1 / w;
+ qreal iw = 1. / w;
return QPointF(x * iw, y * iw);
}
};
@@ -1481,7 +1545,7 @@ static QPainterPath mapProjective(const QTransform &transform, const QPainterPat
*/
QPainterPath QTransform::map(const QPainterPath &path) const
{
- TransformationType t = type();
+ TransformationType t = inline_type();
if (t == TxNone || path.isEmpty())
return path;
@@ -1526,7 +1590,7 @@ QPainterPath QTransform::map(const QPainterPath &path) const
*/
QPolygon QTransform::mapToPolygon(const QRect &rect) const
{
- TransformationType t = type();
+ TransformationType t = inline_type();
QPolygon a(4);
qreal x[4] = { 0, 0, 0, 0 }, y[4] = { 0, 0, 0, 0 };
@@ -1700,7 +1764,7 @@ void QTransform::setMatrix(qreal m11, qreal m12, qreal m13,
QRect QTransform::mapRect(const QRect &rect) const
{
- TransformationType t = type();
+ TransformationType t = inline_type();
if (t <= TxTranslate)
return rect.translated(qRound(affine._dx), qRound(affine._dy));
@@ -1720,13 +1784,12 @@ QRect QTransform::mapRect(const QRect &rect) const
return QRect(x, y, w, h);
} else if (t < TxProject) {
// see mapToPolygon for explanations of the algorithm.
- qreal x0 = 0, y0 = 0;
- qreal x, y;
- MAP(rect.left(), rect.top(), x0, y0);
- qreal xmin = x0;
- qreal ymin = y0;
- qreal xmax = x0;
- qreal ymax = y0;
+ qreal x = 0, y = 0;
+ MAP(rect.left(), rect.top(), x, y);
+ qreal xmin = x;
+ qreal ymin = y;
+ qreal xmax = x;
+ qreal ymax = y;
MAP(rect.right() + 1, rect.top(), x, y);
xmin = qMin(xmin, x);
ymin = qMin(ymin, y);
@@ -1771,7 +1834,7 @@ QRect QTransform::mapRect(const QRect &rect) const
*/
QRectF QTransform::mapRect(const QRectF &rect) const
{
- TransformationType t = type();
+ TransformationType t = inline_type();
if (t <= TxTranslate)
return rect.translated(affine._dx, affine._dy);
@@ -1790,13 +1853,12 @@ QRectF QTransform::mapRect(const QRectF &rect) const
}
return QRectF(x, y, w, h);
} else if (t < TxProject) {
- qreal x0 = 0, y0 = 0;
- qreal x, y;
- MAP(rect.x(), rect.y(), x0, y0);
- qreal xmin = x0;
- qreal ymin = y0;
- qreal xmax = x0;
- qreal ymax = y0;
+ qreal x = 0, y = 0;
+ MAP(rect.x(), rect.y(), x, y);
+ qreal xmin = x;
+ qreal ymin = y;
+ qreal xmax = x;
+ qreal ymax = y;
MAP(rect.x() + rect.width(), rect.y(), x, y);
xmin = qMin(xmin, x);
ymin = qMin(ymin, y);
@@ -1846,7 +1908,7 @@ QRectF QTransform::mapRect(const QRectF &rect) const
*/
void QTransform::map(qreal x, qreal y, qreal *tx, qreal *ty) const
{
- TransformationType t = type();
+ TransformationType t = inline_type();
MAP(x, y, *tx, *ty);
}
@@ -1860,7 +1922,7 @@ void QTransform::map(qreal x, qreal y, qreal *tx, qreal *ty) const
*/
void QTransform::map(int x, int y, int *tx, int *ty) const
{
- TransformationType t = type();
+ TransformationType t = inline_type();
qreal fx = 0, fy = 0;
MAP(x, y, fx, fy);
*tx = qRound(fx);
@@ -1889,25 +1951,41 @@ const QMatrix &QTransform::toAffine() const
*/
QTransform::TransformationType QTransform::type() const
{
- if (m_dirty >= m_type) {
- if (m_dirty > TxShear && (!qFuzzyCompare(m_13 + 1, 1) || !qFuzzyCompare(m_23 + 1, 1)))
+ if(m_dirty == TxNone || m_dirty < m_type)
+ return static_cast<TransformationType>(m_type);
+
+ switch (static_cast<TransformationType>(m_dirty)) {
+ case TxProject:
+ if (!qFuzzyIsNull(m_13) || !qFuzzyIsNull(m_23) || !qFuzzyIsNull(m_33 - 1)) {
m_type = TxProject;
- else if (m_dirty > TxScale && (!qFuzzyCompare(affine._m12 + 1, 1) || !qFuzzyCompare(affine._m21 + 1, 1))) {
+ break;
+ }
+ case TxShear:
+ case TxRotate:
+ if (!qFuzzyIsNull(affine._m12) || !qFuzzyIsNull(affine._m21)) {
const qreal dot = affine._m11 * affine._m12 + affine._m21 * affine._m22;
- if (qFuzzyCompare(dot + 1, 1))
+ if (qFuzzyIsNull(dot))
m_type = TxRotate;
else
m_type = TxShear;
- } else if (m_dirty > TxTranslate && (!qFuzzyCompare(affine._m11, 1) || !qFuzzyCompare(affine._m22, 1) || !qFuzzyCompare(m_33, 1)))
+ break;
+ }
+ case TxScale:
+ if (!qFuzzyIsNull(affine._m11 - 1) || !qFuzzyIsNull(affine._m22 - 1)) {
m_type = TxScale;
- else if (m_dirty > TxNone && (!qFuzzyCompare(affine._dx + 1, 1) || !qFuzzyCompare(affine._dy + 1, 1)))
+ break;
+ }
+ case TxTranslate:
+ if (!qFuzzyIsNull(affine._dx) || !qFuzzyIsNull(affine._dy)) {
m_type = TxTranslate;
- else
- m_type = TxNone;
-
- m_dirty = TxNone;
+ break;
+ }
+ case TxNone:
+ m_type = TxNone;
+ break;
}
+ m_dirty = TxNone;
return static_cast<TransformationType>(m_type);
}
diff --git a/src/gui/painting/qtransform.h b/src/gui/painting/qtransform.h
index c76409b..aac7c31 100644
--- a/src/gui/painting/qtransform.h
+++ b/src/gui/painting/qtransform.h
@@ -159,6 +159,19 @@ public:
static QTransform fromScale(qreal dx, qreal dy);
private:
+ inline QTransform(qreal h11, qreal h12, qreal h13,
+ qreal h21, qreal h22, qreal h23,
+ qreal h31, qreal h32, qreal h33, bool)
+ : affine(h11, h12, h21, h22, h31, h32, true)
+ , m_13(h13), m_23(h23), m_33(h33)
+ , m_type(TxNone)
+ , m_dirty(TxProject) {}
+ inline QTransform(bool)
+ : affine(true)
+ , m_13(0), m_23(0), m_33(1)
+ , m_type(TxNone)
+ , m_dirty(TxNone) {}
+ inline TransformationType inline_type() const;
QMatrix affine;
qreal m_13;
qreal m_23;
@@ -173,18 +186,25 @@ private:
Q_DECLARE_TYPEINFO(QTransform, Q_MOVABLE_TYPE);
/******* inlines *****/
+inline QTransform::TransformationType QTransform::inline_type() const
+{
+ if (m_dirty == TxNone)
+ return static_cast<TransformationType>(m_type);
+ return type();
+}
+
inline bool QTransform::isAffine() const
{
- return type() < TxProject;
+ return inline_type() < TxProject;
}
inline bool QTransform::isIdentity() const
{
- return type() == TxNone;
+ return inline_type() == TxNone;
}
inline bool QTransform::isInvertible() const
{
- return !qFuzzyCompare(determinant() + 1, 1);
+ return !qFuzzyIsNull(determinant());
}
inline bool QTransform::isScaling() const
@@ -193,12 +213,12 @@ inline bool QTransform::isScaling() const
}
inline bool QTransform::isRotating() const
{
- return type() >= TxRotate;
+ return inline_type() >= TxRotate;
}
inline bool QTransform::isTranslating() const
{
- return type() >= TxTranslate;
+ return inline_type() >= TxTranslate;
}
inline qreal QTransform::determinant() const
diff --git a/src/gui/painting/qwindowsurface.cpp b/src/gui/painting/qwindowsurface.cpp
index bcb0380..d941a24 100644
--- a/src/gui/painting/qwindowsurface.cpp
+++ b/src/gui/painting/qwindowsurface.cpp
@@ -310,10 +310,13 @@ void qt_scrollRectInImage(QImage &img, const QRect &rect, const QPoint &offset)
int lineskip = img.bytesPerLine();
int depth = img.depth() >> 3;
-
- const QRect r = rect & QRect(0, 0, img.width(), img.height());
+ 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;
diff --git a/src/gui/styles/gtksymbols.cpp b/src/gui/styles/gtksymbols.cpp
index 8123d32..acb8437 100644
--- a/src/gui/styles/gtksymbols.cpp
+++ b/src/gui/styles/gtksymbols.cpp
@@ -504,13 +504,6 @@ static QPalette gtkWidgetPalette(const QString &gtkWidgetName)
pal.setBrush(QPalette::Disabled, QPalette::WindowText, disabledTextColor);
pal.setBrush(QPalette::All, QPalette::ButtonText, textColor);
pal.setBrush(QPalette::Disabled, QPalette::ButtonText, disabledTextColor);
- if (gtkWidgetName == QLS("GtkMenu")) {
- // This really applies to the combo box rendering since
- // QComboBox copies the palette from a QMenu
- GdkColor gdkBg = gtkWidget->style->bg[GTK_STATE_NORMAL];
- QColor bgColor(gdkBg.red>>8, gdkBg.green>>8, gdkBg.blue>>8);
- pal.setBrush(QPalette::Base, bgColor);
- }
return pal;
}
@@ -528,6 +521,7 @@ void QGtk::applyCustomPaletteHash()
GdkColor gdkBg = QGtk::gtkWidget(QLS("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(QLS("GtkToolbar"));
@@ -555,6 +549,7 @@ void QGtkStyleUpdateScheduler::updateTheme()
QPalette newPalette = qApp->style()->standardPalette();
QApplicationPrivate::setSystemPalette(newPalette);
QApplication::setPalette(newPalette);
+ QGtk::initGtkWidgets();
QGtk::applyCustomPaletteHash();
QList<QWidget*> widgets = QApplication::allWidgets();
// Notify all widgets that size metrics might have changed
diff --git a/src/gui/styles/qgtkstyle.cpp b/src/gui/styles/qgtkstyle.cpp
index 6354ce7..b7fa575 100644
--- a/src/gui/styles/qgtkstyle.cpp
+++ b/src/gui/styles/qgtkstyle.cpp
@@ -977,7 +977,7 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
if (widget && widget->testAttribute(Qt::WA_SetPalette) &&
resolve_mask & (1 << QPalette::Base)) // Palette overridden by user
- painter->fillRect(textRect, option->palette.base().color());
+ 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);
@@ -2507,6 +2507,10 @@ void QGtkStyle::drawControl(ControlElement element,
if (selected) {
QRect rect = option->rect.adjusted(0, 0, -1, -1);
+#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);
}
@@ -2634,7 +2638,7 @@ void QGtkStyle::drawControl(ControlElement element,
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);;
+ disabledTextColor = option->palette.brush(QPalette::Disabled, QPalette::ButtonText).color();
}
QColor highlightedTextColor = QColor(gdkHText.red>>8, gdkHText.green>>8, gdkHText.blue>>8);
@@ -2756,10 +2760,13 @@ void QGtkStyle::drawControl(ControlElement element,
if (tab->state & State_Selected)
state = GTK_STATE_NORMAL;
- bool first = tab->position == QStyleOptionTab::Beginning || tab->position == QStyleOptionTab::OnlyOneTab;
- bool last = tab->position == QStyleOptionTab::End || tab->position == QStyleOptionTab::OnlyOneTab;
bool selected = (tab->state & State_Selected);
- if (option->direction == Qt::RightToLeft) {
+ 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;
diff --git a/src/gui/styles/qwindowsmobilestyle.cpp b/src/gui/styles/qwindowsmobilestyle.cpp
index c52c700..1c03b9e 100644
--- a/src/gui/styles/qwindowsmobilestyle.cpp
+++ b/src/gui/styles/qwindowsmobilestyle.cpp
@@ -3401,6 +3401,9 @@ int QWindowsMobileStyle::styleHint(StyleHint hint, const QStyleOption *opt, cons
case SH_ScrollBar_ContextMenu:
ret = false;
break;
+ case SH_MenuBar_AltKeyNavigation:
+ ret = false;
+ break;
default:
ret = QWindowsStyle::styleHint(hint, opt, widget, returnData);
break;
diff --git a/src/gui/styles/qwindowsvistastyle.cpp b/src/gui/styles/qwindowsvistastyle.cpp
index 4c3060d..013ca1e 100644
--- a/src/gui/styles/qwindowsvistastyle.cpp
+++ b/src/gui/styles/qwindowsvistastyle.cpp
@@ -801,12 +801,20 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt
if (vopt->viewItemPosition == QStyleOptionViewItemV4::OnlyOne
|| vopt->viewItemPosition == QStyleOptionViewItemV4::Invalid)
painter->drawPixmap(pixmapRect.topLeft(), pixmap);
- else if (reverse ? rightSection : leftSection)
- painter->drawPixmap(pixmapRect, pixmap, srcRect.adjusted(0, 0, -frame, 0));
- else if (reverse ? leftSection : rightSection)
- painter->drawPixmap(pixmapRect, pixmap,
- srcRect.adjusted(frame, 0, 0, 0));
- else if (vopt->viewItemPosition == QStyleOptionViewItemV4::Middle)
+ else if (reverse ? rightSection : leftSection){
+ painter->drawPixmap(QRect(pixmapRect.topLeft(),
+ QSize(frame, pixmapRect.height())), pixmap,
+ QRect(QPoint(0, 0), QSize(frame, pixmapRect.height())));
+ painter->drawPixmap(pixmapRect.adjusted(frame, 0, 0, 0),
+ pixmap, srcRect.adjusted(frame, 0, -frame, 0));
+ } else if (reverse ? leftSection : rightSection) {
+ painter->drawPixmap(QRect(pixmapRect.topRight() - QPoint(frame - 1, 0),
+ QSize(frame, pixmapRect.height())), pixmap,
+ QRect(QPoint(pixmapRect.width() - frame, 0),
+ QSize(frame, pixmapRect.height())));
+ painter->drawPixmap(pixmapRect.adjusted(0, 0, -frame, 0),
+ pixmap, srcRect.adjusted(frame, 0, -frame, 0));
+ } else if (vopt->viewItemPosition == QStyleOptionViewItemV4::Middle)
painter->drawPixmap(pixmapRect, pixmap,
srcRect.adjusted(frame, 0, -frame, 0));
} else {
@@ -2388,6 +2396,9 @@ void QWindowsVistaStyle::polish(QWidget *widget)
else if (QTreeView *tree = qobject_cast<QTreeView *> (widget)) {
tree->viewport()->setAttribute(Qt::WA_Hover);
}
+ else if (QListView *list = qobject_cast<QListView *> (widget)) {
+ list->viewport()->setAttribute(Qt::WA_Hover);
+ }
}
/*!
diff --git a/src/gui/styles/qwindowsvistastyle_p.h b/src/gui/styles/qwindowsvistastyle_p.h
index 877bc50..cef2b71 100644
--- a/src/gui/styles/qwindowsvistastyle_p.h
+++ b/src/gui/styles/qwindowsvistastyle_p.h
@@ -76,6 +76,7 @@
#include <qscrollbar.h>
#include <qprogressbar.h>
#include <qdockwidget.h>
+#include <qlistview.h>
#include <qtreeview.h>
#include <qtextedit.h>
#include <qmessagebox.h>
diff --git a/src/gui/styles/qwindowsxpstyle.cpp b/src/gui/styles/qwindowsxpstyle.cpp
index 50cd13f..639eff0 100644
--- a/src/gui/styles/qwindowsxpstyle.cpp
+++ b/src/gui/styles/qwindowsxpstyle.cpp
@@ -608,7 +608,7 @@ void QWindowsXPStylePrivate::drawBackground(XPThemeData &themeData)
QPainter *painter = themeData.painter;
Q_ASSERT_X(painter != 0, "QWindowsXPStylePrivate::drawBackground()", "Trying to draw a theme part without a painter");
- if (!painter)
+ if (!painter || !painter->isActive())
return;
painter->save();
@@ -2835,7 +2835,7 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo
bflags |= State_MouseOver;
}
}
-
+
QStyleOption tool(0);
tool.palette = toolbutton->palette;
if (toolbutton->subControls & SC_ToolButton) {
diff --git a/src/gui/text/qfontengine_mac.mm b/src/gui/text/qfontengine_mac.mm
index 425cab2..6b5bd0f 100644
--- a/src/gui/text/qfontengine_mac.mm
+++ b/src/gui/text/qfontengine_mac.mm
@@ -135,12 +135,12 @@ QCoreTextFontEngineMulti::QCoreTextFontEngineMulti(const ATSFontFamilyRef &, con
symbolicTraits |= kCTFontItalicTrait;
break;
}
-
+
QCFString name;
ATSFontGetName(atsFontRef, kATSOptionFlagsDefault, &name);
- QCFType<CTFontDescriptorRef> descriptor = CTFontDescriptorCreateWithNameAndSize(name, fontDef.pixelSize);
- QCFType<CTFontRef> baseFont = CTFontCreateWithFontDescriptor(descriptor, fontDef.pixelSize, 0);
- ctfont = CTFontCreateCopyWithSymbolicTraits(baseFont, fontDef.pixelSize, 0, symbolicTraits, symbolicTraits);
+ QCFType<CTFontDescriptorRef> descriptor = CTFontDescriptorCreateWithNameAndSize(name, fontDef.pointSize);
+ QCFType<CTFontRef> baseFont = CTFontCreateWithFontDescriptor(descriptor, fontDef.pointSize, 0);
+ ctfont = CTFontCreateCopyWithSymbolicTraits(baseFont, fontDef.pointSize, 0, symbolicTraits, symbolicTraits);
// CTFontCreateCopyWithSymbolicTraits returns NULL if we ask for a trait that does
// not exist for the given font. (for example italic)
@@ -162,7 +162,7 @@ QCoreTextFontEngineMulti::QCoreTextFontEngineMulti(const ATSFontFamilyRef &, con
QCoreTextFontEngine *fe = new QCoreTextFontEngine(ctfont, fontDef, this);
fe->ref.ref();
engines.append(fe);
-
+
}
QCoreTextFontEngineMulti::~QCoreTextFontEngineMulti()
@@ -176,7 +176,7 @@ uint QCoreTextFontEngineMulti::fontIndexForFont(CTFontRef id) const
if (CFEqual(engineAt(i)->ctfont, id))
return i;
}
-
+
QCoreTextFontEngineMulti *that = const_cast<QCoreTextFontEngineMulti *>(this);
QCoreTextFontEngine *fe = new QCoreTextFontEngine(id, fontDef, that);
fe->ref.ref();
@@ -227,7 +227,7 @@ bool QCoreTextFontEngineMulti::stringToCMap(const QChar *str, int len, QGlyphLay
CTFontRef runFont = static_cast<CTFontRef>(CFDictionaryGetValue(runAttribs, NSFontAttributeName));
const uint fontIndex = (fontIndexForFont(runFont) << 24);
//NSLog(@"Run Font Name = %@", CTFontCopyFamilyName(runFont));
- QVarLengthArray<CGGlyph, 512> cgglyphs(0);
+ QVarLengthArray<CGGlyph, 512> cgglyphs(0);
const CGGlyph *tmpGlyphs = CTRunGetGlyphsPtr(run);
if (!tmpGlyphs) {
cgglyphs.resize(glyphCount);
@@ -260,7 +260,7 @@ bool QCoreTextFontEngineMulti::stringToCMap(const QChar *str, int len, QGlyphLay
CFIndex k = 0;
CFIndex i = 0;
- for (i = stringRange.location;
+ for (i = stringRange.location;
(i < stringRange.location + stringRange.length) && (k < glyphCount); ++i) {
if (tmpIndices[k * rtlSign + rtlOffset] == i || i == stringRange.location) {
logClusters[i] = k + firstGlyphIndex;
@@ -425,28 +425,28 @@ void QCoreTextFontEngine::draw(CGContextRef ctx, qreal x, qreal y, const QTextIt
getGlyphPositions(ti.glyphs, matrix, ti.flags, glyphs, positions);
if (glyphs.size() == 0)
return;
-
+
CGContextSetFontSize(ctx, fontDef.pixelSize);
-
+
CGAffineTransform oldTextMatrix = CGContextGetTextMatrix(ctx);
-
+
CGAffineTransform cgMatrix = CGAffineTransformMake(1, 0, 0, -1, 0, -paintDeviceHeight);
-
+
CGAffineTransformConcat(cgMatrix, oldTextMatrix);
-
+
if (synthesisFlags & QFontEngine::SynthesizedItalic)
cgMatrix = CGAffineTransformConcat(cgMatrix, CGAffineTransformMake(1, 0, -tanf(14 * acosf(0) / 90), 1, 0, 0));
-
+
// ### cgMatrix = CGAffineTransformConcat(cgMatrix, transform);
-
+
CGContextSetTextMatrix(ctx, cgMatrix);
-
+
CGContextSetTextDrawingMode(ctx, kCGTextFill);
-
-
+
+
QVarLengthArray<CGSize> advances(glyphs.size());
QVarLengthArray<CGGlyph> cgGlyphs(glyphs.size());
-
+
for (int i = 0; i < glyphs.size() - 1; ++i) {
advances[i].width = (positions[i + 1].x - positions[i].x).toReal();
advances[i].height = (positions[i + 1].y - positions[i].y).toReal();
@@ -455,21 +455,21 @@ void QCoreTextFontEngine::draw(CGContextRef ctx, qreal x, qreal y, const QTextIt
advances[glyphs.size() - 1].width = 0;
advances[glyphs.size() - 1].height = 0;
cgGlyphs[glyphs.size() - 1] = glyphs[glyphs.size() - 1];
-
+
CGContextSetFont(ctx, cgFont);
//NSLog(@"Font inDraw %@ ctfont %@", CGFontCopyFullName(cgFont), CTFontCopyFamilyName(ctfont));
-
+
CGContextSetTextPosition(ctx, positions[0].x.toReal(), positions[0].y.toReal());
-
+
CGContextShowGlyphsWithAdvances(ctx, cgGlyphs.data(), advances.data(), glyphs.size());
-
+
if (synthesisFlags & QFontEngine::SynthesizedBold) {
CGContextSetTextPosition(ctx, positions[0].x.toReal() + 0.5 * lineThickness().toReal(),
positions[0].y.toReal());
-
+
CGContextShowGlyphsWithAdvances(ctx, cgGlyphs.data(), advances.data(), glyphs.size());
}
-
+
CGContextSetTextMatrix(ctx, oldTextMatrix);
}
@@ -622,7 +622,7 @@ QFontEngine::FaceId QCoreTextFontEngine::faceId() const
bool QCoreTextFontEngine::canRender(const QChar *string, int len)
{
- QCFType<CTFontRef> retFont = CTFontCreateForString(ctfont,
+ QCFType<CTFontRef> retFont = CTFontCreateForString(ctfont,
QCFType<CFStringRef>(CFStringCreateWithCharactersNoCopy(0,
reinterpret_cast<const UniChar *>(string),
len, kCFAllocatorNull)),
@@ -672,7 +672,7 @@ QFontEngineMacMulti::QFontEngineMacMulti(const ATSFontFamilyRef &atsFamily, cons
} else {
if (fontDef.weight >= QFont::Bold)
fntStyle |= ::bold;
- if (fontDef.style != QFont::StyleNormal)
+ if (fontDef.style != QFont::StyleNormal)
fntStyle |= ::italic;
FMFontStyle intrinsicStyle;
@@ -955,7 +955,7 @@ bool QFontEngineMacMulti::stringToCMap(const QChar *str, int len, QGlyphLayout *
tmpItem.length = charCount;
tmpItem.glyphs = shaperItem.glyphs.mid(glyphIdx, glyphCount);
tmpItem.log_clusters = shaperItem.log_clusters + charIdx;
- if (!stringToCMapInternal(tmpItem.string + tmpItem.from, tmpItem.length,
+ if (!stringToCMapInternal(tmpItem.string + tmpItem.from, tmpItem.length,
&tmpItem.glyphs, &glyphCount, flags,
&tmpItem)) {
*nglyphs = glyphIdx + glyphCount;
@@ -1221,12 +1221,12 @@ QFontEngineMac::QFontEngineMac(ATSUStyle baseStyle, ATSUFontID fontID, const QFo
transform = multiEngine->transform;
else
transform = CGAffineTransformIdentity;
-
+
ATSUTextMeasurement metric;
ATSUGetAttribute(style, kATSUAscentTag, sizeof(metric), &metric, 0);
m_ascent = FixRound(metric);
-
+
ATSUGetAttribute(style, kATSUDescentTag, sizeof(metric), &metric, 0);
m_descent = FixRound(metric);
@@ -1422,11 +1422,16 @@ void QFontEngineMac::addGlyphsToPath(glyph_t *glyphs, QFixedPoint *positions, in
addGlyphsToPathHelper(style, glyphs, positions, numGlyphs, path);
}
-QImage QFontEngineMac::alphaMapForGlyph(glyph_t glyph)
+
+/*!
+ Helper function for alphaMapForGlyph and alphaRGBMapForGlyph. The two are identical, except for
+ the subpixel antialiasing...
+*/
+QImage QFontEngineMac::imageForGlyph(glyph_t glyph, int margin, bool colorful)
{
const glyph_metrics_t br = boundingBox(glyph);
QImage im(qRound(br.width)+2, qRound(br.height)+4, QImage::Format_RGB32);
- im.fill(0);
+ im.fill(0xff000000);
CGColorSpaceRef colorspace = QCoreGraphicsPaintEngine::macGenericColorSpace();
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4)
@@ -1444,7 +1449,7 @@ QImage QFontEngineMac::alphaMapForGlyph(glyph_t glyph)
CGContextSetFontSize(ctx, fontDef.pixelSize);
CGContextSetShouldAntialias(ctx, fontDef.pointSize > qt_antialiasing_threshold && !(fontDef.styleStrategy & QFont::NoAntialias));
// turn off sub-pixel hinting - no support for that in OpenGL
- CGContextSetShouldSmoothFonts(ctx, false);
+ CGContextSetShouldSmoothFonts(ctx, colorful);
CGAffineTransform oldTextMatrix = CGContextGetTextMatrix(ctx);
CGAffineTransform cgMatrix = CGAffineTransformMake(1, 0, 0, 1, 0, 0);
CGAffineTransformConcat(cgMatrix, oldTextMatrix);
@@ -1476,6 +1481,13 @@ QImage QFontEngineMac::alphaMapForGlyph(glyph_t glyph)
CGContextRelease(ctx);
+ return im;
+}
+
+QImage QFontEngineMac::alphaMapForGlyph(glyph_t glyph)
+{
+ QImage im = imageForGlyph(glyph, 2, false);
+
QImage indexed(im.width(), im.height(), QImage::Format_Indexed8);
QVector<QRgb> colors(256);
for (int i=0; i<256; ++i)
@@ -1495,6 +1507,32 @@ QImage QFontEngineMac::alphaMapForGlyph(glyph_t glyph)
return indexed;
}
+QImage QFontEngineMac::alphaRGBMapForGlyph(glyph_t glyph, int margin, const QTransform &t)
+{
+ QImage im = imageForGlyph(glyph, margin, true);
+
+ if (t.type() >= QTransform::TxScale) {
+ im = im.transformed(t);
+ }
+
+ extern uchar qt_pow_rgb_gamma[256];
+
+ // gamma correct the pixels back to linear color space...
+ for (int y=0; y<im.height(); ++y) {
+ uint *pixels = (uint *) im.scanLine(y);
+ for (int x=0; x<im.width(); ++x) {
+ uint p = pixels[x];
+ uint r = qt_pow_rgb_gamma[qRed(p)];
+ uint g = qt_pow_rgb_gamma[qGreen(p)];
+ uint b = qt_pow_rgb_gamma[qBlue(p)];
+ pixels[x] = (r << 16) | (g << 8) | b | 0xff000000;
+ }
+ }
+
+ return im;
+}
+
+
bool QFontEngineMac::canRender(const QChar *string, int len)
{
Q_ASSERT(false);
@@ -1648,7 +1686,7 @@ QFontEngine::Properties QFontEngineMac::properties() const
if (ATSFontGetTable(atsFont, MAKE_TAG('p', 'o', 's', 't'), 10, 2, &lw, 0) == noErr)
lw = qFromBigEndian<quint16>(lw);
props.lineWidth = lw;
-
+
// CTFontCopyPostScriptName
QCFString psName;
if (ATSFontGetPostScriptName(FMGetATSFontRefFromFont(fontID), kATSOptionFlagsDefault, &psName) == noErr)
@@ -1663,7 +1701,7 @@ void QFontEngineMac::getUnscaledGlyph(glyph_t glyph, QPainterPath *path, glyph_m
ATSUCreateAndCopyStyle(style, &unscaledStyle);
int emSquare = properties().emSquare.toInt();
-
+
const int maxAttributeCount = 4;
ATSUAttributeTag tags[maxAttributeCount + 1];
ByteCount sizes[maxAttributeCount + 1];
@@ -1675,7 +1713,7 @@ void QFontEngineMac::getUnscaledGlyph(glyph_t glyph, QPainterPath *path, glyph_m
sizes[attributeCount] = sizeof(size);
values[attributeCount] = &size;
++attributeCount;
-
+
Q_ASSERT(attributeCount < maxAttributeCount + 1);
OSStatus err = ATSUSetAttributes(unscaledStyle, attributeCount, tags, sizes, values);
Q_ASSERT(err == noErr);
diff --git a/src/gui/text/qfontengine_p.h b/src/gui/text/qfontengine_p.h
index 176c728..8f6b92a 100644
--- a/src/gui/text/qfontengine_p.h
+++ b/src/gui/text/qfontengine_p.h
@@ -525,8 +525,11 @@ public:
virtual Properties properties() const;
virtual void getUnscaledGlyph(glyph_t glyph, QPainterPath *path, glyph_metrics_t *metrics);
virtual QImage alphaMapForGlyph(glyph_t);
+ virtual QImage alphaRGBMapForGlyph(glyph_t, int margin, const QTransform &t);
private:
+ QImage imageForGlyph(glyph_t glyph, int margin, bool colorful);
+
ATSUFontID fontID;
QCFType<CGFontRef> cgFont;
ATSUStyle style;
diff --git a/src/gui/widgets/qabstractbutton.cpp b/src/gui/widgets/qabstractbutton.cpp
index c25253a..f2a9ceb 100644
--- a/src/gui/widgets/qabstractbutton.cpp
+++ b/src/gui/widgets/qabstractbutton.cpp
@@ -1250,15 +1250,6 @@ void QAbstractButton::timerEvent(QTimerEvent *e)
}
}
-#if defined(Q_OS_WINCE) && !defined(QT_NO_CONTEXTMENU)
-/*! \reimp */
-void QAbstractButton::contextMenuEvent(QContextMenuEvent *e)
-{
- e->ignore();
- setDown(false);
-}
-#endif
-
/*! \reimp */
void QAbstractButton::focusInEvent(QFocusEvent *e)
{
diff --git a/src/gui/widgets/qabstractbutton.h b/src/gui/widgets/qabstractbutton.h
index 6503a56..f0cbb05 100644
--- a/src/gui/widgets/qabstractbutton.h
+++ b/src/gui/widgets/qabstractbutton.h
@@ -143,9 +143,6 @@ protected:
void focusOutEvent(QFocusEvent *e);
void changeEvent(QEvent *e);
void timerEvent(QTimerEvent *e);
-#ifdef Q_OS_WINCE
- void contextMenuEvent(QContextMenuEvent *e);
-#endif
#ifdef QT3_SUPPORT
public:
diff --git a/src/gui/widgets/qcocoamenu_mac.mm b/src/gui/widgets/qcocoamenu_mac.mm
index c92dfc0..6434289 100644
--- a/src/gui/widgets/qcocoamenu_mac.mm
+++ b/src/gui/widgets/qcocoamenu_mac.mm
@@ -1,11 +1,11 @@
/****************************************************************************
- **
- ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
- **
- ** This file is part of the QtGui module of the Qt Toolkit.
- **
- ** $QT_BEGIN_LICENSE:LGPL$
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
@@ -36,11 +36,11 @@
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
** $QT_END_LICENSE$
- **
- ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- **
- ****************************************************************************/
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+****************************************************************************/
#include "qmacdefines_mac.h"
#include "qapplication.h"
@@ -55,11 +55,17 @@
QT_FORWARD_DECLARE_CLASS(QAction)
QT_FORWARD_DECLARE_CLASS(QWidget)
QT_FORWARD_DECLARE_CLASS(QApplication)
+QT_FORWARD_DECLARE_CLASS(QCoreApplication)
+QT_FORWARD_DECLARE_CLASS(QApplicationPrivate)
+QT_FORWARD_DECLARE_CLASS(QKeyEvent)
+QT_FORWARD_DECLARE_CLASS(QEvent)
QT_BEGIN_NAMESPACE
extern bool qt_sendSpontaneousEvent(QObject*, QEvent*); //qapplication.cpp
QT_END_NAMESPACE
+QT_USE_NAMESPACE
+
@implementation QT_MANGLE_NAMESPACE(QCocoaMenu)
- (id)initWithQMenu:(QMenu*)menu
@@ -134,8 +140,9 @@ QT_END_NAMESPACE
// If it does, then we will first send the key sequence to the QWidget that has focus
// since (in Qt's eyes) it needs to a chance at the key event first. If the widget
// accepts the key event, we then return YES, but set the target and action to be nil,
- // which means that the action should not be triggered. In every other case we return
- // NO, which means that Cocoa can do as it pleases (i.e., fire the menu action).
+ // which means that the action should not be triggered, and instead dispatch the event ourselves.
+ // In every other case we return NO, which means that Cocoa can do as it pleases
+ // (i.e., fire the menu action).
NSMenuItem *whichItem;
if ([self hasShortcut:menu
forKey:[event characters]
@@ -158,9 +165,11 @@ QT_END_NAMESPACE
accel_ev.ignore();
qt_sendSpontaneousEvent(widget, &accel_ev);
if (accel_ev.isAccepted()) {
- *target = nil;
- *action = nil;
- return YES;
+ if (qt_dispatchKeyEvent(event, widget)) {
+ *target = nil;
+ *action = nil;
+ return YES;
+ }
}
}
}
diff --git a/src/gui/widgets/qcombobox.cpp b/src/gui/widgets/qcombobox.cpp
index 09a51fe..f30ece4 100644
--- a/src/gui/widgets/qcombobox.cpp
+++ b/src/gui/widgets/qcombobox.cpp
@@ -949,6 +949,7 @@ QComboBoxPrivateContainer* QComboBoxPrivate::viewContainer()
container->itemView()->setTextElideMode(Qt::ElideMiddle);
updateDelegate();
updateLayoutDirection();
+ updateViewContainerPaletteAndOpacity();
QObject::connect(container, SIGNAL(itemSelected(QModelIndex)),
q, SLOT(_q_itemSelected(QModelIndex)));
QObject::connect(container->itemView()->selectionModel(),
@@ -1051,6 +1052,27 @@ void QComboBoxPrivate::_q_rowsRemoved(const QModelIndex &parent, int /*start*/,
}
+void QComboBoxPrivate::updateViewContainerPaletteAndOpacity()
+{
+ if (!container)
+ return;
+ Q_Q(QComboBox);
+ QStyleOptionComboBox opt;
+ q->initStyleOption(&opt);
+#ifndef QT_NO_MENU
+ if (q->style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, q)) {
+ QMenu menu;
+ menu.ensurePolished();
+ container->setPalette(menu.palette());
+ container->setWindowOpacity(menu.windowOpacity());
+ } else
+#endif
+ {
+ container->setPalette(q->palette());
+ container->setWindowOpacity(1.0);
+ }
+}
+
/*!
Initialize \a option with the values from this QComboBox. This method
is useful for subclasses when they need a QStyleOptionComboBox, but don't want
@@ -2572,20 +2594,7 @@ void QComboBox::changeEvent(QEvent *e)
hidePopup();
break;
case QEvent::PaletteChange: {
- QStyleOptionComboBox opt;
- initStyleOption(&opt);
-#ifndef QT_NO_MENU
- if (style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, this)) {
- QMenu menu;
- menu.ensurePolished();
- d->viewContainer()->setPalette(menu.palette());
- d->viewContainer()->setWindowOpacity(menu.windowOpacity());
- } else
-#endif
- {
- d->viewContainer()->setPalette(palette());
- d->viewContainer()->setWindowOpacity(1.0);
- }
+ d->updateViewContainerPaletteAndOpacity();
break;
}
case QEvent::FontChange:
diff --git a/src/gui/widgets/qcombobox_p.h b/src/gui/widgets/qcombobox_p.h
index c39a231..a0b76cf 100644
--- a/src/gui/widgets/qcombobox_p.h
+++ b/src/gui/widgets/qcombobox_p.h
@@ -370,6 +370,7 @@ public:
void updateDelegate();
void keyboardSearchString(const QString &text);
void modelChanged();
+ void updateViewContainerPaletteAndOpacity();
QAbstractItemModel *model;
QLineEdit *lineEdit;
diff --git a/src/gui/widgets/qdialogbuttonbox.cpp b/src/gui/widgets/qdialogbuttonbox.cpp
index 246da95..4a95292 100644
--- a/src/gui/widgets/qdialogbuttonbox.cpp
+++ b/src/gui/widgets/qdialogbuttonbox.cpp
@@ -752,7 +752,8 @@ QDialogButtonBox::~QDialogButtonBox()
\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}.
+ The button layout is specified by the \l{style()}{current style}. However,
+ on the X11 platform, it may be influenced by the desktop environment.
*/
/*!
diff --git a/src/gui/widgets/qmaccocoaviewcontainer_mac.mm b/src/gui/widgets/qmaccocoaviewcontainer_mac.mm
index 710af6a..380e983 100644
--- a/src/gui/widgets/qmaccocoaviewcontainer_mac.mm
+++ b/src/gui/widgets/qmaccocoaviewcontainer_mac.mm
@@ -1,11 +1,11 @@
/****************************************************************************
- **
- ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
- **
- ** This file is part of the QtGui module of the Qt Toolkit.
- **
- ** $QT_BEGIN_LICENSE:LGPL$
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
@@ -36,11 +36,11 @@
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
** $QT_END_LICENSE$
- **
- ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- **
- ****************************************************************************/
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+****************************************************************************/
#import <Cocoa/Cocoa.h>
#include <private/qwidget_p.h>
diff --git a/src/gui/widgets/qmacnativewidget_mac.mm b/src/gui/widgets/qmacnativewidget_mac.mm
index 1bc0430..0f4edf9 100644
--- a/src/gui/widgets/qmacnativewidget_mac.mm
+++ b/src/gui/widgets/qmacnativewidget_mac.mm
@@ -1,11 +1,11 @@
/****************************************************************************
- **
- ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
- **
- ** This file is part of the QtGui module of the Qt Toolkit.
- **
- ** $QT_BEGIN_LICENSE:LGPL$
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
@@ -36,11 +36,11 @@
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
** $QT_END_LICENSE$
- **
- ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- **
- ****************************************************************************/
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+****************************************************************************/
#import <Cocoa/Cocoa.h>
#import <private/qcocoaview_mac_p.h>
diff --git a/src/gui/widgets/qmainwindow.cpp b/src/gui/widgets/qmainwindow.cpp
index 46d6471..2abc9e8 100644
--- a/src/gui/widgets/qmainwindow.cpp
+++ b/src/gui/widgets/qmainwindow.cpp
@@ -481,7 +481,7 @@ void QMainWindow::setMenuBar(QMenuBar *menuBar)
oldMenuBar->deleteLater();
}
#ifdef Q_OS_WINCE
- if (menuBar->size().height() > 0)
+ if (menuBar && menuBar->size().height() > 0)
#endif
d->layout->setMenuBar(menuBar);
}
diff --git a/src/gui/widgets/qmainwindowlayout_mac.mm b/src/gui/widgets/qmainwindowlayout_mac.mm
index 950f758..c807afb 100644
--- a/src/gui/widgets/qmainwindowlayout_mac.mm
+++ b/src/gui/widgets/qmainwindowlayout_mac.mm
@@ -1,3 +1,47 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+****************************************************************************/
+
#include <private/qmainwindowlayout_p.h>
#include <qtoolbar.h>
#include <private/qtoolbarlayout_p.h>
diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp
index ed3e338..7396a9d 100644
--- a/src/gui/widgets/qmenu.cpp
+++ b/src/gui/widgets/qmenu.cpp
@@ -2889,8 +2889,8 @@ void QMenu::internalDelayedPopup()
int subMenuOffset = style()->pixelMetric(QStyle::PM_SubMenuOverlap, 0, this);
const QRect actionRect(d->actionRect(d->currentAction));
const QSize menuSize(d->activeMenu->sizeHint());
- const QPoint rightPos(mapToGlobal(QPoint(rect().right() + subMenuOffset + 1, actionRect.top())));
- const QPoint leftPos(mapToGlobal(QPoint(rect().left() - subMenuOffset - menuSize.width(), actionRect.top())));
+ const QPoint rightPos(mapToGlobal(QPoint(actionRect.right() + subMenuOffset + 1, actionRect.top())));
+ const QPoint leftPos(mapToGlobal(QPoint(actionRect.left() - subMenuOffset - menuSize.width(), actionRect.top())));
QPoint pos(rightPos);
QMenu *caused = qobject_cast<QMenu*>(d->activeMenu->d_func()->causedPopup.widget);
diff --git a/src/gui/widgets/qplaintextedit.cpp b/src/gui/widgets/qplaintextedit.cpp
index 2e9201d..a51ed2d 100644
--- a/src/gui/widgets/qplaintextedit.cpp
+++ b/src/gui/widgets/qplaintextedit.cpp
@@ -370,11 +370,16 @@ void QPlainTextDocumentLayout::layoutBlock(const QTextBlock &block)
extraMargin += fm.width(QChar(0x21B5));
}
tl->beginLayout();
+ qreal availableWidth = d->width;
+ if (availableWidth <= 0) {
+ availableWidth = INT_MAX; // similar to text edit with pageSize.width == 0
+ }
+ availableWidth -= 2*margin + extraMargin;
while (1) {
QTextLine line = tl->createLine();
if (!line.isValid())
break;
- line.setLineWidth(d->width - 2*margin - extraMargin);
+ line.setLineWidth(availableWidth);
height += leading;
line.setPosition(QPointF(margin, height));
diff --git a/src/gui/widgets/qtabbar.cpp b/src/gui/widgets/qtabbar.cpp
index 7d970ad..b6e6b6d 100644
--- a/src/gui/widgets/qtabbar.cpp
+++ b/src/gui/widgets/qtabbar.cpp
@@ -131,7 +131,7 @@ void QTabBar::initStyleOption(QStyleOptionTab *option, int tabIndex) const
option->state &= ~QStyle::State_Enabled;
if (isActiveWindow())
option->state |= QStyle::State_Active;
- if (option->rect == d->hoverRect)
+ if (!d->dragInProgress && option->rect == d->hoverRect)
option->state |= QStyle::State_MouseOver;
option->shape = d->shape;
option->text = tab.text;
@@ -454,9 +454,6 @@ void QTabBarPrivate::layoutTabs()
maxExtent = maxWidth;
}
- if (pressedIndex != -1 && movable)
- grabCache(0, tabList.count(), true);
-
Q_ASSERT(tabChainIndex == tabChain.count() - 1); // add an assert just to make sure.
// Mirror our front item.
tabChain[tabChainIndex].init();
@@ -1484,6 +1481,8 @@ void QTabBar::paintEvent(QPaintEvent *)
bool vertical = verticalTabs(d->shape);
QStyleOptionTab cutTab;
selected = d->currentIndex;
+ if (d->dragInProgress)
+ selected = d->pressedIndex;
for (int i = 0; i < d->tabList.count(); ++i)
optTabBase.tabBarRect |= tabRect(i);
@@ -1522,11 +1521,7 @@ void QTabBar::paintEvent(QPaintEvent *)
if (i == selected)
continue;
- if (!d->tabList[i].animatingCache.isNull() && d->paintWithOffsets) {
- p.drawPixmap(tab.rect, d->tabList[i].animatingCache);
- } else {
- p.drawControl(QStyle::CE_TabBarTab, tab);
- }
+ p.drawControl(QStyle::CE_TabBarTab, tab);
}
// Draw the selected tab last to get it "on top"
@@ -1539,7 +1534,11 @@ void QTabBar::paintEvent(QPaintEvent *)
else
tab.rect.moveLeft(tab.rect.x() + d->tabList[selected].dragOffset);
}
- p.drawControl(QStyle::CE_TabBarTab, tab);
+ if (!d->dragInProgress)
+ p.drawControl(QStyle::CE_TabBarTab, tab);
+ else
+ d->movingTab->setGeometry(tab.rect);
+
}
// Only draw the tear indicator if necessary. Most of the time we don't need too.
@@ -1680,6 +1679,7 @@ void QTabBarPrivate::_q_moveTab(int offset)
if (!validIndex(index))
return;
tabList[index].dragOffset = offset;
+ layoutTab(index); // Make buttons follow tab
q->update();
}
}
@@ -1727,8 +1727,7 @@ void QTabBar::mouseMoveEvent(QMouseEvent *event)
if (!d->dragInProgress && d->pressedIndex != -1) {
if ((event->pos() - d->dragStartPosition).manhattanLength() > QApplication::startDragDistance()) {
d->dragInProgress = true;
- if (d->animations.isEmpty())
- d->grabCache(0, d->tabList.count(), false);
+ d->setupMovableTab();
}
}
@@ -1773,7 +1772,6 @@ void QTabBar::mouseMoveEvent(QMouseEvent *event)
if (dragDistance > needsToBeOver)
d->slide(i + offset, d->pressedIndex);
}
-
}
// Buttons needs to follow the dragged tab
d->layoutTab(d->pressedIndex);
@@ -1801,32 +1799,41 @@ void QTabBarPrivate::_q_moveTabFinished()
}
}
-void QTabBarPrivate::grabCache(int start, int end, bool unhide)
+void QTabBarPrivate::setupMovableTab()
{
Q_Q(QTabBar);
- paintWithOffsets = false;
- bool showButtonsAgain = rightB->isVisible();
- rightB->hide();
- leftB->hide();
-
- QWidget *topLevel = q->window();
- QPoint topLevelOffset(q->mapTo(topLevel, QPoint()));
- for (int i = start; i < end; ++i) {
- QRect tabRect = q->tabRect(i);
- tabRect.translate(topLevelOffset);
- if (unhide) {
- tabList[i].unHideWidgets();
- layoutWidgets(i);
- }
- tabList[i].animatingCache = QPixmap::grabWidget(topLevel, tabRect);
- if (i != pressedIndex)
- tabList[i].hideWidgets();
- }
- if (showButtonsAgain) {
- rightB->show();
- leftB->show();
- }
- paintWithOffsets = true;
+ if (!movingTab)
+ movingTab = new QWidget(q);
+
+ QRect grabRect = q->tabRect(pressedIndex);
+
+ QPixmap grabImage(grabRect.size());
+ grabImage.fill(Qt::transparent);
+ QStylePainter p(&grabImage, q);
+
+ QStyleOptionTabV3 tab;
+ q->initStyleOption(&tab, pressedIndex);
+ tab.rect.moveTopLeft(QPoint(0, 0));
+ p.drawControl(QStyle::CE_TabBarTab, tab);
+ p.end();
+
+ QPalette pal;
+ pal.setBrush(QPalette::All, QPalette::Window, grabImage);
+ movingTab->setPalette(pal);
+ movingTab->setGeometry(grabRect);
+ movingTab->setAutoFillBackground(true);
+ movingTab->raise();
+
+ // Re-arrange widget order to avoid overlaps
+ if (tabList[pressedIndex].leftWidget)
+ tabList[pressedIndex].leftWidget->raise();
+ if (tabList[pressedIndex].rightWidget)
+ tabList[pressedIndex].rightWidget->raise();
+ if (leftB)
+ leftB->raise();
+ if (rightB)
+ rightB->raise();
+ movingTab->setVisible(true);
}
void QTabBarPrivate::_q_moveTabFinished(int index)
@@ -1834,10 +1841,9 @@ void QTabBarPrivate::_q_moveTabFinished(int index)
Q_Q(QTabBar);
bool cleanup = (pressedIndex == index) || (pressedIndex == -1) || !validIndex(index);
if (animations.isEmpty() && cleanup) {
+ movingTab->setVisible(false); // We might not get a mouse release
for (int i = 0; i < tabList.count(); ++i) {
tabList[i].dragOffset = 0;
- tabList[i].unHideWidgets();
- tabList[i].animatingCache = QPixmap();
}
if (pressedIndex != -1 && movable) {
pressedIndex = -1;
@@ -1881,6 +1887,7 @@ void QTabBar::mouseReleaseEvent(QMouseEvent *event)
d->_q_moveTabFinished(d->pressedIndex);
}
d->dragInProgress = false;
+ d->movingTab->setVisible(false);
d->dragStartPosition = QPoint();
}
@@ -2203,19 +2210,16 @@ void QTabBar::setTabButton(int index, ButtonPosition position, QWidget *widget)
widget->setParent(this);
// make sure our left and right widgets stay on top
widget->lower();
+ widget->show();
}
if (position == LeftSide) {
if (d->tabList[index].leftWidget)
d->tabList[index].leftWidget->hide();
d->tabList[index].leftWidget = widget;
- if(!d->tabList[index].hidLeft && widget)
- widget->show();
} else {
if (d->tabList[index].rightWidget)
d->tabList[index].rightWidget->hide();
d->tabList[index].rightWidget = widget;
- if(!d->tabList[index].hidRight && widget)
- widget->show();
}
d->layoutTabs();
update();
diff --git a/src/gui/widgets/qtabbar_p.h b/src/gui/widgets/qtabbar_p.h
index a117aa3..cb1a15b 100644
--- a/src/gui/widgets/qtabbar_p.h
+++ b/src/gui/widgets/qtabbar_p.h
@@ -70,7 +70,6 @@
QT_BEGIN_NAMESPACE
-
class QTabBarPrivate : public QWidgetPrivate
{
Q_DECLARE_PUBLIC(QTabBar)
@@ -78,7 +77,7 @@ public:
QTabBarPrivate()
:currentIndex(-1), pressedIndex(-1),
shape(QTabBar::RoundedNorth),
- layoutDirty(false), drawBase(true), scrollOffset(0), expanding(true), closeButtonOnTabs(false), selectionBehaviorOnRemove(QTabBar::SelectRightTab), paintWithOffsets(true), movable(false), dragInProgress(false), documentMode(false) {}
+ layoutDirty(false), drawBase(true), scrollOffset(0), expanding(true), closeButtonOnTabs(false), selectionBehaviorOnRemove(QTabBar::SelectRightTab), paintWithOffsets(true), movable(false), dragInProgress(false), documentMode(false), movingTab(0) {}
int currentIndex;
int pressedIndex;
@@ -98,8 +97,6 @@ public:
, lastTab(-1)
, timeLine(0)
, dragOffset(0)
- , hidLeft(false)
- , hidRight(false)
{}
bool enabled;
int shortcutId;
@@ -123,9 +120,6 @@ public:
QTimeLine *timeLine;
int dragOffset;
- QPixmap animatingCache;
- bool hidLeft;
- bool hidRight;
void makeTimeLine(QWidget *q) {
if (timeLine)
@@ -135,27 +129,6 @@ public:
q->connect(timeLine, SIGNAL(finished()), q, SLOT(_q_moveTabFinished()));
}
- void hideWidgets() {
- if (!hidRight && rightWidget) {
- hidRight = rightWidget->isVisible();
- rightWidget->hide();
- }
-
- if (!hidLeft && leftWidget) {
- hidLeft = leftWidget->isVisible();
- leftWidget->hide();
- }
- }
-
- void unHideWidgets() {
- if (leftWidget && hidLeft)
- leftWidget->show();
- hidLeft = false;
- if (rightWidget && hidRight)
- rightWidget->show();
- hidRight = false;
- }
-
};
QList<Tab> tabList;
QHash<QTimeLine*, int> animations;
@@ -184,12 +157,12 @@ public:
void _q_moveTabFinished(int offset);
QRect hoverRect;
- void grabCache(int start, int end, bool unhide);
void refresh();
void layoutTabs();
void layoutWidgets(int index = -1);
void layoutTab(int index);
void updateMacBorderMetrics();
+ void setupMovableTab();
void makeVisible(int index);
QSize iconSize;
@@ -206,6 +179,8 @@ public:
bool dragInProgress;
bool documentMode;
+ QWidget *movingTab;
+
// shared by tabwidget and qtabbar
static void initStyleBaseOption(QStyleOptionTabBarBaseV2 *optTabBase, QTabBar *tabbar, QSize size)
{
diff --git a/src/gui/widgets/qtoolbar.cpp b/src/gui/widgets/qtoolbar.cpp
index 85d6ea2..1babb6d 100644
--- a/src/gui/widgets/qtoolbar.cpp
+++ b/src/gui/widgets/qtoolbar.cpp
@@ -1153,6 +1153,17 @@ bool QToolBar::event(QEvent *event)
if (d->mouseMoveEvent(static_cast<QMouseEvent*>(event)))
return true;
break;
+#ifdef Q_OS_WINCE
+ case QEvent::ContextMenu:
+ {
+ QContextMenuEvent* contextMenuEvent = static_cast<QContextMenuEvent*>(event);
+ QWidget* child = childAt(contextMenuEvent->pos());
+ QAbstractButton* button = qobject_cast<QAbstractButton*>(child);
+ if (button)
+ button->setDown(false);
+ }
+ break;
+#endif
case QEvent::Leave:
if (d->state != 0 && d->state->dragging) {
#ifdef Q_OS_WIN