fix setTarget and setTargetItem behaviour

svn path=/trunk/KDE/kdelibs/; revision=1017557
This commit is contained in:
Marco Martin 2009-08-30 21:56:33 +00:00
parent 40db26d969
commit a93ab19864

View File

@ -61,7 +61,7 @@ ItemBackground::ItemBackground(QGraphicsWidget *parent)
d->frameSvg->setElementPrefix("hover"); d->frameSvg->setElementPrefix("hover");
setAcceptedMouseButtons(0); setAcceptedMouseButtons(0);
setZValue(-800);
} }
ItemBackground::~ItemBackground() ItemBackground::~ItemBackground()
@ -69,15 +69,17 @@ ItemBackground::~ItemBackground()
void ItemBackground::setTarget(const QRectF &newGeometry) void ItemBackground::setTarget(const QRectF &newGeometry)
{ {
if (!isVisible()) {
return;
}
qreal left, top, right, bottom; qreal left, top, right, bottom;
d->frameSvg->getMargins(left, top, right, bottom); d->frameSvg->getMargins(left, top, right, bottom);
d->oldGeometry = geometry(); d->oldGeometry = geometry();
d->newGeometry = newGeometry.adjusted(-left, -top, right, bottom); d->newGeometry = newGeometry.adjusted(-left, -top, right, bottom);
if (!isVisible()) {
setGeometry(d->newGeometry);
return;
}
QGraphicsWidget *pw = parentWidget(); QGraphicsWidget *pw = parentWidget();
if (pw) { if (pw) {
d->newGeometry = d->newGeometry.intersected(QRectF(QPointF(0,0), pw->size())); d->newGeometry = d->newGeometry.intersected(QRectF(QPointF(0,0), pw->size()));
@ -95,7 +97,9 @@ void ItemBackground::setTarget(const QRectF &newGeometry)
void ItemBackground::setTargetItem(QGraphicsItem *target) void ItemBackground::setTargetItem(QGraphicsItem *target)
{ {
setTarget(target->boundingRect()); QRectF rect = target->boundingRect();
rect.setTopLeft(target->pos());
setTarget(rect);
} }
QVariant ItemBackground::itemChange(GraphicsItemChange change, const QVariant &value) QVariant ItemBackground::itemChange(GraphicsItemChange change, const QVariant &value)