X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fchatline.cpp;h=4f03794e6f89ebc9c18929f212141ecd9e1588de;hp=6032cbef5969814bdd94badb395ccb621885c546;hb=c80e9d81bfecf4126ed5a0a8b34802aa320ade0c;hpb=6330f7fe3d19113cbf29944a9b6e8b503893d4a9 diff --git a/src/qtui/chatline.cpp b/src/qtui/chatline.cpp index 6032cbef..4f03794e 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); @@ -58,6 +59,11 @@ ChatLine::ChatLine(int row, QAbstractItemModel *model, setHighlighted(index.data(MessageModel::FlagsRole).toInt() & Message::Highlight); } +ChatLine::~ChatLine() { + if(chatView()) + chatView()->setHasCache(this, false); +} + ChatItem *ChatLine::item(ChatLineModel::ColumnType column) { switch(column) { case ChatLineModel::TimestampColumn: @@ -81,6 +87,12 @@ ChatItem *ChatLine::itemAt(const QPointF &pos) { return 0; } +void ChatLine::clearCache() { + _timestampItem.clearCache(); + _senderItem.clearCache(); + _contentsItem.clearCache(); +} + void ChatLine::setMouseGrabberItem(ChatItem *item) { _mouseGrabberItem = item; } @@ -197,26 +209,6 @@ void ChatLine::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, timestampItem()->paint(painter, option, widget); senderItem()->paint(painter, option, widget); contentsItem()->paint(painter, option, widget); - - // new line marker - if(model_ && row() > 0 && chatScene()->isSingleBufferScene()) { - QModelIndex prevRowIdx = model_->index(row() - 1, 0); - MsgId prevMsgId = prevRowIdx.data(MessageModel::MsgIdRole).value(); - MsgId myMsgId = myIdx.data(MessageModel::MsgIdRole).value(); - Message::Flags flags = (Message::Flags)myIdx.data(MessageModel::FlagsRole).toInt(); - - // don't show the marker if we wrote that new line - if(!(flags & Message::Self)) { - BufferId bufferId = BufferId(chatScene()->idString().toInt()); - MsgId lastSeenMsgId = Client::networkModel()->markerLineMsgId(bufferId); - if(lastSeenMsgId < myMsgId && lastSeenMsgId >= prevMsgId) { - QLinearGradient gradient(0, 0, 0, contentsItem()->fontMetrics()->lineSpacing()); - gradient.setColorAt(0, QtUi::style()->brush(UiStyle::MarkerLine).color()); // FIXME: Use full (gradient?) brush instead of just the color - gradient.setColorAt(0.1, Qt::transparent); - painter->fillRect(boundingRect(), gradient); - } - } - } } // We need to dispatch all mouse-related events to the appropriate (mouse grabbing) ChatItem @@ -247,14 +239,17 @@ void ChatLine::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { void ChatLine::hoverEnterEvent(QGraphicsSceneHoverEvent *event) { ChatItem *item = mouseEventTargetItem(event->pos()); - if(item) + if(item && !_hoverItem) { + _hoverItem = item; item->hoverEnterEvent(event); + } } void ChatLine::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) { - ChatItem *item = mouseEventTargetItem(event->pos()); - if(item) - item->hoverLeaveEvent(event); + if(_hoverItem) { + _hoverItem->hoverLeaveEvent(event); + _hoverItem = 0; + } } void ChatLine::hoverMoveEvent(QGraphicsSceneHoverEvent *event) {