postpone refreshing of the currently selected item

svn path=/trunk/KDE/kdelibs/; revision=1030620
This commit is contained in:
Jacopo De Simoi 2009-10-02 19:08:36 +00:00
parent b8d35a709c
commit 9a1a247591
2 changed files with 11 additions and 2 deletions

View File

@ -20,6 +20,7 @@
#include "itembackground.h"
#include <QPainter>
#include <QTimer>
#include <QStyleOptionGraphicsItem>
#include <kdebug.h>
@ -41,6 +42,7 @@ public:
void animationUpdate(qreal progress);
void targetDestroyed(QObject*);
void frameSvgChanged();
void refreshCurrentTarget();
ItemBackground * const q;
QGraphicsItem *target;
@ -172,7 +174,8 @@ bool ItemBackground::eventFilter(QObject *watched, QEvent *event)
if (watched == targetWidget) {
if (event->type() == QEvent::GraphicsSceneResize ||
event->type() == QEvent::GraphicsSceneMove) {
setTargetItem(targetWidget);
// We need to wait for the parent widget to resize...
QTimer::singleShot(0, this, SLOT(refreshCurrentTarget()) );
}
}
@ -183,7 +186,7 @@ bool ItemBackground::sceneEventFilter(QGraphicsItem *watched, QEvent *event)
{
if (watched == d->target) {
if (event->type() == QEvent::GraphicsSceneMove) {
setTargetItem(d->target);
QTimer::singleShot(0, this, SLOT(refreshCurrentTarget()) );
}
}
@ -281,6 +284,11 @@ void ItemBackgroundPrivate::frameSvgChanged()
emit q->appearanceChanged();
}
void ItemBackgroundPrivate::refreshCurrentTarget()
{
q->setTargetItem(target);
}
} // Plasma namespace

View File

@ -107,6 +107,7 @@ private:
Q_PRIVATE_SLOT(d, void animationUpdate(qreal progress))
Q_PRIVATE_SLOT(d, void targetDestroyed(QObject*))
Q_PRIVATE_SLOT(d, void frameSvgChanged())
Q_PRIVATE_SLOT(d, void refreshCurrentTarget())
friend class ItemBackgroundPrivate;
ItemBackgroundPrivate * const d;