summaryrefslogtreecommitdiffstats
path: root/src/gui/graphicsview/qgraphicsitem.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/graphicsview/qgraphicsitem.cpp')
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp32
1 files changed, 26 insertions, 6 deletions
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index 2685b86..738c6e3 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -1658,7 +1658,7 @@ void QGraphicsItem::setFlags(GraphicsItemFlags flags)
d_ptr->scene->d_func()->index->itemChange(this, ItemFlagsChange, quint32(flags));
// Flags that alter the geometry of the item (or its children).
- const quint32 geomChangeFlagsMask = (ItemClipsChildrenToShape | ItemClipsToShape | ItemIgnoresTransformations);
+ const quint32 geomChangeFlagsMask = (ItemClipsChildrenToShape | ItemClipsToShape | ItemIgnoresTransformations | ItemIsSelectable);
bool fullUpdate = (quint32(flags) & geomChangeFlagsMask) != (d_ptr->flags & geomChangeFlagsMask);
if (fullUpdate)
d_ptr->paintedViewBoundingRectsNeedRepaint = 1;
@@ -9157,10 +9157,14 @@ void QGraphicsPixmapItem::setOffset(const QPointF &offset)
QRectF QGraphicsPixmapItem::boundingRect() const
{
Q_D(const QGraphicsPixmapItem);
- qreal pw = 1.0;
if (d->pixmap.isNull())
return QRectF();
- return QRectF(d->offset, d->pixmap.size()).adjusted(-pw/2, -pw/2, pw/2, pw/2);
+ if (d->flags & ItemIsSelectable) {
+ qreal pw = 1.0;
+ return QRectF(d->offset, d->pixmap.size()).adjusted(-pw/2, -pw/2, pw/2, pw/2);
+ } else {
+ return QRectF(d->offset, d->pixmap.size());
+ }
}
/*!
@@ -10679,7 +10683,8 @@ void QGraphicsItemEffectSourcePrivate::draw(QPainter *painter)
}
}
-QPixmap QGraphicsItemEffectSourcePrivate::pixmap(Qt::CoordinateSystem system, QPoint *offset) const
+QPixmap QGraphicsItemEffectSourcePrivate::pixmap(Qt::CoordinateSystem system, QPoint *offset,
+ QGraphicsEffectSource::PixmapPadMode mode) const
{
const bool deviceCoordinates = (system == Qt::DeviceCoordinates);
if (!info && deviceCoordinates) {
@@ -10693,7 +10698,17 @@ QPixmap QGraphicsItemEffectSourcePrivate::pixmap(Qt::CoordinateSystem system, QP
QGraphicsScenePrivate *scened = item->d_ptr->scene->d_func();
const QRectF sourceRect = boundingRect(system);
- QRect effectRect = item->graphicsEffect()->boundingRectFor(sourceRect).toAlignedRect();
+ QRect effectRect;
+
+ if (mode == QGraphicsEffectSource::ExpandToEffectRectPadMode) {
+ effectRect = item->graphicsEffect()->boundingRectFor(sourceRect).toAlignedRect();
+ } else if (mode == QGraphicsEffectSource::ExpandToTransparentBorderPadMode) {
+ // adjust by 1.5 to account for cosmetic pens
+ effectRect = sourceRect.adjusted(-1.5, -1.5, 1.5, 1.5).toAlignedRect();
+ } else {
+ effectRect = sourceRect.toAlignedRect();
+ }
+
if (offset)
*offset = effectRect.topLeft();
@@ -10721,10 +10736,15 @@ QPixmap QGraphicsItemEffectSourcePrivate::pixmap(Qt::CoordinateSystem system, QP
effectRect.setBottom(deviceHeight -1);
}
-
if (effectRect.isEmpty())
return QPixmap();
+ if (system == Qt::LogicalCoordinates
+ && effectRect.size() == sourceRect.size()
+ && isPixmap()) {
+ return static_cast<QGraphicsPixmapItem *>(item)->pixmap();
+ }
+
QPixmap pixmap(effectRect.size());
pixmap.fill(Qt::transparent);
QPainter pixmapPainter(&pixmap);