Make sender column clickable
authorSebastian Goth <seezer@roath.org>
Sat, 30 Jan 2010 21:46:14 +0000 (22:46 +0100)
committerManuel Nickschas <sputnick@quassel-irc.org>
Sun, 31 Jan 2010 19:26:05 +0000 (20:26 +0100)
Doubleclicking the sender switches to a querybuffer to that
user.
Still somewhat broken since not-yet-existing buffers are created
with the first doubleclick and the switch will only work with a second.
This will hopefully get fixed soon.

src/qtui/chatitem.cpp
src/qtui/chatitem.h

index 4855f0c..03a5ddc 100644 (file)
@@ -387,6 +387,25 @@ void SenderChatItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *op
   }
 }
 
   }
 }
 
+void SenderChatItem::handleClick(const QPointF &pos, ChatScene::ClickMode clickMode) {
+  if(clickMode == ChatScene::DoubleClick) {
+    BufferInfo curBufInfo = Client::networkModel()->bufferInfo(data(MessageModel::BufferIdRole).value<BufferId>());
+    QString nick = data(MessageModel::EditRole).toString();
+    // check if the nick is a valid ircUser
+    if(!nick.isEmpty() && Client::network(curBufInfo.networkId())->ircUser(nick)) {
+      BufferId targetBufId = Client::networkModel()->bufferId(curBufInfo.networkId(), nick);
+      if(targetBufId.isValid()) { // querybuffer exists
+        Client::bufferModel()->switchToBuffer(targetBufId);
+      }
+      else { // we create it
+        Client::userInput(curBufInfo, QString("/QUERY %1").arg(nick));
+      }
+    }
+  }
+  else
+    ChatItem::handleClick(pos, clickMode);
+}
+
 // ************************************************************
 // ContentsChatItem
 // ************************************************************
 // ************************************************************
 // ContentsChatItem
 // ************************************************************
index 0e6a3de..1184740 100644 (file)
@@ -156,6 +156,7 @@ class SenderChatItem : public ChatItem {
 public:
   SenderChatItem(const QRectF &boundingRect, ChatLine *parent) : ChatItem(boundingRect, parent) {}
   virtual inline ChatLineModel::ColumnType column() const { return ChatLineModel::SenderColumn; }
 public:
   SenderChatItem(const QRectF &boundingRect, ChatLine *parent) : ChatItem(boundingRect, parent) {}
   virtual inline ChatLineModel::ColumnType column() const { return ChatLineModel::SenderColumn; }
+  virtual void handleClick(const QPointF &pos, ChatScene::ClickMode clickMode);
 
 protected:
   virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
 
 protected:
   virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);