From 7858f42f5c3028392feeb58398e3d15eab6c00ec Mon Sep 17 00:00:00 2001 From: Manuel Nickschas Date: Sun, 14 Dec 2008 01:24:56 +0100 Subject: [PATCH] Make channel names in ChatView left-clickable as well --- src/qtui/chatitem.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/qtui/chatitem.cpp b/src/qtui/chatitem.cpp index be792c97..7e6d0e18 100644 --- a/src/qtui/chatitem.cpp +++ b/src/qtui/chatitem.cpp @@ -28,6 +28,7 @@ #include #include +#include "buffermodel.h" #include "bufferview.h" #include "chatitem.h" #include "chatlinemodel.h" @@ -511,9 +512,18 @@ void ContentsChatItem::handleClick(const QPointF &pos, ChatScene::ClickMode clic str = "http://" + str; QDesktopServices::openUrl(QUrl::fromEncoded(str.toUtf8(), QUrl::TolerantMode)); break; - case Clickable::Channel: - // TODO join or whatever... + case Clickable::Channel: { + NetworkId networkId = Client::networkModel()->networkId(data(MessageModel::BufferIdRole).value()); + BufferId bufId = Client::networkModel()->bufferId(networkId, str); + if(bufId.isValid()) { + QModelIndex targetIdx = Client::networkModel()->bufferIndex(bufId); + Client::bufferModel()->switchToBuffer(bufId); + if(!targetIdx.data(NetworkModel::ItemActiveRole).toBool()) + Client::userInput(BufferInfo::fakeStatusBuffer(networkId), QString("/JOIN %1").arg(str)); + } else + Client::userInput(BufferInfo::fakeStatusBuffer(networkId), QString("/JOIN %1").arg(str)); break; + } default: break; } -- 2.20.1