* move the private slots to the private class

* corrections to the on-destruction handler

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=833491
This commit is contained in:
Aaron J. Seigo 2008-07-16 21:44:19 +00:00
parent 4ce38c254d
commit 84a92918a9
2 changed files with 46 additions and 36 deletions

View File

@ -52,10 +52,20 @@ public :
{ {
} }
void showToolTip(); void showToolTip();
void resetShownState(); 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; QGraphicsWidget *currentWidget;
bool isShown; bool isShown;
bool delayedHide; bool delayedHide;
@ -85,7 +95,7 @@ ToolTipManager::ToolTipManager(QObject* parent)
d(new ToolTipManagerPrivate) d(new ToolTipManagerPrivate)
{ {
connect(Plasma::Theme::defaultTheme(), SIGNAL(themeChanged()), this, SLOT(themeUpdated())); connect(Plasma::Theme::defaultTheme(), SIGNAL(themeChanged()), this, SLOT(themeUpdated()));
themeUpdated(); d->themeUpdated();
d->showTimer = new QTimer(this); d->showTimer = new QTimer(this);
d->showTimer->setSingleShot(true); d->showTimer->setSingleShot(true);
@ -188,30 +198,37 @@ bool ToolTipManager::widgetHasToolTip(QGraphicsWidget *widget)
return d->tooltips.contains(widget); return d->tooltips.contains(widget);
} }
void ToolTipManager::themeUpdated() void ToolTipManagerPrivate::themeUpdated()
{ {
QMapIterator<QGraphicsWidget*, ToolTip *> iterator(d->tooltips); QMapIterator<QGraphicsWidget*, ToolTip *> iterator(tooltips);
while (iterator.hasNext()) { while (iterator.hasNext()) {
iterator.next(); iterator.next();
iterator.value()->updateTheme(); iterator.value()->updateTheme();
} }
} }
void ToolTipManager::onWidgetDestroyed(QObject * object) void ToolTipManagerPrivate::onWidgetDestroyed(QObject *object)
{ {
if (object) { if (!object) {
QMapIterator<QGraphicsWidget*, ToolTip *> iterator(d->tooltips); return;
while (iterator.hasNext()) { }
iterator.next();
if (iterator.key() == object) { QGraphicsWidget *w = static_cast<QGraphicsWidget*>(object);
ToolTip * tooltip = iterator.value();
d->tooltips.remove(iterator.key()); if (currentWidget == w) {
d->showTimer->stop(); // stop the timer to show the tooltip currentWidget = 0;
d->delayedHide = false; showTimer->stop(); // stop the timer to show the tooltip
d->currentWidget = 0; delayedHide = false;
tooltip->hide(); }
delete tooltip;
} QMapIterator<QGraphicsWidget*, ToolTip *> 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() void ToolTipManagerPrivate::resetShownState()
{ {
if (currentWidget) { if (currentWidget) {
ToolTip * tooltip = tooltips.value(currentWidget); ToolTip * tooltip = tooltips.value(currentWidget);
if (tooltip && (!tooltip->isVisible() || delayedHide)) { if (tooltip && (!tooltip->isVisible() || delayedHide)) {
//One might have moused out and back in again //One might have moused out and back in again
delayedHide = false; delayedHide = false;
isShown = false; isShown = false;
tooltip->hide(); tooltip->hide();
currentWidget = 0; currentWidget = 0;
} }
} }
} }
@ -309,4 +326,5 @@ QPoint ToolTipManager::popupPosition(const QGraphicsItem * item, const QSize &s)
} }
#include "tooltipmanager.moc" #include "tooltipmanager.moc"

View File

@ -140,21 +140,13 @@ namespace Plasma
*/ */
static QPoint popupPosition(const QGraphicsItem * item, const QSize &s); 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: private:
friend class ToolTipManagerSingleton; friend class ToolTipManagerSingleton;
ToolTipManagerPrivate* const d; ToolTipManagerPrivate* const d;
Q_PRIVATE_SLOT(d, void showToolTip()) Q_PRIVATE_SLOT(d, void showToolTip())
Q_PRIVATE_SLOT(d, void resetShownState()) Q_PRIVATE_SLOT(d, void resetShownState())
Q_PRIVATE_SLOT(d, void onWidgetDestroyed(QObject*))
Q_PRIVATE_SLOT(d, void themeUpdated())
}; };
} }
#endif #endif