From 84a92918a9ca74925260d8c73bf8873b2709e85d Mon Sep 17 00:00:00 2001 From: "Aaron J. Seigo" Date: Wed, 16 Jul 2008 21:44:19 +0000 Subject: [PATCH] * move the private slots to the private class * corrections to the on-destruction handler svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=833491 --- tooltipmanager.cpp | 70 +++++++++++++++++++++++++++++----------------- tooltipmanager.h | 12 ++------ 2 files changed, 46 insertions(+), 36 deletions(-) diff --git a/tooltipmanager.cpp b/tooltipmanager.cpp index f460bbfcd..951249b29 100644 --- a/tooltipmanager.cpp +++ b/tooltipmanager.cpp @@ -52,10 +52,20 @@ public : { } - + void showToolTip(); void resetShownState(); + /** + * called when the theme of plasma has change + */ + void themeUpdated(); + /** + * called when a widget inside the tooltip manager is deleted + */ + void onWidgetDestroyed(QObject * object); + + QGraphicsWidget *currentWidget; bool isShown; bool delayedHide; @@ -85,7 +95,7 @@ ToolTipManager::ToolTipManager(QObject* parent) d(new ToolTipManagerPrivate) { connect(Plasma::Theme::defaultTheme(), SIGNAL(themeChanged()), this, SLOT(themeUpdated())); - themeUpdated(); + d->themeUpdated(); d->showTimer = new QTimer(this); d->showTimer->setSingleShot(true); @@ -188,30 +198,37 @@ bool ToolTipManager::widgetHasToolTip(QGraphicsWidget *widget) return d->tooltips.contains(widget); } -void ToolTipManager::themeUpdated() +void ToolTipManagerPrivate::themeUpdated() { - QMapIterator iterator(d->tooltips); + QMapIterator iterator(tooltips); while (iterator.hasNext()) { iterator.next(); iterator.value()->updateTheme(); } } -void ToolTipManager::onWidgetDestroyed(QObject * object) +void ToolTipManagerPrivate::onWidgetDestroyed(QObject *object) { - if (object) { - QMapIterator iterator(d->tooltips); - while (iterator.hasNext()) { - iterator.next(); - if (iterator.key() == object) { - ToolTip * tooltip = iterator.value(); - d->tooltips.remove(iterator.key()); - d->showTimer->stop(); // stop the timer to show the tooltip - d->delayedHide = false; - d->currentWidget = 0; - tooltip->hide(); - delete tooltip; - } + if (!object) { + return; + } + + QGraphicsWidget *w = static_cast(object); + + if (currentWidget == w) { + currentWidget = 0; + showTimer->stop(); // stop the timer to show the tooltip + delayedHide = false; + } + + QMapIterator iterator(tooltips); + while (iterator.hasNext()) { + iterator.next(); + if (iterator.key() == w) { + ToolTip * tooltip = iterator.value(); + tooltips.remove(iterator.key()); + tooltip->hide(); + delete tooltip; } } } @@ -219,13 +236,13 @@ void ToolTipManager::onWidgetDestroyed(QObject * object) void ToolTipManagerPrivate::resetShownState() { if (currentWidget) { - ToolTip * tooltip = tooltips.value(currentWidget); - if (tooltip && (!tooltip->isVisible() || delayedHide)) { - //One might have moused out and back in again - delayedHide = false; - isShown = false; - tooltip->hide(); - currentWidget = 0; + ToolTip * tooltip = tooltips.value(currentWidget); + if (tooltip && (!tooltip->isVisible() || delayedHide)) { + //One might have moused out and back in again + delayedHide = false; + isShown = false; + tooltip->hide(); + currentWidget = 0; } } } @@ -309,4 +326,5 @@ QPoint ToolTipManager::popupPosition(const QGraphicsItem * item, const QSize &s) } -#include "tooltipmanager.moc" \ No newline at end of file +#include "tooltipmanager.moc" + diff --git a/tooltipmanager.h b/tooltipmanager.h index 801f7f9d9..f9233405c 100644 --- a/tooltipmanager.h +++ b/tooltipmanager.h @@ -140,21 +140,13 @@ namespace Plasma */ static QPoint popupPosition(const QGraphicsItem * item, const QSize &s); - private Q_SLOTS: - /** - * @internal called when the theme of plasma has change - */ - void themeUpdated(); - /** - * @internal called when a widget inside the tooltip manager is deleted - */ - void onWidgetDestroyed(QObject * object); - private: friend class ToolTipManagerSingleton; ToolTipManagerPrivate* const d; Q_PRIVATE_SLOT(d, void showToolTip()) Q_PRIVATE_SLOT(d, void resetShownState()) + Q_PRIVATE_SLOT(d, void onWidgetDestroyed(QObject*)) + Q_PRIVATE_SLOT(d, void themeUpdated()) }; } #endif