diff options
author | Sami Merilä <sami.merila@nokia.com> | 2009-10-02 13:21:34 (GMT) |
---|---|---|
committer | Sami Merilä <sami.merila@nokia.com> | 2009-10-02 13:21:34 (GMT) |
commit | 1ffaf40f5cffca57d7e116d61935ccd034239222 (patch) | |
tree | f8d9c73bb0a1ede03418415163b957fcf060e6f6 /src/gui | |
parent | c206ea53ebac0436bad0c00c1e340f23efb3aa16 (diff) | |
parent | a841c496bb7ca54fef01f9785e0d91991172b182 (diff) | |
download | Qt-1ffaf40f5cffca57d7e116d61935ccd034239222.zip Qt-1ffaf40f5cffca57d7e116d61935ccd034239222.tar.gz Qt-1ffaf40f5cffca57d7e116d61935ccd034239222.tar.bz2 |
Merge branch '4.6' of git@scm.dev.nokia.troll.no:qt/qt into 4.6
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/embedded/qvfbhdr.h | 18 | ||||
-rw-r--r-- | src/gui/graphicsview/qgraphicsitem.cpp | 95 | ||||
-rw-r--r-- | src/gui/graphicsview/qgraphicsscene.cpp | 243 | ||||
-rw-r--r-- | src/gui/graphicsview/qgraphicsview.cpp | 28 | ||||
-rw-r--r-- | src/gui/image/qimage_p.h | 2 | ||||
-rw-r--r-- | src/gui/image/qpixmap_s60.cpp | 4 | ||||
-rw-r--r-- | src/gui/image/qpixmap_x11.cpp | 33 | ||||
-rw-r--r-- | src/gui/itemviews/qabstractitemview.cpp | 27 | ||||
-rw-r--r-- | src/gui/itemviews/qabstractitemview.h | 5 | ||||
-rw-r--r-- | src/gui/itemviews/qabstractitemview_p.h | 9 | ||||
-rw-r--r-- | src/gui/kernel/qapplication_qws.cpp | 2 | ||||
-rw-r--r-- | src/gui/kernel/qapplication_s60.cpp | 13 | ||||
-rw-r--r-- | src/gui/kernel/qwidget_p.h | 1 | ||||
-rw-r--r-- | src/gui/kernel/qwidget_s60.cpp | 42 | ||||
-rw-r--r-- | src/gui/painting/qdrawutil.cpp | 36 | ||||
-rw-r--r-- | src/gui/painting/qdrawutil.h | 18 | ||||
-rw-r--r-- | src/gui/styles/qstylesheetstyle.cpp | 2 | ||||
-rw-r--r-- | src/gui/widgets/qabstractslider.cpp | 21 | ||||
-rw-r--r-- | src/gui/widgets/qlabel.cpp | 13 | ||||
-rw-r--r-- | src/gui/widgets/qtextedit.cpp | 5 |
20 files changed, 384 insertions, 233 deletions
diff --git a/src/gui/embedded/qvfbhdr.h b/src/gui/embedded/qvfbhdr.h index f02286e..eff5fc2 100644 --- a/src/gui/embedded/qvfbhdr.h +++ b/src/gui/embedded/qvfbhdr.h @@ -56,6 +56,7 @@ QT_MODULE(Gui) #define QT_QWS_TEMP_DIR "/tmp" #endif +#ifdef QT_PRIVATE_QWS #define QT_VFB_DATADIR(DISPLAY) QString("%1/qtembedded-%2-%3") \ .arg(QT_QWS_TEMP_DIR).arg(getuid()).arg(DISPLAY) @@ -67,7 +68,22 @@ QT_MODULE(Gui) .append("/qtvfb_map") #define QT_VFB_SOUND_PIPE(DISPLAY) QT_VFB_DATADIR(DISPLAY) \ .append("/qt_soundserver") -#define QTE_PIPE "QtEmbedded" +#define QTE_PIPE(DISPLAY) QT_VFB_DATADIR(DISPLAY) \ + .append("/QtEmbedded") +#define QTE_PIPE_QVFB QTE_PIPE +#else +#define QT_VFB_DATADIR(DISPLAY) QString("%1/qtembedded-%2") \ + .arg(QT_QWS_TEMP_DIR).arg(DISPLAY) +#define QT_VFB_MOUSE_PIPE(DISPLAY) QString("/tmp/.qtvfb_mouse-%1").arg(DISPLAY) +#define QT_VFB_KEYBOARD_PIPE(DISPLAY) QString("/tmp/.qtvfb_keyboard-%1").arg(DISPLAY) +#define QT_VFB_MAP(DISPLAY) QString("/tmp/.qtvfb_map-%1").arg(DISPLAY) +#define QT_VFB_SOUND_PIPE(DISPLAY) QString("/tmp/.qt_soundserver-%1").arg(DISPLAY) +#define QTE_PIPE(DISPLAY) QT_VFB_DATADIR(DISPLAY) \ + .append("/QtEmbedded-%1") \ + .arg(DISPLAY) +#define QTE_PIPE_QVFB(DISPLAY) QString("/tmp/qtembedded-%1/QtEmbedded-%1") \ + .arg(DISPLAY) +#endif struct QVFbHeader { diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index bc9c73f..0690690 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -186,6 +186,49 @@ high z-values. Stacking order applies to sibling items; parents are always drawn before their children. + \section1 Sorting + + All items are drawn in a defined, stable order, and this same order decides + which items will receive mouse input first when you click on the scene. + Normally you don't have to worry about sorting, as the items follow a + "natural order", following the logical structure of the scene. + + An item's children are stacked on top of the parent, and sibling items are + stacked by insertion order (i.e., in the same order that they were either + added to the scene, or added to the same parent). If you add item A, and + then B, then B will be on top of A. If you then add C, the items' stacking + order will be A, then B, then C. + + \image graphicsview-zorder.png + + This example shows the stacking order of all limbs of the robot from the + \l{graphicsview/dragdroprobot}{Drag and Drop Robot} example. The torso is + the root item (all other items are children or descendants of the torso), + so it is drawn first. Next, the head is drawn, as it is the first item in + the torso's list of children. Then the upper left arm is drawn. As the + lower arm is a child of the upper arm, the lower arm is then drawn, + followed by the upper arm's next sibling, which is the upper right arm, and + so on. + + For advanced users, there are ways to alter how your items are sorted: + + \list + \o You can call setZValue() on an item to explicitly stack it on top of, or + under, other sibling items. The default Z value for an item is 0. Items + with the same Z value are stacked by insertion order. + + \o You can call stackBefore() to reorder the list of children. This will + directly modify the insertion order. + + \o You can set the ItemStacksBehindParent flag to stack a child item behind + its parent. + \endlist + + The stacking order of two sibling items also counts for each item's + children and descendant items. So if one item is on top of another, then + all its children will also be on top of all the other item's children as + well. + \section1 Events QGraphicsItem receives events from QGraphicsScene through the virtual @@ -1487,10 +1530,12 @@ QList<QGraphicsItem *> QGraphicsItem::children() const /*! \since 4.4 - Returns a list of this item's children. The items are returned in no - particular order. + Returns a list of this item's children. - \sa setParentItem() + The items are sorted by stacking order. This takes into account both the + items' insertion order and their Z-values. + + \sa setParentItem(), zValue(), {QGraphicsItem#Sorting}{Sorting} */ QList<QGraphicsItem *> QGraphicsItem::childItems() const { @@ -4090,12 +4135,12 @@ void QGraphicsItem::advance(int phase) } /*! - Returns the Z-value, or the elevation, of the item. The Z-value decides - the stacking order of sibling (neighboring) items. + Returns the Z-value of the item. The Z-value affects the stacking order of + sibling (neighboring) items. The default Z-value is 0. - \sa setZValue() + \sa setZValue(), {QGraphicsItem#Sorting}{Sorting}, stackBefore(), ItemStacksBehindParent */ qreal QGraphicsItem::zValue() const { @@ -4103,33 +4148,18 @@ qreal QGraphicsItem::zValue() const } /*! - Sets the Z-value, or the elevation, of the item, to \a z. The elevation - decides the stacking order of sibling (neighboring) items. An item of high - Z-value will be drawn on top of an item with a lower Z-value if they share - the same parent item. In addition, children of an item will always be - drawn on top of the parent, regardless of the child's Z-value. Sibling - items that share the same Z-value will be drawn in order of insertion; the - last inserted child is stacked above previous children. - - \img graphicsview-zorder.png + Sets the Z-value of the item to \a z. The Z value decides the stacking + order of sibling (neighboring) items. A sibling item of high Z value will + always be drawn on top of another sibling item with a lower Z value. - Children of different parents are stacked according to the Z-value of - each item's ancestor item which is an immediate child of the two - items' closest common ancestor. For example, a robot item might - define a torso item as the parent of a head item, two arm items, - and two upper-leg items. The upper-leg items would each be parents - of one lower-leg item, and each lower-leg item would be parents of - one foot item. The stacking order of the feet is the same as the - stacking order of each foot's ancestor that is an immediate child - of the two feet's common ancestor (i.e., the torso item); so the - feet are stacked in the same order as the upper-leg items, - regardless of each foot's Z-value. + If you restore the Z value, the item's insertion order will decide its + stacking order. The Z-value does not affect the item's size in any way. The default Z-value is 0. - \sa zValue() + \sa zValue(), {QGraphicsItem#Sorting}{Sorting}, stackBefore(), ItemStacksBehindParent */ void QGraphicsItem::setZValue(qreal z) { @@ -4192,12 +4222,13 @@ void QGraphicsItemPrivate::ensureSequentialSiblingIndex() The \a sibling must have the same Z value as this item, otherwise calling this function will have no effect. - By default, all items are stacked by insertion order (i.e., the first item - you add is drawn before the next item you add). If two items' Z values are - different, then the item with the highest Z value is drawn on top. When the - Z values are the same, the insertion order will decide the stacking order. + By default, all sibling items are stacked by insertion order (i.e., the + first item you add is drawn before the next item you add). If two items' Z + values are different, then the item with the highest Z value is drawn on + top. When the Z values are the same, the insertion order will decide the + stacking order. - \sa setZValue(), ItemStacksBehindParent + \sa setZValue(), ItemStacksBehindParent, {QGraphicsItem#Sorting}{Sorting} */ void QGraphicsItem::stackBefore(const QGraphicsItem *sibling) { diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index a1ff6d2..1226722 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -1759,10 +1759,10 @@ QRectF QGraphicsScene::itemsBoundingRect() const return boundingRect; } -/*! \fn QList<QGraphicsItem *> QGraphicsScene::items() const - Returns a list of all items on the scene, in no particular order. +/*! + Returns a list of all items in the scene in descending stacking order. - \sa addItem(), removeItem() + \sa addItem(), removeItem(), {QGraphicsItem#Sorting}{Sorting} */ QList<QGraphicsItem *> QGraphicsScene::items() const { @@ -1770,11 +1770,11 @@ QList<QGraphicsItem *> QGraphicsScene::items() const return d->index->items(Qt::DescendingOrder); } -/*! \fn QList<QGraphicsItem *> QGraphicsScene::items(Qt::SortOrder order) const - Returns an ordered list of all items on the scene. \a order decides the - sorting. +/*! + Returns an ordered list of all items on the scene. \a order decides the + stacking order. - \sa addItem(), removeItem() + \sa addItem(), removeItem(), {QGraphicsItem#Sorting}{Sorting} */ QList<QGraphicsItem *> QGraphicsScene::items(Qt::SortOrder order) const { @@ -1782,18 +1782,18 @@ QList<QGraphicsItem *> QGraphicsScene::items(Qt::SortOrder order) const return d->index->items(order); } -/*! \fn QList<QGraphicsItem *> QGraphicsScene::items(const QPointF &pos) const - \obsolete +/*! + \obsolete - Returns all visible items at position \a pos in the scene. The items are - listed in descending stacking order (i.e., the first item in the list is the - top-most item, and the last item is the bottom-most item). + Returns all visible items at position \a pos in the scene. The items are + listed in descending stacking order (i.e., the first item in the list is the + top-most item, and the last item is the bottom-most item). - This function is deprecated and returns incorrect results if the scene - contains items that ignore transformations. Use the overload that takes - a QTransform instead. + This function is deprecated and returns incorrect results if the scene + contains items that ignore transformations. Use the overload that takes + a QTransform instead. - \sa itemAt() + \sa itemAt(), {QGraphicsItem#Sorting}{Sorting} */ QList<QGraphicsItem *> QGraphicsScene::items(const QPointF &pos) const { @@ -1801,21 +1801,21 @@ QList<QGraphicsItem *> QGraphicsScene::items(const QPointF &pos) const return d->index->items(pos, Qt::IntersectsItemShape, Qt::DescendingOrder); } -/*! \fn QList<QGraphicsItem *> QGraphicsScene::items(const QRectF &rectangle, Qt::ItemSelectionMode mode) const - \overload - \obsolete +/*! + \overload + \obsolete - Returns all visible items that, depending on \a mode, are either inside or - intersect with the specified \a rectangle. + Returns all visible items that, depending on \a mode, are either inside or + intersect with the specified \a rectangle. - The default value for \a mode is Qt::IntersectsItemShape; all items whose - exact shape intersects with or is contained by \a rectangle are returned. + The default value for \a mode is Qt::IntersectsItemShape; all items whose + exact shape intersects with or is contained by \a rectangle are returned. - This function is deprecated and returns incorrect results if the scene - contains items that ignore transformations. Use the overload that takes - a QTransform instead. + This function is deprecated and returns incorrect results if the scene + contains items that ignore transformations. Use the overload that takes + a QTransform instead. - \sa itemAt() + \sa itemAt(), {QGraphicsItem#Sorting}{Sorting} */ QList<QGraphicsItem *> QGraphicsScene::items(const QRectF &rectangle, Qt::ItemSelectionMode mode) const { @@ -1823,45 +1823,47 @@ QList<QGraphicsItem *> QGraphicsScene::items(const QRectF &rectangle, Qt::ItemSe return d->index->items(rectangle, mode, Qt::DescendingOrder); } -/*! \fn QList<QGraphicsItem *> QGraphicsScene::items(qreal x, qreal y, qreal w, qreal h, Qt::ItemSelectionMode mode) const - \obsolete - \since 4.3 +/*! + \fn QList<QGraphicsItem *> QGraphicsScene::items(qreal x, qreal y, qreal w, qreal h, Qt::ItemSelectionMode mode) const + \obsolete + \since 4.3 - This convenience function is equivalent to calling items(QRectF(\a x, \a y, \a w, \a h), \a mode). + This convenience function is equivalent to calling items(QRectF(\a x, \a y, \a w, \a h), \a mode). - This function is deprecated and returns incorrect results if the scene - contains items that ignore transformations. Use the overload that takes - a QTransform instead. + This function is deprecated and returns incorrect results if the scene + contains items that ignore transformations. Use the overload that takes + a QTransform instead. */ /*! - \fn QList<QGraphicsItem *> QGraphicsScene::items(qreal x, qreal y, qreal w, qreal h, Qt::ItemSelectionMode mode, Qt::SortOrder order, const QTransform &deviceTransform) const - \overload - \since 4.6 + \fn QList<QGraphicsItem *> QGraphicsScene::items(qreal x, qreal y, qreal w, qreal h, Qt::ItemSelectionMode mode, Qt::SortOrder order, const QTransform &deviceTransform) const + \overload + \since 4.6 - \brief Returns all visible items that, depending on \a mode, are - either inside or intersect with the rectangle defined by \a x, \a y, - \a w and \a h, in a list sorted using \a order. + \brief Returns all visible items that, depending on \a mode, are + either inside or intersect with the rectangle defined by \a x, \a y, + \a w and \a h, in a list sorted using \a order. - \a deviceTransform is the transformation that applies to the view, and needs to - be provided if the scene contains items that ignore transformations. + \a deviceTransform is the transformation that applies to the view, and needs to + be provided if the scene contains items that ignore transformations. */ -/*! \fn QList<QGraphicsItem *> QGraphicsScene::items(const QPolygonF &polygon, Qt::ItemSelectionMode mode) const - \overload - \obsolete +/*! + \fn QList<QGraphicsItem *> QGraphicsScene::items(const QPolygonF &polygon, Qt::ItemSelectionMode mode) const + \overload + \obsolete - Returns all visible items that, depending on \a mode, are either inside or - intersect with the polygon \a polygon. + Returns all visible items that, depending on \a mode, are either inside or + intersect with the polygon \a polygon. - The default value for \a mode is Qt::IntersectsItemShape; all items whose - exact shape intersects with or is contained by \a polygon are returned. + The default value for \a mode is Qt::IntersectsItemShape; all items whose + exact shape intersects with or is contained by \a polygon are returned. - This function is deprecated and returns incorrect results if the scene - contains items that ignore transformations. Use the overload that takes - a QTransform instead. + This function is deprecated and returns incorrect results if the scene + contains items that ignore transformations. Use the overload that takes + a QTransform instead. - \sa itemAt() + \sa itemAt(), {QGraphicsItem#Sorting}{Sorting} */ QList<QGraphicsItem *> QGraphicsScene::items(const QPolygonF &polygon, Qt::ItemSelectionMode mode) const { @@ -1869,21 +1871,22 @@ QList<QGraphicsItem *> QGraphicsScene::items(const QPolygonF &polygon, Qt::ItemS return d->index->items(polygon, mode, Qt::DescendingOrder); } -/*! \fn QList<QGraphicsItem *> QGraphicsScene::items(const QPainterPath &path, Qt::ItemSelectionMode mode) const - \overload - \obsolete +/*! + \fn QList<QGraphicsItem *> QGraphicsScene::items(const QPainterPath &path, Qt::ItemSelectionMode mode) const + \overload + \obsolete - Returns all visible items that, depending on \a path, are either inside or - intersect with the path \a path. + Returns all visible items that, depending on \a path, are either inside or + intersect with the path \a path. - The default value for \a mode is Qt::IntersectsItemShape; all items whose - exact shape intersects with or is contained by \a path are returned. + The default value for \a mode is Qt::IntersectsItemShape; all items whose + exact shape intersects with or is contained by \a path are returned. - This function is deprecated and returns incorrect results if the scene - contains items that ignore transformations. Use the overload that takes - a QTransform instead. + This function is deprecated and returns incorrect results if the scene + contains items that ignore transformations. Use the overload that takes + a QTransform instead. - \sa itemAt() + \sa itemAt(), {QGraphicsItem#Sorting}{Sorting} */ QList<QGraphicsItem *> QGraphicsScene::items(const QPainterPath &path, Qt::ItemSelectionMode mode) const { @@ -1891,20 +1894,20 @@ QList<QGraphicsItem *> QGraphicsScene::items(const QPainterPath &path, Qt::ItemS return d->index->items(path, mode, Qt::DescendingOrder); } -/*! \fn QList<QGraphicsItem *> QGraphicsScene::items(const QPointF &pos, Qt::ItemSelectionMode mode, Qt::SortOrder order, const QTransform &deviceTransform) const - - \since 4.6 +/*! + \fn QList<QGraphicsItem *> QGraphicsScene::items(const QPointF &pos, Qt::ItemSelectionMode mode, Qt::SortOrder order, const QTransform &deviceTransform) const + \since 4.6 - \brief Returns all visible items that, depending on \a mode, are at - the specified \a pos in a list sorted using \a order. + \brief Returns all visible items that, depending on \a mode, are at + the specified \a pos in a list sorted using \a order. - The default value for \a mode is Qt::IntersectsItemShape; all items whose - exact shape intersects with \a pos are returned. + The default value for \a mode is Qt::IntersectsItemShape; all items whose + exact shape intersects with \a pos are returned. - \a deviceTransform is the transformation that applies to the view, and needs to - be provided if the scene contains items that ignore transformations. + \a deviceTransform is the transformation that applies to the view, and needs to + be provided if the scene contains items that ignore transformations. - \sa itemAt() + \sa itemAt(), {QGraphicsItem#Sorting}{Sorting} */ QList<QGraphicsItem *> QGraphicsScene::items(const QPointF &pos, Qt::ItemSelectionMode mode, Qt::SortOrder order, const QTransform &deviceTransform) const @@ -1913,21 +1916,22 @@ QList<QGraphicsItem *> QGraphicsScene::items(const QPointF &pos, Qt::ItemSelecti return d->index->items(pos, mode, order, deviceTransform); } -/*! \fn QList<QGraphicsItem *> QGraphicsScene::items(const QRectF &rect, Qt::ItemSelectionMode mode, Qt::SortOrder order, const QTransform &deviceTransform) const - \overload - \since 4.6 +/*! + \fn QList<QGraphicsItem *> QGraphicsScene::items(const QRectF &rect, Qt::ItemSelectionMode mode, Qt::SortOrder order, const QTransform &deviceTransform) const + \overload + \since 4.6 - \brief Returns all visible items that, depending on \a mode, are - either inside or intersect with the specified \a rect and return a - list sorted using \a order. + \brief Returns all visible items that, depending on \a mode, are + either inside or intersect with the specified \a rect and return a + list sorted using \a order. - The default value for \a mode is Qt::IntersectsItemShape; all items whose - exact shape intersects with or is contained by \a rect are returned. + The default value for \a mode is Qt::IntersectsItemShape; all items whose + exact shape intersects with or is contained by \a rect are returned. - \a deviceTransform is the transformation that applies to the view, and needs to - be provided if the scene contains items that ignore transformations. + \a deviceTransform is the transformation that applies to the view, and needs to + be provided if the scene contains items that ignore transformations. - \sa itemAt() + \sa itemAt(), {QGraphicsItem#Sorting}{Sorting} */ QList<QGraphicsItem *> QGraphicsScene::items(const QRectF &rect, Qt::ItemSelectionMode mode, Qt::SortOrder order, const QTransform &deviceTransform) const @@ -1936,21 +1940,22 @@ QList<QGraphicsItem *> QGraphicsScene::items(const QRectF &rect, Qt::ItemSelecti return d->index->items(rect, mode, order, deviceTransform); } -/*! \fn QList<QGraphicsItem *> QGraphicsScene::items(const QPolygonF &polygon, Qt::ItemSelectionMode mode, Qt::SortOrder order, const QTransform &deviceTransform) const - \overload - \since 4.6 +/*! + \fn QList<QGraphicsItem *> QGraphicsScene::items(const QPolygonF &polygon, Qt::ItemSelectionMode mode, Qt::SortOrder order, const QTransform &deviceTransform) const + \overload + \since 4.6 - \brief Returns all visible items that, depending on \a mode, are - either inside or intersect with the specified \a polygon and return - a list sorted using \a order. + \brief Returns all visible items that, depending on \a mode, are + either inside or intersect with the specified \a polygon and return + a list sorted using \a order. - The default value for \a mode is Qt::IntersectsItemShape; all items whose - exact shape intersects with or is contained by \a polygon are returned. + The default value for \a mode is Qt::IntersectsItemShape; all items whose + exact shape intersects with or is contained by \a polygon are returned. - \a deviceTransform is the transformation that applies to the view, and needs to - be provided if the scene contains items that ignore transformations. + \a deviceTransform is the transformation that applies to the view, and needs to + be provided if the scene contains items that ignore transformations. - \sa itemAt() + \sa itemAt(), {QGraphicsItem#Sorting}{Sorting} */ QList<QGraphicsItem *> QGraphicsScene::items(const QPolygonF &polygon, Qt::ItemSelectionMode mode, Qt::SortOrder order, const QTransform &deviceTransform) const @@ -1959,21 +1964,22 @@ QList<QGraphicsItem *> QGraphicsScene::items(const QPolygonF &polygon, Qt::ItemS return d->index->items(polygon, mode, order, deviceTransform); } -/*! \fn QList<QGraphicsItem *> QGraphicsScene::items(const QPainterPath &path, Qt::ItemSelectionMode mode, Qt::SortOrder order, const QTransform &deviceTransform) const - \overload - \since 4.6 +/*! + \fn QList<QGraphicsItem *> QGraphicsScene::items(const QPainterPath &path, Qt::ItemSelectionMode mode, Qt::SortOrder order, const QTransform &deviceTransform) const + \overload + \since 4.6 - \brief Returns all visible items that, depending on \a mode, are - either inside or intersect with the specified \a path and return a - list sorted using \a order. + \brief Returns all visible items that, depending on \a mode, are + either inside or intersect with the specified \a path and return a + list sorted using \a order. - The default value for \a mode is Qt::IntersectsItemShape; all items whose - exact shape intersects with or is contained by \a path are returned. + The default value for \a mode is Qt::IntersectsItemShape; all items whose + exact shape intersects with or is contained by \a path are returned. - \a deviceTransform is the transformation that applies to the view, and needs to - be provided if the scene contains items that ignore transformations. + \a deviceTransform is the transformation that applies to the view, and needs to + be provided if the scene contains items that ignore transformations. - \sa itemAt() + \sa itemAt(), {QGraphicsItem#Sorting}{Sorting} */ QList<QGraphicsItem *> QGraphicsScene::items(const QPainterPath &path, Qt::ItemSelectionMode mode, Qt::SortOrder order, const QTransform &deviceTransform) const @@ -1988,10 +1994,11 @@ QList<QGraphicsItem *> QGraphicsScene::items(const QPainterPath &path, Qt::ItemS detection is determined by \a mode. By default, all items whose shape intersects \a item or is contained inside \a item's shape are returned. - The items are returned in descending Z order (i.e., the first item in the - list is the top-most item, and the last item is the bottom-most item). + The items are returned in descending stacking order (i.e., the first item + in the list is the uppermost item, and the last item is the lowermost + item). - \sa items(), itemAt(), QGraphicsItem::collidesWithItem() + \sa items(), itemAt(), QGraphicsItem::collidesWithItem(), {QGraphicsItem#Sorting}{Sorting} */ QList<QGraphicsItem *> QGraphicsScene::collidingItems(const QGraphicsItem *item, Qt::ItemSelectionMode mode) const @@ -2018,13 +2025,11 @@ QList<QGraphicsItem *> QGraphicsScene::collidingItems(const QGraphicsItem *item, Returns the topmost visible item at the specified \a position, or 0 if there are no items at this position. - \note The topmost item is the one with the highest Z-value. - This function is deprecated and returns incorrect results if the scene contains items that ignore transformations. Use the overload that takes a QTransform instead. - \sa items(), collidingItems(), QGraphicsItem::setZValue() + \sa items(), collidingItems(), {QGraphicsItem#Sorting}{Sorting} */ QGraphicsItem *QGraphicsScene::itemAt(const QPointF &position) const { @@ -2041,10 +2046,8 @@ QGraphicsItem *QGraphicsScene::itemAt(const QPointF &position) const \a deviceTransform is the transformation that applies to the view, and needs to be provided if the scene contains items that ignore transformations. - \note The topmost item is the one with the highest Z-value. - - \sa items(), collidingItems(), QGraphicsItem::setZValue() - */ + \sa items(), collidingItems(), {QGraphicsItem#Sorting}{Sorting} +*/ QGraphicsItem *QGraphicsScene::itemAt(const QPointF &position, const QTransform &deviceTransform) const { QList<QGraphicsItem *> itemsAtPoint = items(position, Qt::IntersectsItemShape, @@ -2065,8 +2068,6 @@ QGraphicsItem *QGraphicsScene::itemAt(const QPointF &position, const QTransform This convenience function is equivalent to calling \c {itemAt(QPointF(x, y), deviceTransform)}. - - \note The topmost item is the one with the highest Z-value. */ /*! @@ -2083,8 +2084,6 @@ QGraphicsItem *QGraphicsScene::itemAt(const QPointF &position, const QTransform This function is deprecated and returns incorrect results if the scene contains items that ignore transformations. Use the overload that takes a QTransform instead. - - \note The topmost item is the one with the highest Z-value. */ /*! @@ -2363,7 +2362,7 @@ void QGraphicsScene::destroyItemGroup(QGraphicsItemGroup *group) in the scene, then the item will be activated. \sa removeItem(), addEllipse(), addLine(), addPath(), addPixmap(), - addRect(), addText(), addWidget() + addRect(), addText(), addWidget(), {QGraphicsItem#Sorting}{Sorting} */ void QGraphicsScene::addItem(QGraphicsItem *item) { diff --git a/src/gui/graphicsview/qgraphicsview.cpp b/src/gui/graphicsview/qgraphicsview.cpp index 98b2c9c..32747cc 100644 --- a/src/gui/graphicsview/qgraphicsview.cpp +++ b/src/gui/graphicsview/qgraphicsview.cpp @@ -2016,9 +2016,11 @@ void QGraphicsView::render(QPainter *painter, const QRectF &target, const QRect } /*! - Returns a list of all the items in the associated scene. + Returns a list of all the items in the associated scene, in descending + stacking order (i.e., the first item in the returned list is the uppermost + item). - \sa QGraphicsScene::items() + \sa QGraphicsScene::items(), {QGraphicsItem#Sorting}{Sorting} */ QList<QGraphicsItem *> QGraphicsView::items() const { @@ -2030,9 +2032,9 @@ QList<QGraphicsItem *> QGraphicsView::items() const /*! Returns a list of all the items at the position \a pos in the view. The - items are listed in descending Z order (i.e., the first item in the list - is the top-most item, and the last item is the bottom-most item). \a pos - is in viewport coordinates. + items are listed in descending stacking order (i.e., the first item in the + list is the uppermost item, and the last item is the lowermost item). \a + pos is in viewport coordinates. This function is most commonly called from within mouse event handlers in a subclass in QGraphicsView. \a pos is in untransformed viewport @@ -2040,7 +2042,7 @@ QList<QGraphicsItem *> QGraphicsView::items() const \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsview.cpp 5 - \sa QGraphicsScene::items(), QGraphicsItem::zValue() + \sa QGraphicsScene::items(), {QGraphicsItem#Sorting}{Sorting} */ QList<QGraphicsItem *> QGraphicsView::items(const QPoint &pos) const { @@ -2082,7 +2084,10 @@ QList<QGraphicsItem *> QGraphicsView::items(const QPoint &pos) const The default value for \a mode is Qt::IntersectsItemShape; all items whose exact shape intersects with or is contained by \a rect are returned. - \sa itemAt(), items(), mapToScene() + The items are sorted in descending stacking order (i.e., the first item in + the returned list is the uppermost item). + + \sa itemAt(), items(), mapToScene(), {QGraphicsItem#Sorting}{Sorting} */ QList<QGraphicsItem *> QGraphicsView::items(const QRect &rect, Qt::ItemSelectionMode mode) const { @@ -2110,7 +2115,10 @@ QList<QGraphicsItem *> QGraphicsView::items(const QRect &rect, Qt::ItemSelection The default value for \a mode is Qt::IntersectsItemShape; all items whose exact shape intersects with or is contained by \a polygon are returned. - \sa itemAt(), items(), mapToScene() + The items are sorted by descending stacking order (i.e., the first item in + the returned list is the uppermost item). + + \sa itemAt(), items(), mapToScene(), {QGraphicsItem#Sorting}{Sorting} */ QList<QGraphicsItem *> QGraphicsView::items(const QPolygon &polygon, Qt::ItemSelectionMode mode) const { @@ -2130,7 +2138,7 @@ QList<QGraphicsItem *> QGraphicsView::items(const QPolygon &polygon, Qt::ItemSel The default value for \a mode is Qt::IntersectsItemShape; all items whose exact shape intersects with or is contained by \a path are returned. - \sa itemAt(), items(), mapToScene() + \sa itemAt(), items(), mapToScene(), {QGraphicsItem#Sorting}{Sorting} */ QList<QGraphicsItem *> QGraphicsView::items(const QPainterPath &path, Qt::ItemSelectionMode mode) const { @@ -2149,7 +2157,7 @@ QList<QGraphicsItem *> QGraphicsView::items(const QPainterPath &path, Qt::ItemSe \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsview.cpp 6 - \sa items() + \sa items(), {QGraphicsItem#Sorting}{Sorting} */ QGraphicsItem *QGraphicsView::itemAt(const QPoint &pos) const { diff --git a/src/gui/image/qimage_p.h b/src/gui/image/qimage_p.h index 4f44109..bea1e8d 100644 --- a/src/gui/image/qimage_p.h +++ b/src/gui/image/qimage_p.h @@ -63,7 +63,7 @@ QT_BEGIN_NAMESPACE -struct QImageData { // internal image data +struct Q_GUI_EXPORT QImageData { // internal image data QImageData(); ~QImageData(); static QImageData *create(const QSize &size, QImage::Format format, int numColors = 0); diff --git a/src/gui/image/qpixmap_s60.cpp b/src/gui/image/qpixmap_s60.cpp index 4938442..326dd10 100644 --- a/src/gui/image/qpixmap_s60.cpp +++ b/src/gui/image/qpixmap_s60.cpp @@ -64,7 +64,7 @@ const uchar qt_pixmap_bit_mask[] = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 }; -/*! +/* \class QSymbianFbsClient \since 4.6 \internal @@ -145,7 +145,7 @@ void QSymbianFbsHeapLock::relock() qt_symbianFbsClient()->lockHeap(); } -/*! +/* \class QSymbianBitmapDataAccess \since 4.6 \internal diff --git a/src/gui/image/qpixmap_x11.cpp b/src/gui/image/qpixmap_x11.cpp index f77d200..6cde898 100644 --- a/src/gui/image/qpixmap_x11.cpp +++ b/src/gui/image/qpixmap_x11.cpp @@ -67,6 +67,7 @@ #include <private/qt_x11_p.h> #include "qx11info_x11.h" #include <private/qdrawhelper_p.h> +#include <private/qimage_p.h> #include <stdlib.h> @@ -369,6 +370,30 @@ void QX11PixmapData::resize(int width, int height) #endif // QT_NO_XRENDER } +struct QX11AlphaDetector +{ + bool hasAlpha() const { + if (checked) + return has; + // Will implicitly also check format and return quickly for opaque types... + checked = true; + has = const_cast<QImage *>(image)->data_ptr()->checkForAlphaPixels(); + return has; + } + + bool hasXRenderAndAlpha() const { + if (!X11->use_xrender) + return false; + return hasAlpha(); + } + + QX11AlphaDetector(const QImage *i) : image(i), checked(false), has(false) { } + + const QImage *image; + mutable bool checked; + mutable bool has; +}; + void QX11PixmapData::fromImage(const QImage &img, Qt::ImageConversionFlags flags) { @@ -402,7 +427,9 @@ void QX11PixmapData::fromImage(const QImage &img, return; } - int dd = X11->use_xrender && img.hasAlphaChannel() ? 32 : xinfo.depth(); + QX11AlphaDetector alphaCheck(&img); + int dd = alphaCheck.hasXRenderAndAlpha() ? 32 : xinfo.depth(); + if (qt_x11_preferred_pixmap_depth) dd = qt_x11_preferred_pixmap_depth; @@ -454,7 +481,7 @@ void QX11PixmapData::fromImage(const QImage &img, uchar *newbits= 0; #ifndef QT_NO_XRENDER - if (X11->use_xrender && image.hasAlphaChannel()) { + if (alphaCheck.hasXRenderAndAlpha()) { const QImage &cimage = image; d = 32; @@ -1091,7 +1118,7 @@ void QX11PixmapData::fromImage(const QImage &img, } #endif - if (image.hasAlphaChannel()) { + if (alphaCheck.hasAlpha()) { QBitmap m = QBitmap::fromImage(image.createAlphaMask(flags)); setMask(m); } diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp index 0fae959..18cab13 100644 --- a/src/gui/itemviews/qabstractitemview.cpp +++ b/src/gui/itemviews/qabstractitemview.cpp @@ -87,6 +87,7 @@ QAbstractItemViewPrivate::QAbstractItemViewPrivate() dragDropMode(QAbstractItemView::NoDragDrop), overwrite(false), dropIndicatorPosition(QAbstractItemView::OnItem), + defaultDropAction(Qt::IgnoreAction), #endif #ifdef QT_SOFTKEYS_ENABLED doneSoftKey(0), @@ -1371,6 +1372,28 @@ QAbstractItemView::DragDropMode QAbstractItemView::dragDropMode() const return NoDragDrop; } +/*! + \property QAbstractItemView::defaultDropAction + \brief the drop action that will be used by default in QAbstractItemView::drag() + + If the property is not set, the drop action is CopyAction when the supported + actions support CopyAction. + + \since 4.6 + \sa showDropIndicator dragDropOverwriteMode +*/ +void QAbstractItemView::setDefaultDropAction(Qt::DropAction dropAction) +{ + Q_D(QAbstractItemView); + d->defaultDropAction = dropAction; +} + +Qt::DropAction QAbstractItemView::defaultDropAction() const +{ + Q_D(const QAbstractItemView); + return d->defaultDropAction; +} + #endif // QT_NO_DRAGANDDROP /*! @@ -3297,7 +3320,9 @@ void QAbstractItemView::startDrag(Qt::DropActions supportedActions) drag->setMimeData(data); drag->setHotSpot(d->pressedPosition - rect.topLeft()); Qt::DropAction defaultDropAction = Qt::IgnoreAction; - if (supportedActions & Qt::CopyAction && dragDropMode() != QAbstractItemView::InternalMove) + if (d->defaultDropAction != Qt::IgnoreAction && (supportedActions & d->defaultDropAction)) + defaultDropAction = d->defaultDropAction; + else if (supportedActions & Qt::CopyAction && dragDropMode() != QAbstractItemView::InternalMove) defaultDropAction = Qt::CopyAction; if (drag->exec(supportedActions, defaultDropAction) == Qt::MoveAction) d->clearOrRemove(); diff --git a/src/gui/itemviews/qabstractitemview.h b/src/gui/itemviews/qabstractitemview.h index 7d5c765..b4f0957 100644 --- a/src/gui/itemviews/qabstractitemview.h +++ b/src/gui/itemviews/qabstractitemview.h @@ -74,6 +74,7 @@ class Q_GUI_EXPORT QAbstractItemView : public QAbstractScrollArea Q_PROPERTY(bool dragEnabled READ dragEnabled WRITE setDragEnabled) Q_PROPERTY(bool dragDropOverwriteMode READ dragDropOverwriteMode WRITE setDragDropOverwriteMode) Q_PROPERTY(DragDropMode dragDropMode READ dragDropMode WRITE setDragDropMode) + Q_PROPERTY(Qt::DropAction defaultDropAction READ defaultDropAction WRITE setDefaultDropAction) #endif Q_PROPERTY(bool alternatingRowColors READ alternatingRowColors WRITE setAlternatingRowColors) Q_PROPERTY(SelectionMode selectionMode READ selectionMode WRITE setSelectionMode) @@ -181,7 +182,11 @@ public: void setDragDropMode(DragDropMode behavior); DragDropMode dragDropMode() const; + + void setDefaultDropAction(Qt::DropAction dropAction); + Qt::DropAction defaultDropAction() const; #endif + void setAlternatingRowColors(bool enable); bool alternatingRowColors() const; diff --git a/src/gui/itemviews/qabstractitemview_p.h b/src/gui/itemviews/qabstractitemview_p.h index 84c0892..fcf381a 100644 --- a/src/gui/itemviews/qabstractitemview_p.h +++ b/src/gui/itemviews/qabstractitemview_p.h @@ -117,7 +117,7 @@ public: virtual void _q_columnsInserted(const QModelIndex &parent, int start, int end); virtual void _q_modelDestroyed(); virtual void _q_layoutChanged(); - + void fetchMore(); bool shouldEdit(QAbstractItemView::EditTrigger trigger, const QModelIndex &index) const; @@ -315,7 +315,7 @@ public: } return ref; } - + /** * return true if the index is registered as a QPersistentModelIndex */ @@ -356,8 +356,8 @@ public: Qt::KeyboardModifiers pressedModifiers; QPoint pressedPosition; bool pressedAlreadySelected; - - //forces the next mouseMoveEvent to send the viewportEntered signal + + //forces the next mouseMoveEvent to send the viewportEntered signal //if the mouse is over the viewport and not over an item bool viewportEnteredNeeded; @@ -377,6 +377,7 @@ public: QAbstractItemView::DragDropMode dragDropMode; bool overwrite; QAbstractItemView::DropIndicatorPosition dropIndicatorPosition; + Qt::DropAction defaultDropAction; #endif #ifdef QT_SOFTKEYS_ENABLED diff --git a/src/gui/kernel/qapplication_qws.cpp b/src/gui/kernel/qapplication_qws.cpp index 01c64f1..634f23a 100644 --- a/src/gui/kernel/qapplication_qws.cpp +++ b/src/gui/kernel/qapplication_qws.cpp @@ -232,7 +232,7 @@ QString qws_dataDir() // Get the filename of the pipe Qt for Embedded Linux uses for server/client comms Q_GUI_EXPORT QString qws_qtePipeFilename() { - return (qws_dataDir().append(QTE_PIPE)); + return QTE_PIPE(qws_display_id); } static void setMaxWindowRect(const QRect &rect) diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index d50e7e1..af9fe92 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -780,7 +780,7 @@ TCoeInputCapabilities QSymbianControl::InputCapabilities() const } #endif -void QSymbianControl::Draw(const TRect& r) const +void QSymbianControl::Draw(const TRect& controlRect) const { QWindowSurface *surface = qwidget->windowSurface(); QPaintEngine *engine = surface ? surface->paintDevice()->paintEngine() : NULL; @@ -788,6 +788,11 @@ void QSymbianControl::Draw(const TRect& r) const if (!engine) return; + // Map source rectangle into coordinates of the backing store. + const QPoint controlBase(controlRect.iTl.iX, controlRect.iTl.iY); + const QPoint backingStoreBase = qwidget->mapTo(qwidget->window(), controlBase); + const TRect backingStoreRect(TPoint(backingStoreBase.x(), backingStoreBase.y()), controlRect.Size()); + if (engine->type() == QPaintEngine::Raster) { QS60WindowSurface *s60Surface = static_cast<QS60WindowSurface *>(qwidget->windowSurface()); CFbsBitmap *bitmap = s60Surface->symbianBitmap(); @@ -796,10 +801,10 @@ void QSymbianControl::Draw(const TRect& r) const if(!qwidget->d_func()->extraData()->disableBlit) { if (qwidget->d_func()->isOpaque) gc.SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha); - gc.BitBlt(r.iTl, bitmap, r); - } + gc.BitBlt(controlRect.iTl, bitmap, backingStoreRect); + } } else { - surface->flush(qwidget, QRegion(qt_TRect2QRect(r)), QPoint()); + surface->flush(qwidget, QRegion(qt_TRect2QRect(backingStoreRect)), QPoint()); } } diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h index 6c879be..c06ef73 100644 --- a/src/gui/kernel/qwidget_p.h +++ b/src/gui/kernel/qwidget_p.h @@ -294,6 +294,7 @@ public: void setMask_sys(const QRegion &); #ifdef Q_OS_SYMBIAN void setSoftKeys_sys(const QList<QAction*> &softkeys); + void activateSymbianWindow(); #endif void raise_sys(); diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp index 05db8ca..3328cee 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -194,8 +194,8 @@ void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &) } if (jump && data.winid) { - RWindow *const window = static_cast<RWindow *>(data.winid->DrawableWindow()); - window->Invalidate(TRect(0, 0, wrect.width(), wrect.height())); + RWindow *const window = static_cast<RWindow *>(data.winid->DrawableWindow()); + window->Invalidate(TRect(0, 0, wrect.width(), wrect.height())); } } @@ -411,6 +411,14 @@ void QWidgetPrivate::create_sys(WId window, bool /* initializeWindow */, bool de int x, y, w, h; data.crect.getRect(&x, &y, &w, &h); control->SetRect(TRect(TPoint(x, y), TSize(w, h))); + + RDrawableWindow *const drawableWindow = control->DrawableWindow(); + // Request mouse move events. + drawableWindow->PointerFilter(EPointerFilterEnterExit + | EPointerFilterMove | EPointerFilterDrag, 0); + + if (q->isVisible() && q->testAttribute(Qt::WA_Mapped)) + activateSymbianWindow(); } if (destroyw) { @@ -440,12 +448,11 @@ void QWidgetPrivate::show_sys() } if (q->internalWinId()) { - - QSymbianControl *id = static_cast<QSymbianControl *>(q->internalWinId()); - if (!extra->activated) { - QT_TRAP_THROWING(id->ActivateL()); - extra->activated = 1; - } + if (!extra->activated) + activateSymbianWindow(); + + QSymbianControl *id = static_cast<QSymbianControl *>(q->internalWinId()); + id->MakeVisible(true); if(q->isWindow()) @@ -461,6 +468,19 @@ void QWidgetPrivate::show_sys() invalidateBuffer(q->rect()); } +void QWidgetPrivate::activateSymbianWindow() +{ + Q_Q(QWidget); + + Q_ASSERT(q->testAttribute(Qt::WA_WState_Created)); + Q_ASSERT(q->testAttribute(Qt::WA_Mapped)); + Q_ASSERT(!extra->activated); + + WId id = q->internalWinId(); + QT_TRAP_THROWING(id->ActivateL()); + extra->activated = 1; +} + void QWidgetPrivate::hide_sys() { Q_Q(QWidget); @@ -1016,9 +1036,9 @@ QPoint QWidget::mapFromGlobal(const QPoint &pos) const } // Native window case - const TPoint widgetScreenOffset = internalWinId()->PositionRelativeToScreen(); - const QPoint widgetPos = pos - QPoint(widgetScreenOffset.iX, widgetScreenOffset.iY); - return widgetPos; + const TPoint widgetScreenOffset = internalWinId()->PositionRelativeToScreen(); + const QPoint widgetPos = pos - QPoint(widgetScreenOffset.iX, widgetScreenOffset.iY); + return widgetPos; } void QWidget::setWindowState(Qt::WindowStates newstate) diff --git a/src/gui/painting/qdrawutil.cpp b/src/gui/painting/qdrawutil.cpp index 716300e..ac3796a 100644 --- a/src/gui/painting/qdrawutil.cpp +++ b/src/gui/painting/qdrawutil.cpp @@ -1225,7 +1225,7 @@ void qDrawBorderPixmap(QPainter *painter, const QRect &targetRect, const QMargin // horizontal edges switch (rules.horizontal) { - case Qt::Stretch: + case Qt::StretchTile: if (targetMargins.top() > 0 && sourceMargins.top() > 0) { // top const QRect targetTopRect(targetCenterLeft, targetTop, targetCenterWidth, targetMargins.top()); const QRect sourceTopRect(sourceCenterLeft, sourceTop, sourceCenterWidth, sourceMargins.top()); @@ -1237,7 +1237,7 @@ void qDrawBorderPixmap(QPainter *painter, const QRect &targetRect, const QMargin qDrawPixmap(painter, targetBottomRect, pixmap, sourceBottomRect); } break; - case Qt::Repeat: + case Qt::RepeatTile: if (targetMargins.top() > 0 && sourceMargins.top() > 0) { // top const QRect targetTopRect(targetCenterLeft, targetTop, targetCenterWidth, targetMargins.top()); const QRect sourceTopRect(sourceCenterLeft, sourceTop, sourceCenterWidth, sourceMargins.top()); @@ -1249,7 +1249,7 @@ void qDrawBorderPixmap(QPainter *painter, const QRect &targetRect, const QMargin qDrawHorizontallyRepeatedPixmap(painter, targetBottomRect, pixmap, sourceBottomRect); } break; - case Qt::Round: + case Qt::RoundTile: if (targetMargins.top() > 0 && sourceMargins.top() > 0) { // top const QRect targetTopRect(targetCenterLeft, targetTop, targetCenterWidth, targetMargins.top()); const QRect sourceTopRect(sourceCenterLeft, sourceTop, sourceCenterWidth, sourceMargins.top()); @@ -1265,7 +1265,7 @@ void qDrawBorderPixmap(QPainter *painter, const QRect &targetRect, const QMargin // vertical edges switch (rules.vertical) { - case Qt::Stretch: + case Qt::StretchTile: if (targetMargins.left() > 0 && sourceMargins.left() > 0) { // left const QRect targetLeftRect(targetLeft, targetCenterTop, targetMargins.left(), targetCenterHeight); const QRect sourceLeftRect(sourceLeft, sourceCenterTop, sourceMargins.left(), sourceCenterHeight); @@ -1277,7 +1277,7 @@ void qDrawBorderPixmap(QPainter *painter, const QRect &targetRect, const QMargin qDrawPixmap(painter, targetRightRect, pixmap, sourceRightRect); } break; - case Qt::Repeat: + case Qt::RepeatTile: if (targetMargins.left() > 0 && sourceMargins.left() > 0) { // left const QRect targetLeftRect(targetLeft, targetCenterTop, targetMargins.left(), targetCenterHeight); const QRect sourceLeftRect(sourceLeft, sourceCenterTop, sourceMargins.left(), sourceCenterHeight); @@ -1289,7 +1289,7 @@ void qDrawBorderPixmap(QPainter *painter, const QRect &targetRect, const QMargin qDrawVerticallyRepeatedPixmap(painter, targetRightRect, pixmap, sourceRightRect); } break; - case Qt::Round: + case Qt::RoundTile: if (targetMargins.left() > 0 && sourceMargins.left() > 0) { // left const QRect targetLeftRect(targetLeft, targetCenterTop, targetMargins.left(), targetCenterHeight); const QRect sourceLeftRect(sourceLeft, sourceCenterTop, sourceMargins.left(), sourceCenterHeight); @@ -1308,41 +1308,41 @@ void qDrawBorderPixmap(QPainter *painter, const QRect &targetRect, const QMargin const QRect targetCenterRect(targetCenterLeft, targetCenterTop, targetCenterWidth, targetCenterHeight); const QRect sourceCenterRect(sourceCenterLeft, sourceCenterTop, sourceCenterWidth, sourceCenterHeight); switch (rules.horizontal) { - case Qt::Stretch: + case Qt::StretchTile: switch (rules.vertical) { - case Qt::Stretch: // stretch stretch + case Qt::StretchTile: // stretch stretch qDrawPixmap(painter, targetCenterRect, pixmap, sourceCenterRect); break; - case Qt::Repeat: // stretch repeat + case Qt::RepeatTile: // stretch repeat qVerticalRepeat(painter, targetCenterRect, pixmap, sourceCenterRect, qDrawPixmap); break; - case Qt::Round: // stretch round + case Qt::RoundTile: // stretch round qVerticalRound(painter, targetCenterRect, pixmap, sourceCenterRect, qDrawPixmap); break; } break; - case Qt::Repeat: + case Qt::RepeatTile: switch (rules.vertical) { - case Qt::Stretch: // repeat stretch + case Qt::StretchTile: // repeat stretch qHorizontalRepeat(painter, targetCenterRect, pixmap, sourceCenterRect, qDrawPixmap); break; - case Qt::Repeat: // repeat repeat + case Qt::RepeatTile: // repeat repeat qVerticalRepeat(painter, targetCenterRect, pixmap, sourceCenterRect, qDrawHorizontallyRepeatedPixmap); break; - case Qt::Round: // repeat round + case Qt::RoundTile: // repeat round qVerticalRound(painter, targetCenterRect, pixmap, sourceCenterRect, qDrawHorizontallyRepeatedPixmap); break; } break; - case Qt::Round: + case Qt::RoundTile: switch (rules.vertical) { - case Qt::Stretch: // round stretch + case Qt::StretchTile: // round stretch qHorizontalRound(painter, targetCenterRect, pixmap, sourceCenterRect, qDrawPixmap); break; - case Qt::Repeat: // round repeat + case Qt::RepeatTile: // round repeat qHorizontalRound(painter, targetCenterRect, pixmap, sourceCenterRect, qDrawVerticallyRepeatedPixmap); break; - case Qt::Round: // round round + case Qt::RoundTile: // round round qHorizontalRound(painter, targetCenterRect, pixmap, sourceCenterRect, qDrawVerticallyRoundedPixmap); break; } diff --git a/src/gui/painting/qdrawutil.h b/src/gui/painting/qdrawutil.h index 3a2dd0e..22a57e9 100644 --- a/src/gui/painting/qdrawutil.h +++ b/src/gui/painting/qdrawutil.h @@ -137,22 +137,22 @@ struct QTileRules { inline QTileRules(Qt::TileRule horizontalRule, Qt::TileRule verticalRule) : horizontal(horizontalRule), vertical(verticalRule) {} - inline QTileRules(Qt::TileRule rule = Qt::Stretch) + inline QTileRules(Qt::TileRule rule = Qt::StretchTile) : horizontal(rule), vertical(rule) {} Qt::TileRule horizontal; Qt::TileRule vertical; }; -Q_GUI_EXPORT void qDrawBorderPixmap(QPainter *painter, - const QRect &targetRect, - const QMargins &targetMargins, +Q_GUI_EXPORT void qDrawBorderPixmap(QPainter *painter, + const QRect &targetRect, + const QMargins &targetMargins, const QPixmap &pixmap, - const QRect &sourceRect, - const QMargins &sourceMargins, + const QRect &sourceRect, + const QMargins &sourceMargins, const QTileRules &rules = QTileRules()); -inline void qDrawBorderPixmap(QPainter *painter, - const QRect &target, - const QMargins &margins, +inline void qDrawBorderPixmap(QPainter *painter, + const QRect &target, + const QMargins &margins, const QPixmap &pixmap) { qDrawBorderPixmap(painter, target, margins, pixmap, pixmap.rect(), margins); diff --git a/src/gui/styles/qstylesheetstyle.cpp b/src/gui/styles/qstylesheetstyle.cpp index 0f3a88b..707b05e 100644 --- a/src/gui/styles/qstylesheetstyle.cpp +++ b/src/gui/styles/qstylesheetstyle.cpp @@ -1126,7 +1126,7 @@ void QRenderRule::fixupBorder(int nativeWidth) void QRenderRule::drawBorderImage(QPainter *p, const QRect& rect) { static const Qt::TileRule tileMode2TileRule[] = { - Qt::Stretch, Qt::Round, Qt::Stretch, Qt::Repeat, Qt::Stretch }; + Qt::StretchTile, Qt::RoundTile, Qt::StretchTile, Qt::RepeatTile, Qt::StretchTile }; const QStyleSheetBorderImageData *borderImageData = border()->borderImage(); const int *targetBorders = border()->borders; diff --git a/src/gui/widgets/qabstractslider.cpp b/src/gui/widgets/qabstractslider.cpp index c3289b4..28f3be3 100644 --- a/src/gui/widgets/qabstractslider.cpp +++ b/src/gui/widgets/qabstractslider.cpp @@ -693,13 +693,8 @@ void QAbstractSlider::wheelEvent(QWheelEvent * e) if (e->orientation() != d->orientation && !rect().contains(e->pos())) return; - int step = qMin(QApplication::wheelScrollLines() * d->singleStep, d->pageStep); - if ((e->modifiers() & Qt::ControlModifier) || (e->modifiers() & Qt::ShiftModifier)) - step = d->pageStep; - - qreal currentOffset = qreal(e->delta()) * step / 120; + qreal currentOffset = qreal(e->delta()) / 120; d->offset_accumulated += d->invertedControls ? -currentOffset : currentOffset; - if (int(d->offset_accumulated) == 0) { // QAbstractSlider works on integer values. So if the accumulated // offset is less than +/- 1, we need to wait until we get more @@ -708,8 +703,20 @@ void QAbstractSlider::wheelEvent(QWheelEvent * e) return; } + // Calculate the number of steps to scroll (per 15 degrees of rotate): +#ifdef Q_OS_MAC + // On mac, since mouse wheel scrolling is accelerated and + // fine tuned by the OS, we skip applying acceleration: + int stepsToScroll = int(d->offset_accumulated); +#else + int step = qMin(QApplication::wheelScrollLines() * d->singleStep, d->pageStep); + if ((e->modifiers() & Qt::ControlModifier) || (e->modifiers() & Qt::ShiftModifier)) + step = d->pageStep; + int stepsToScroll = step * int(d->offset_accumulated); +#endif + int prevValue = d->value; - d->position = d->overflowSafeAdd(int(d->offset_accumulated)); // value will be updated by triggerAction() + d->position = d->overflowSafeAdd(stepsToScroll); // value will be updated by triggerAction() triggerAction(SliderMove); if (prevValue == d->value) { diff --git a/src/gui/widgets/qlabel.cpp b/src/gui/widgets/qlabel.cpp index 5ff323a..5ba0571 100644 --- a/src/gui/widgets/qlabel.cpp +++ b/src/gui/widgets/qlabel.cpp @@ -886,7 +886,18 @@ void QLabel::focusInEvent(QFocusEvent *ev) void QLabel::focusOutEvent(QFocusEvent *ev) { Q_D(QLabel); - d->sendControlEvent(ev); + if (d->control) { + d->sendControlEvent(ev); + QTextCursor cursor = d->control->textCursor(); + Qt::FocusReason reason = ev->reason(); + if (reason != Qt::ActiveWindowFocusReason + && reason != Qt::PopupFocusReason + && cursor.hasSelection()) { + cursor.clearSelection(); + d->control->setTextCursor(cursor); + } + } + QFrame::focusOutEvent(ev); } diff --git a/src/gui/widgets/qtextedit.cpp b/src/gui/widgets/qtextedit.cpp index 3fe9bb4..dc78fd5 100644 --- a/src/gui/widgets/qtextedit.cpp +++ b/src/gui/widgets/qtextedit.cpp @@ -174,13 +174,8 @@ void QTextEditPrivate::init(const QString &html) if (!html.isEmpty()) control->setHtml(html); -#ifdef Q_OS_MAC - hbar->setSingleStep(1); - vbar->setSingleStep(1); -#else hbar->setSingleStep(20); vbar->setSingleStep(20); -#endif viewport->setBackgroundRole(QPalette::Base); q->setAcceptDrops(true); |