X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fchatitem.cpp;h=8063a972365ace53da297ad7a1bdaa431373fb02;hp=1fc8f60c7a4dcec9a37bb69f623776c337003abb;hb=f9efdde7f3a6004af8f834c409cfa6ae1d877692;hpb=68878dc8366f2f4a0afe132847aad9a51a80cdbf diff --git a/src/qtui/chatitem.cpp b/src/qtui/chatitem.cpp index 1fc8f60c..8063a972 100644 --- a/src/qtui/chatitem.cpp +++ b/src/qtui/chatitem.cpp @@ -18,24 +18,29 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ +#include "chatitem.h" + +#include +#include + #include #include #include #include #include -#include #include #include #include #include +#include "action.h" #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 +50,7 @@ ChatItem::ChatItem(const QRectF &boundingRect, ChatLine *parent) _boundingRect(boundingRect), _selectionMode(NoSelection), _selectionStart(-1), - _cachedLayout(0) + _cachedLayout(nullptr) { } @@ -137,7 +142,7 @@ QTextLayout *ChatItem::layout() const void ChatItem::clearCache() { delete _cachedLayout; - _cachedLayout = 0; + _cachedLayout = nullptr; } @@ -245,7 +250,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 +290,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(); + auto itemLabel = data(ChatLineModel::MsgLabelRole).value