X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fqtui%2Fchatmonitorview.cpp;h=45dbb41a5ae633c850ea19961c01de5cb9243073;hb=2ab3040da0e42f4afdd282e34f0d8b089020a73d;hp=6b9fe601382744a373d4f92330ff01349b16f88e;hpb=9d52e49424afb60c2f28073051c1dbf25f47adec;p=quassel.git diff --git a/src/qtui/chatmonitorview.cpp b/src/qtui/chatmonitorview.cpp index 6b9fe601..45dbb41a 100644 --- a/src/qtui/chatmonitorview.cpp +++ b/src/qtui/chatmonitorview.cpp @@ -26,7 +26,12 @@ #include "chatmonitorfilter.h" #include "chatlinemodel.h" +#include "chatitem.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) @@ -36,25 +41,49 @@ ChatMonitorView::ChatMonitorView(ChatMonitorFilter *filter, QWidget *parent) } void ChatMonitorView::contextMenuEvent(QContextMenuEvent *event) { - if(scene()->sectionByScenePos(event->pos()) != ChatLineModel::SenderColumn) - return; - - int showFields = _filter->showFields(); - QMenu contextMenu(this); - QAction *showNetworkAction = contextMenu.addAction(tr("Show network name"), this, SLOT(showFieldsChanged(bool))); - showNetworkAction->setCheckable(true); - showNetworkAction->setChecked(showFields & ChatMonitorFilter::NetworkField); - showNetworkAction->setData(ChatMonitorFilter::NetworkField); - - QAction *showBufferAction = contextMenu.addAction(tr("Show buffer name"), this, SLOT(showFieldsChanged(bool))); - showBufferAction->setCheckable(true); - showBufferAction->setChecked(showFields & ChatMonitorFilter::BufferField); - showBufferAction->setData(ChatMonitorFilter::BufferField); + + QAction *showOwnNicksAction = contextMenu.addAction(tr("Show own messages"), _filter, SLOT(setShowOwnMessages(bool))); + showOwnNicksAction->setCheckable(true); + showOwnNicksAction->setChecked(_filter->showOwnMessages()); + + if(scene()->sectionByScenePos(event->pos()) == ChatLineModel::SenderColumn) { + contextMenu.addSeparator(); + + QAction *showNetworkAction = contextMenu.addAction(tr("Show network name"), this, SLOT(showFieldsChanged(bool))); + showNetworkAction->setCheckable(true); + showNetworkAction->setChecked(_filter->showFields() & ChatMonitorFilter::NetworkField); + showNetworkAction->setData(ChatMonitorFilter::NetworkField); + + QAction *showBufferAction = contextMenu.addAction(tr("Show buffer name"), this, SLOT(showFieldsChanged(bool))); + showBufferAction->setCheckable(true); + showBufferAction->setChecked(_filter->showFields() & ChatMonitorFilter::BufferField); + showBufferAction->setData(ChatMonitorFilter::BufferField); + } contextMenu.exec(QCursor::pos()); } +void ChatMonitorView::mouseDoubleClickEvent(QMouseEvent *event) { + if(scene()->sectionByScenePos(event->pos()) != ChatLineModel::SenderColumn) { + ChatView::mouseDoubleClickEvent(event); + return; + } + + ChatItem *chatItem = dynamic_cast(itemAt(event->pos())); + if(!chatItem) { + event->ignore(); + return; + } + + event->accept(); + BufferId bufferId = chatItem->data(MessageModel::BufferIdRole).value(); + if(!bufferId.isValid()) + return; + + Client::bufferModel()->switchToBuffer(bufferId); +} + void ChatMonitorView::showFieldsChanged(bool checked) { QAction *showAction = qobject_cast(sender()); if(!showAction) @@ -63,5 +92,5 @@ void ChatMonitorView::showFieldsChanged(bool checked) { if(checked) _filter->addShowField(showAction->data().toInt()); else - _filter->removeShowField(showAction->data().toInt()); + _filter->removeShowField(showAction->data().toInt()); }