Fixing BR # 204 - double click on the sender column in the chatmonitor to switch...
[quassel.git] / src / qtui / chatmonitorview.cpp
index 6b9fe60..6d5d667 100644 (file)
 
 #include "chatmonitorfilter.h"
 #include "chatlinemodel.h"
 
 #include "chatmonitorfilter.h"
 #include "chatlinemodel.h"
+#include "chatitem.h"
 #include "chatscene.h"
 #include "chatscene.h"
+#include "client.h"
+#include "networkmodel.h"
+#include "buffermodel.h"
+#include "messagemodel.h"
 #include "qtuisettings.h"
 
 ChatMonitorView::ChatMonitorView(ChatMonitorFilter *filter, QWidget *parent)
 #include "qtuisettings.h"
 
 ChatMonitorView::ChatMonitorView(ChatMonitorFilter *filter, QWidget *parent)
@@ -55,6 +60,23 @@ void ChatMonitorView::contextMenuEvent(QContextMenuEvent *event) {
   contextMenu.exec(QCursor::pos());
 }
 
   contextMenu.exec(QCursor::pos());
 }
 
+void ChatMonitorView::mouseDoubleClickEvent(QMouseEvent *event) {
+  if(scene()->sectionByScenePos(event->pos()) != ChatLineModel::SenderColumn)
+    return;
+
+  //ChatItem *chatItem = static_cast<ChatItem *>(itemAt(event->pos()));
+  ChatItem *chatItem = dynamic_cast<ChatItem *>(itemAt(event->pos()));
+  BufferId bufferId = chatItem->data(MessageModel::BufferIdRole).value<BufferId>();
+  if(!bufferId.isValid())
+    return;
+  
+  QModelIndex bufferIdx = Client::networkModel()->bufferIndex(bufferId);
+  if(!bufferIdx.isValid())
+    return;
+
+  Client::bufferModel()->setCurrentIndex(Client::bufferModel()->mapFromSource(bufferIdx));
+}
+
 void ChatMonitorView::showFieldsChanged(bool checked) {
   QAction *showAction = qobject_cast<QAction *>(sender());
   if(!showAction)
 void ChatMonitorView::showFieldsChanged(bool checked) {
   QAction *showAction = qobject_cast<QAction *>(sender());
   if(!showAction)