delay only in the case the item to be visible is a qgraphicswidget, so we can guard the temp pointer with a weak one

BUG:219475

svn path=/trunk/KDE/kdelibs/; revision=1064800
This commit is contained in:
Marco Martin 2009-12-21 20:29:08 +00:00
parent 3a27e22612
commit 923d772a85

View File

@ -268,7 +268,7 @@ public:
(widget.data()->pos() + delta).toPoint()); (widget.data()->pos() + delta).toPoint());
} }
void makeItemVisible() void makeItemVisible(QGraphicsItem *itemToBeVisible)
{ {
if (!widget) { if (!widget) {
return; return;
@ -280,6 +280,13 @@ public:
makeRectVisible(); makeRectVisible();
} }
void makeItemVisible()
{
if (widgetToBeVisible) {
makeItemVisible(widgetToBeVisible.data());
}
}
void cleanupDragHandles(QObject *destroyed) void cleanupDragHandles(QObject *destroyed)
{ {
dragHandles.remove(static_cast<QGraphicsWidget *>(destroyed)); dragHandles.remove(static_cast<QGraphicsWidget *>(destroyed));
@ -307,7 +314,7 @@ public:
ScrollBar *horizontalScrollBar; ScrollBar *horizontalScrollBar;
Qt::ScrollBarPolicy horizontalScrollBarPolicy; Qt::ScrollBarPolicy horizontalScrollBarPolicy;
QString styleSheet; QString styleSheet;
QGraphicsItem *itemToBeVisible; QWeakPointer<QGraphicsWidget> widgetToBeVisible;
QRectF rectToBeVisible; QRectF rectToBeVisible;
QPointF dragHandleClicked; QPointF dragHandleClicked;
QSet<QGraphicsWidget *>dragHandles; QSet<QGraphicsWidget *>dragHandles;
@ -415,10 +422,16 @@ void ScrollWidget::ensureItemVisible(QGraphicsItem *item)
parentOfItem = parentOfItem->parentItem(); parentOfItem = parentOfItem->parentItem();
} }
d->itemToBeVisible = item; //since we can't ensure it'll stay alive we can delay only if it's a qgraphicswidget
QGraphicsWidget *widget = qgraphicsitem_cast<QGraphicsWidget *>(item);
if (widget) {
d->widgetToBeVisible = widget;
// We need to wait for the parent item to resize... // We need to wait for the parent item to resize...
QTimer::singleShot(0, this, SLOT(makeItemVisible())); QTimer::singleShot(0, this, SLOT(makeItemVisible()));
} else {
d->makeItemVisible(item);
}
} }
void ScrollWidget::registerAsDragHandle(QGraphicsWidget *item) void ScrollWidget::registerAsDragHandle(QGraphicsWidget *item)