X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fchatitem.cpp;h=86fb133205e42a230c0d0466b6cff072f6762fa5;hp=fc45b77c0e6eafad02955fb05722555ba789acad;hb=755ae9469c82d0e3557a4fe2e05461ca0c270bb2;hpb=86d792a90e2868635170a1092ac7a9278a84ef71 diff --git a/src/qtui/chatitem.cpp b/src/qtui/chatitem.cpp index fc45b77c..86fb1332 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" @@ -278,7 +279,7 @@ void ChatItem::mousePressEvent(QGraphicsSceneMouseEvent *event) { } void ChatItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { - if(_selectionMode != NoSelection && !event->buttons() & Qt::LeftButton) { + if(_selectionMode != NoSelection && event->button() == Qt::LeftButton) { chatScene()->selectionToClipboard(QClipboard::Selection); event->accept(); } else @@ -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); } }