avoid some unecesary calls, write an if as a switch

svn path=/trunk/KDE/kdelibs/; revision=1178749
This commit is contained in:
Aaron J. Seigo 2010-09-23 20:24:17 +00:00
parent 6e14d1c773
commit 4946385727

View File

@ -121,7 +121,9 @@ bool FocusIndicator::eventFilter(QObject *watched, QEvent *event)
m_isUnderMouse = false; m_isUnderMouse = false;
} }
if (!m_parent->hasFocus() && event->type() == QEvent::GraphicsSceneHoverEnter) { switch (event->type()) {
case QEvent::GraphicsSceneHoverEnter:
if (!m_parent->hasFocus()) {
m_prefix = m_customPrefix % "hover"; m_prefix = m_customPrefix % "hover";
syncGeometry(); syncGeometry();
m_hoverAnimation->stop(); m_hoverAnimation->stop();
@ -136,7 +138,11 @@ bool FocusIndicator::eventFilter(QObject *watched, QEvent *event)
} }
m_hoverAnimation->start(); m_hoverAnimation->start();
} else if (!m_parent->hasFocus() && event->type() == QEvent::GraphicsSceneHoverLeave) { }
break;
case QEvent::GraphicsSceneHoverLeave:
if (!m_parent->hasFocus()) {
m_prefix = m_customPrefix % "shadow"; m_prefix = m_customPrefix % "shadow";
syncGeometry(); syncGeometry();
m_hoverAnimation->stop(); m_hoverAnimation->stop();
@ -151,9 +157,14 @@ bool FocusIndicator::eventFilter(QObject *watched, QEvent *event)
m_hoverAnimation->setProperty("targetPixmap", m_background->pixmap(m_customPrefix % "shadow")); m_hoverAnimation->setProperty("targetPixmap", m_background->pixmap(m_customPrefix % "shadow"));
} }
m_hoverAnimation->start(); m_hoverAnimation->start();
} else if (event->type() == QEvent::GraphicsSceneResize) { }
break;
case QEvent::GraphicsSceneResize:
syncGeometry(); syncGeometry();
} else if (event->type() == QEvent::FocusIn) { break;
case QEvent::FocusIn:
m_prefix = m_customPrefix % "focus"; m_prefix = m_customPrefix % "focus";
syncGeometry(); syncGeometry();
m_hoverAnimation->stop(); m_hoverAnimation->stop();
@ -169,7 +180,10 @@ bool FocusIndicator::eventFilter(QObject *watched, QEvent *event)
} }
m_hoverAnimation->start(); m_hoverAnimation->start();
} else if (!m_isUnderMouse && event->type() == QEvent::FocusOut) { break;
case QEvent::FocusOut:
if (!m_isUnderMouse) {
m_prefix = m_customPrefix % "shadow"; m_prefix = m_customPrefix % "shadow";
syncGeometry(); syncGeometry();
m_hoverAnimation->stop(); m_hoverAnimation->stop();
@ -186,17 +200,28 @@ bool FocusIndicator::eventFilter(QObject *watched, QEvent *event)
m_hoverAnimation->start(); m_hoverAnimation->start();
} }
break;
default:
break;
};
return false; return false;
} }
void FocusIndicator::resizeEvent(QGraphicsSceneResizeEvent *) void FocusIndicator::resizeEvent(QGraphicsSceneResizeEvent *)
{ {
if (m_background->hasElementPrefix(m_testPrefix)) { if (m_background->hasElementPrefix(m_customPrefix % "shadow")) {
m_background->setElementPrefix(m_customPrefix % "shadow"); m_background->setElementPrefix(m_customPrefix % "shadow");
m_background->resizeFrame(size()); m_background->resizeFrame(size());
}
if (m_background->hasElementPrefix(m_customPrefix % "hover")) {
m_background->setElementPrefix(m_customPrefix % "hover"); m_background->setElementPrefix(m_customPrefix % "hover");
m_background->resizeFrame(size()); m_background->resizeFrame(size());
}
if (m_background->hasElementPrefix(m_customPrefix % "focus")) {
m_background->setElementPrefix(m_customPrefix % "focus"); m_background->setElementPrefix(m_customPrefix % "focus");
m_background->resizeFrame(size()); m_background->resizeFrame(size());
} }