X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fchatmonitorview.cpp;h=45dbb41a5ae633c850ea19961c01de5cb9243073;hp=6d5d667935e345098bc9ea60c9af421d519d1be2;hb=0f16a547d17c536cc567bfb2746824bfca3424cd;hpb=3e85aa859e7533ec910f8b2efe4a8abd801d3a47 diff --git a/src/qtui/chatmonitorview.cpp b/src/qtui/chatmonitorview.cpp index 6d5d6679..45dbb41a 100644 --- a/src/qtui/chatmonitorview.cpp +++ b/src/qtui/chatmonitorview.cpp @@ -41,40 +41,47 @@ 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) + if(scene()->sectionByScenePos(event->pos()) != ChatLineModel::SenderColumn) { + ChatView::mouseDoubleClickEvent(event); return; + } - //ChatItem *chatItem = static_cast(itemAt(event->pos())); 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; - - QModelIndex bufferIdx = Client::networkModel()->bufferIndex(bufferId); - if(!bufferIdx.isValid()) - return; - Client::bufferModel()->setCurrentIndex(Client::bufferModel()->mapFromSource(bufferIdx)); + Client::bufferModel()->switchToBuffer(bufferId); } void ChatMonitorView::showFieldsChanged(bool checked) { @@ -85,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()); }