X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fchatitem.cpp;h=79ee339b9da85a4b3f730b05f607209861d7bee1;hp=3dd3b2a7f18eba7173b048a527dcc3f7cad28e45;hb=39328183a6a87c6eb10a9dbbffcd5d65bf154a1f;hpb=e6f810169117c836c22ae1146e469e61dec95f6f diff --git a/src/qtui/chatitem.cpp b/src/qtui/chatitem.cpp index 3dd3b2a7..79ee339b 100644 --- a/src/qtui/chatitem.cpp +++ b/src/qtui/chatitem.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2016 by the Quassel Project * + * Copyright (C) 2005-2018 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -18,12 +18,16 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ +#include "chatitem.h" + +#include +#include + #include #include #include #include #include -#include #include #include #include @@ -31,11 +35,11 @@ #include "buffermodel.h" #include "bufferview.h" -#include "chatitem.h" #include "chatline.h" #include "chatlinemodel.h" #include "chatview.h" #include "contextmenuactionprovider.h" +#include "icon.h" #include "mainwin.h" #include "qtui.h" #include "qtuistyle.h" @@ -45,7 +49,7 @@ ChatItem::ChatItem(const QRectF &boundingRect, ChatLine *parent) _boundingRect(boundingRect), _selectionMode(NoSelection), _selectionStart(-1), - _cachedLayout(0) + _cachedLayout(nullptr) { } @@ -137,7 +141,7 @@ QTextLayout *ChatItem::layout() const void ChatItem::clearCache() { delete _cachedLayout; - _cachedLayout = 0; + _cachedLayout = nullptr; } @@ -245,7 +249,7 @@ void ChatItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, // } // 2) draw MsgId over the time column // if(column() == 0) { -// QString msgIdString = QString::number(data(MessageModel::MsgIdRole).value().toInt()); +// QString msgIdString = QString::number(data(MessageModel::MsgIdRole).value().toLongLong()); // QPointF bottomPoint = boundingRect().bottomLeft(); // bottomPoint.ry() -= 2; // painter->drawText(bottomPoint, msgIdString); @@ -285,36 +289,92 @@ void ChatItem::overlayFormat(UiStyle::FormatList &fmtList, quint16 start, quint1 QVector ChatItem::additionalFormats() const { - return selectionFormats(); -} + // Calculate formats to overlay (only) if there's a selection, and/or a hovered clickable + if (!hasSelection() && !hasActiveClickable()) { + return {}; + } + using Label = UiStyle::MessageLabel; + using Format = UiStyle::Format; -QVector ChatItem::selectionFormats() const -{ - if (!hasSelection()) - return QVector(); + Label itemLabel = data(ChatLineModel::MsgLabelRole).value