From f46a6a269ce445d60362cf8fdee3d325744301ba Mon Sep 17 00:00:00 2001 From: Christopher Blauvelt Date: Thu, 10 Jan 2008 23:29:05 +0000 Subject: [PATCH] Use mouseDoubleClickEvent instead of a custom implementation. svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=759629 --- widgets/icon.cpp | 12 +++++------- widgets/icon.h | 13 +++++++------ widgets/icon_p.h | 2 -- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/widgets/icon.cpp b/widgets/icon.cpp index 7a4edd3d3..b96b58b55 100644 --- a/widgets/icon.cpp +++ b/widgets/icon.cpp @@ -1016,13 +1016,6 @@ void Icon::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) if (!handled) { if (boundingRect().contains(event->pos())) { emit clicked(); - - if (qApp && d->lastClicked.isValid() && d->lastClicked.elapsed() < qApp->doubleClickInterval()) { - emit doubleClicked(); - d->lastClicked = QTime(); - } else { - d->lastClicked.restart(); - } } emit pressed(false); } @@ -1030,6 +1023,11 @@ void Icon::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) update(); } +void Icon::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) +{ + emit doubleClicked(); +} + void Icon::hoverEnterEvent(QGraphicsSceneHoverEvent *event) { foreach (IconAction *action, d->cornerActions) { diff --git a/widgets/icon.h b/widgets/icon.h index 397f755f4..ad21f649a 100644 --- a/widgets/icon.h +++ b/widgets/icon.h @@ -209,18 +209,18 @@ protected: Q_SIGNALS: /** - * Indicates when the icon has been pressed. - */ + * Indicates when the icon has been pressed. + */ void pressed(bool down); /** - * Indicates when the icon has been clicked. - */ + * Indicates when the icon has been clicked. + */ void clicked(); /** - * Indicates when the icon has been double clicked. - */ + * Indicates when the icon has been double-clicked + */ void doubleClicked(); protected: @@ -228,6 +228,7 @@ protected: void mousePressEvent(QGraphicsSceneMouseEvent *event); void mouseMoveEvent(QGraphicsSceneMouseEvent *event); void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); + void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event); void hoverEnterEvent(QGraphicsSceneHoverEvent *event); void hoverLeaveEvent(QGraphicsSceneHoverEvent *event); diff --git a/widgets/icon_p.h b/widgets/icon_p.h index e3d733698..0eb984b27 100644 --- a/widgets/icon_p.h +++ b/widgets/icon_p.h @@ -23,7 +23,6 @@ #define ICON_P_H #include -#include #include #include #include @@ -170,7 +169,6 @@ public: QColor shadowColor; QSizeF iconSize; QIcon icon; - QTime lastClicked; IconStates states; Qt::Orientation orientation; int numDisplayLines;