X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fchatmonitorview.cpp;h=6e0077820d739966cb109af60f8191726e753d1e;hp=6b9fe601382744a373d4f92330ff01349b16f88e;hb=731ec69d4608ba95e3ae4f154b8ca1852e1db2e5;hpb=9d52e49424afb60c2f28073051c1dbf25f47adec diff --git a/src/qtui/chatmonitorview.cpp b/src/qtui/chatmonitorview.cpp index 6b9fe601..6e007782 100644 --- a/src/qtui/chatmonitorview.cpp +++ b/src/qtui/chatmonitorview.cpp @@ -26,33 +26,61 @@ #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) : ChatView(filter, parent), _filter(filter) { + scene()->setSenderCutoffMode(ChatScene::CutoffLeft); } -void ChatMonitorView::contextMenuEvent(QContextMenuEvent *event) { - if(scene()->sectionByScenePos(event->pos()) != ChatLineModel::SenderColumn) +void ChatMonitorView::addActionsToMenu(QMenu *menu, const QPointF &pos) { + ChatView::addActionsToMenu(menu, pos); + menu->addSeparator(); + QAction *showOwnNicksAction = menu->addAction(tr("Show Own Messages"), _filter, SLOT(setShowOwnMessages(bool))); + showOwnNicksAction->setCheckable(true); + showOwnNicksAction->setChecked(_filter->showOwnMessages()); + + if(scene()->columnByScenePos(pos) == ChatLineModel::SenderColumn) { + menu->addSeparator(); + + QAction *showNetworkAction = menu->addAction(tr("Show Network Name"), this, SLOT(showFieldsChanged(bool))); + showNetworkAction->setCheckable(true); + showNetworkAction->setChecked(_filter->showFields() & ChatMonitorFilter::NetworkField); + showNetworkAction->setData(ChatMonitorFilter::NetworkField); + + QAction *showBufferAction = menu->addAction(tr("Show Buffer Name"), this, SLOT(showFieldsChanged(bool))); + showBufferAction->setCheckable(true); + showBufferAction->setChecked(_filter->showFields() & ChatMonitorFilter::BufferField); + showBufferAction->setData(ChatMonitorFilter::BufferField); + } +} + +void ChatMonitorView::mouseDoubleClickEvent(QMouseEvent *event) { + if(scene()->columnByScenePos(event->pos()) != ChatLineModel::SenderColumn) { + ChatView::mouseDoubleClickEvent(event); + return; + } + + ChatItem *chatItem = dynamic_cast(itemAt(event->pos())); + if(!chatItem) { + event->ignore(); 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); + event->accept(); + BufferId bufferId = chatItem->data(MessageModel::BufferIdRole).value(); + if(!bufferId.isValid()) + return; - contextMenu.exec(QCursor::pos()); + Client::bufferModel()->switchToBuffer(bufferId); } void ChatMonitorView::showFieldsChanged(bool checked) { @@ -63,5 +91,5 @@ void ChatMonitorView::showFieldsChanged(bool checked) { if(checked) _filter->addShowField(showAction->data().toInt()); else - _filter->removeShowField(showAction->data().toInt()); + _filter->removeShowField(showAction->data().toInt()); }