From: Manuel Nickschas Date: Wed, 24 Feb 2010 17:58:54 +0000 (+0100) Subject: Properly handle hover events in ChatView X-Git-Tag: 0.6-rc1~36 X-Git-Url: https://git.quassel-irc.org/?a=commitdiff_plain;h=826a68dd9b56492b00a4b64bc959acc3f8891ad0;p=quassel.git Properly handle hover events in ChatView Fixes link underlines and hover previews sticking around sometimes. --- diff --git a/src/qtui/chatline.cpp b/src/qtui/chatline.cpp index 6032cbef..2af3269a 100644 --- a/src/qtui/chatline.cpp +++ b/src/qtui/chatline.cpp @@ -49,7 +49,8 @@ ChatLine::ChatLine(int row, QAbstractItemModel *model, _width(width), _height(_contentsItem.height()), _selection(0), - _mouseGrabberItem(0) + _mouseGrabberItem(0), + _hoverItem(0) { Q_ASSERT(model); QModelIndex index = model->index(row, ChatLineModel::ContentsColumn); @@ -247,14 +248,17 @@ void ChatLine::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { void ChatLine::hoverEnterEvent(QGraphicsSceneHoverEvent *event) { ChatItem *item = mouseEventTargetItem(event->pos()); - if(item) + if(item) { + Q_ASSERT(!_hoverItem); + _hoverItem = item; item->hoverEnterEvent(event); + } } void ChatLine::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) { - ChatItem *item = mouseEventTargetItem(event->pos()); - if(item) - item->hoverLeaveEvent(event); + Q_ASSERT(_hoverItem); + _hoverItem->hoverLeaveEvent(event); + _hoverItem = 0; } void ChatLine::hoverMoveEvent(QGraphicsSceneHoverEvent *event) { diff --git a/src/qtui/chatline.h b/src/qtui/chatline.h index 24947d0a..824d50e9 100644 --- a/src/qtui/chatline.h +++ b/src/qtui/chatline.h @@ -101,6 +101,7 @@ private: quint8 _selection; // save space, so we put both the col and the flags into one byte ChatItem *_mouseGrabberItem; + ChatItem *_hoverItem; }; #endif