better wait for the parentItem to resize before calculating the rect of the item to be visible

svn path=/trunk/KDE/kdelibs/; revision=1057266
This commit is contained in:
Giulio Camuffo 2009-12-01 20:49:34 +00:00
parent c95a699031
commit 7e3bdb55e5
2 changed files with 12 additions and 3 deletions

View File

@ -214,6 +214,14 @@ public:
(widget->pos() + delta).toPoint()); (widget->pos() + delta).toPoint());
} }
void makeItemVisible()
{
QRectF rect(widget->mapFromScene(itemToBeVisible->scenePos()), itemToBeVisible->boundingRect().size());
rectToBeVisible = rect;
makeRectVisible();
}
void cleanupDragHandles(QObject *destroyed) void cleanupDragHandles(QObject *destroyed)
{ {
dragHandles.remove(static_cast<QGraphicsWidget *>(destroyed)); dragHandles.remove(static_cast<QGraphicsWidget *>(destroyed));
@ -233,6 +241,7 @@ public:
ScrollBar *horizontalScrollBar; ScrollBar *horizontalScrollBar;
Qt::ScrollBarPolicy horizontalScrollBarPolicy; Qt::ScrollBarPolicy horizontalScrollBarPolicy;
QString styleSheet; QString styleSheet;
QGraphicsItem *itemToBeVisible;
QRectF rectToBeVisible; QRectF rectToBeVisible;
QPointF dragHandleClicked; QPointF dragHandleClicked;
QSet<QGraphicsWidget *>dragHandles; QSet<QGraphicsWidget *>dragHandles;
@ -351,11 +360,10 @@ void ScrollWidget::ensureItemVisible(QGraphicsItem *item)
parentOfItem = parentOfItem->parentItem(); parentOfItem = parentOfItem->parentItem();
} }
QRectF rect(d->widget->mapFromScene(item->scenePos()), item->boundingRect().size()); d->itemToBeVisible = item;
d->rectToBeVisible = rect;
// 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(makeRectVisible())); QTimer::singleShot(0, this, SLOT(makeItemVisible()));
} }
void ScrollWidget::registerAsDragHandle(QGraphicsWidget *item) void ScrollWidget::registerAsDragHandle(QGraphicsWidget *item)

View File

@ -198,6 +198,7 @@ private:
Q_PRIVATE_SLOT(d, void verticalScroll(int value)) Q_PRIVATE_SLOT(d, void verticalScroll(int value))
Q_PRIVATE_SLOT(d, void horizontalScroll(int value)) Q_PRIVATE_SLOT(d, void horizontalScroll(int value))
Q_PRIVATE_SLOT(d, void makeRectVisible()) Q_PRIVATE_SLOT(d, void makeRectVisible())
Q_PRIVATE_SLOT(d, void makeItemVisible())
Q_PRIVATE_SLOT(d, void cleanupDragHandles(QObject *destroyed)) Q_PRIVATE_SLOT(d, void cleanupDragHandles(QObject *destroyed))
}; };