X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fchatitem.cpp;h=9c84249ce594d3597c0838aaf4dcced4e80e6efc;hp=9b7c220343905b31f3e1d45726a875cc45155416;hb=b0238fe2f113dd23df01eeb0491f0afe39847994;hpb=e8e50ceb0f0df46a6f281f6d4fd587f00fe532d3 diff --git a/src/qtui/chatitem.cpp b/src/qtui/chatitem.cpp index 9b7c2203..9c84249c 100644 --- a/src/qtui/chatitem.cpp +++ b/src/qtui/chatitem.cpp @@ -32,6 +32,7 @@ #include "bufferview.h" #include "chatitem.h" #include "chatlinemodel.h" +#include "contextmenuactionprovider.h" #include "iconloader.h" #include "mainwin.h" #include "qtui.h" @@ -286,9 +287,9 @@ void ChatItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { } void ChatItem::addActionsToMenu(QMenu *menu, const QPointF &pos) { - Q_UNUSED(menu); Q_UNUSED(pos); + GraphicalUi::contextMenuActionProvider()->addActions(menu, chatScene()->filter(), data(MessageModel::BufferIdRole).value()); } // ************************************************************ @@ -412,12 +413,12 @@ void ContentsChatItem::doLayout(QTextLayout *layout) const { QList ContentsChatItem::findClickables() const { // For matching URLs static QString urlEnd("(?:>|[,.;:\"]*\\s|\\b|$)"); - static QString urlChars("(?:[,.;:]*[\\w\\-~@/?&=+$()!%#*|{}\\[\\]])"); + static QString urlChars("(?:[,.;:]*[\\w\\-~@/?&=+$()!%#*|{}\\[\\]'])"); static QRegExp regExp[] = { // URL // QRegExp(QString("((?:https?://|s?ftp://|irc://|mailto:|www\\.)%1+|%1+\\.[a-z]{2,4}(?:?=/%1+|\\b))%2").arg(urlChars, urlEnd)), - QRegExp(QString("((?:(?:https?://|s?ftp://|irc://|gopher://|mailto:)|www)%1+)%2").arg(urlChars, urlEnd), Qt::CaseInsensitive), + QRegExp(QString("((?:(?:mailto:|\\w+://)|www)%1+)%2").arg(urlChars, urlEnd), Qt::CaseInsensitive), // Channel name // We don't match for channel names starting with + or &, because that gives us a lot of false positives. @@ -444,7 +445,7 @@ QList ContentsChatItem::findClickables() const { for(int i = 0; i < regExpCount; i++) { if(matches[i] < 0 || matchEnd[i] > str.length()) continue; if(idx >= matchEnd[i]) { - matches[i] = str.indexOf(regExp[i], qMax(matchEnd[i], idx)); + matches[i] = regExp[i].indexIn(str, qMax(matchEnd[i], idx)); if(matches[i] >= 0) matchEnd[i] = matches[i] + regExp[i].cap(1).length(); } if(matches[i] >= 0 && matches[i] < minidx) { @@ -602,8 +603,6 @@ void ContentsChatItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event) { } void ContentsChatItem::addActionsToMenu(QMenu *menu, const QPointF &pos) { - Q_UNUSED(pos); // we assume that the current mouse cursor pos is the point of invocation - if(privateData()->currentClickable.isValid()) { Clickable click = privateData()->currentClickable; switch(click.type) { @@ -617,16 +616,15 @@ void ContentsChatItem::addActionsToMenu(QMenu *menu, const QPointF &pos) { foreach(QAction *action, menu->actions()) action->setVisible(false); QString name = data(ChatLineModel::DisplayRole).toString().mid(click.start, click.length); - Client::mainUi()->actionProvider()->addActions(menu, chatScene()->filter(), data(MessageModel::BufferIdRole).value(), name); + GraphicalUi::contextMenuActionProvider()->addActions(menu, chatScene()->filter(), data(MessageModel::BufferIdRole).value(), name); break; } default: break; } } else { - // Buffer-specific actions - Client::mainUi()->actionProvider()->addActions(menu, chatScene()->filter(), data(MessageModel::BufferIdRole).value()); + ChatItem::addActionsToMenu(menu, pos); } }