X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fchatitem.cpp;h=4da2bb47075b5ab0c9cde1490c51f5777e3b6f05;hp=45abc82bd0363ef86ba21783a2cff6ebabc0d7e1;hb=b7447afe8e836376776dac26704e227a678d2913;hpb=0a43227b8cd44625f4881cc1545d42c8c8a4876c diff --git a/src/qtui/chatitem.cpp b/src/qtui/chatitem.cpp index 45abc82b..4da2bb47 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,13 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ +#include "chatitem.h" + #include #include #include #include #include -#include #include #include #include @@ -31,11 +32,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" @@ -153,7 +154,7 @@ void ChatItem::initLayoutHelper(QTextLayout *layout, QTextOption::WrapMode wrapM layout->setTextOption(option); QList formatRanges - = QtUi::style()->toTextLayoutList(formatList(), layout->text().length(), data(ChatLineModel::MsgLabelRole).toUInt()); + = QtUi::style()->toTextLayoutList(formatList(), layout->text().length(), data(ChatLineModel::MsgLabelRole).value()); layout->setAdditionalFormats(formatRanges); } @@ -245,7 +246,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); @@ -257,11 +258,11 @@ void ChatItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, } -void ChatItem::overlayFormat(UiStyle::FormatList &fmtList, int start, int end, quint32 overlayFmt) const +void ChatItem::overlayFormat(UiStyle::FormatList &fmtList, quint16 start, quint16 end, UiStyle::FormatType overlayFmt) const { - for (int i = 0; i < fmtList.count(); i++) { + for (size_t i = 0; i < fmtList.size(); i++) { int fmtStart = fmtList.at(i).first; - int fmtEnd = (i < fmtList.count()-1 ? fmtList.at(i+1).first : data(MessageModel::DisplayRole).toString().length()); + int fmtEnd = (i < fmtList.size()-1 ? fmtList.at(i+1).first : data(MessageModel::DisplayRole).toString().length()); if (fmtEnd <= start) continue; @@ -270,15 +271,15 @@ void ChatItem::overlayFormat(UiStyle::FormatList &fmtList, int start, int end, q // split the format if necessary if (fmtStart < start) { - fmtList.insert(i, fmtList.at(i)); + fmtList.insert(fmtList.begin() + i, fmtList.at(i)); fmtList[++i].first = start; } if (end < fmtEnd) { - fmtList.insert(i, fmtList.at(i)); + fmtList.insert(fmtList.begin() + i, fmtList.at(i)); fmtList[i+1].first = end; } - fmtList[i].second |= overlayFmt; + fmtList[i].second.type |= overlayFmt; } } @@ -294,7 +295,7 @@ QVector ChatItem::selectionFormats() const if (!hasSelection()) return QVector(); - int start, end; + quint16 start, end; if (_selectionMode == FullSelection) { start = 0; end = data(MessageModel::DisplayRole).toString().length(); @@ -306,15 +307,15 @@ QVector ChatItem::selectionFormats() const UiStyle::FormatList fmtList = formatList(); - while (fmtList.count() > 1 && fmtList.at(1).first <= start) - fmtList.removeFirst(); + while (fmtList.size() > 1 && fmtList.at(1).first <= start) + fmtList.erase(fmtList.begin()); - fmtList.first().first = start; + fmtList.front().first = start; - while (fmtList.count() > 1 && fmtList.last().first >= end) - fmtList.removeLast(); + while (fmtList.size() > 1 && fmtList.back().first >= end) + fmtList.pop_back(); - return QtUi::style()->toTextLayoutList(fmtList, end, UiStyle::Selected|data(ChatLineModel::MsgLabelRole).toUInt()).toVector(); + return QtUi::style()->toTextLayoutList(fmtList, end, data(ChatLineModel::MsgLabelRole).value()|UiStyle::MessageLabel::Selected).toVector(); } @@ -567,7 +568,7 @@ ContentsChatItem::ContentsChatItem(const QPointF &pos, const qreal &width, ChatL QFontMetricsF *ContentsChatItem::fontMetrics() const { - return QtUi::style()->fontMetrics(data(ChatLineModel::FormatRole).value().at(0).second, 0); + return QtUi::style()->fontMetrics(data(ChatLineModel::FormatRole).value().at(0).second.type, UiStyle::MessageLabel::None); } @@ -674,7 +675,7 @@ UiStyle::FormatList ContentsChatItem::formatList() const for (int i = 0; i < privateData()->clickables.count(); i++) { Clickable click = privateData()->clickables.at(i); if (click.type() == Clickable::Url) { - overlayFormat(fmtList, click.start(), click.start() + click.length(), UiStyle::Url); + overlayFormat(fmtList, click.start(), click.start() + click.length(), UiStyle::FormatType::Url); } } return fmtList; @@ -798,7 +799,7 @@ void ContentsChatItem::addActionsToMenu(QMenu *menu, const QPointF &pos) switch (click.type()) { case Clickable::Url: privateData()->activeClickable = click; - menu->addAction(QIcon::fromTheme("edit-copy"), tr("Copy Link Address"), + menu->addAction(icon::get("edit-copy"), tr("Copy Link Address"), &_actionProxy, SLOT(copyLinkToClipboard()))->setData(QVariant::fromValue(this)); break; case Clickable::Channel: @@ -836,7 +837,7 @@ void ContentsChatItem::copyLinkToClipboard() void ContentsChatItem::showWebPreview(const Clickable &click) { -#ifndef HAVE_WEBKIT +#if !defined HAVE_WEBKIT && !defined HAVE_WEBENGINE Q_UNUSED(click); #else QTextLine line = layout()->lineForTextPosition(click.start()); @@ -859,7 +860,7 @@ void ContentsChatItem::showWebPreview(const Clickable &click) void ContentsChatItem::clearWebPreview() { -#ifdef HAVE_WEBKIT +#if defined HAVE_WEBKIT || defined HAVE_WEBENGINE chatScene()->clearWebPreview(this); #endif }