39
39
#include "clientignorelistmanager.h"
41
41
ChatMonitorView::ChatMonitorView(ChatMonitorFilter *filter, QWidget *parent)
42
: ChatView(filter, parent),
42
: ChatView(filter, parent),
45
scene()->setSenderCutoffMode(ChatScene::CutoffLeft);
46
connect(Client::instance(), SIGNAL(coreConnectionStateChanged(bool)), this, SLOT(coreConnectionStateChanged(bool)));
49
void ChatMonitorView::addActionsToMenu(QMenu *menu, const QPointF &pos) {
50
ChatView::addActionsToMenu(menu, pos);
52
QAction *showOwnNicksAction = menu->addAction(tr("Show Own Messages"), _filter, SLOT(setShowOwnMessages(bool)));
53
showOwnNicksAction->setCheckable(true);
54
showOwnNicksAction->setChecked(_filter->showOwnMessages());
56
if(scene()->columnByScenePos(pos) == ChatLineModel::SenderColumn) {
59
QAction *showNetworkAction = menu->addAction(tr("Show Network Name"), this, SLOT(showFieldsChanged(bool)));
60
showNetworkAction->setCheckable(true);
61
showNetworkAction->setChecked(_filter->showFields() & ChatMonitorFilter::NetworkField);
62
showNetworkAction->setData(ChatMonitorFilter::NetworkField);
64
QAction *showBufferAction = menu->addAction(tr("Show Buffer Name"), this, SLOT(showFieldsChanged(bool)));
65
showBufferAction->setCheckable(true);
66
showBufferAction->setChecked(_filter->showFields() & ChatMonitorFilter::BufferField);
67
showBufferAction->setData(ChatMonitorFilter::BufferField);
71
menu->addAction(SmallIcon("configure"), tr("Configure..."), this, SLOT(showSettingsPage()));
74
void ChatMonitorView::mouseDoubleClickEvent(QMouseEvent *event) {
75
if(scene()->columnByScenePos(event->pos()) != ChatLineModel::SenderColumn) {
76
ChatView::mouseDoubleClickEvent(event);
80
ChatItem *chatItem = scene()->chatItemAt(mapToScene(event->pos()));
87
BufferId bufferId = chatItem->data(MessageModel::BufferIdRole).value<BufferId>();
88
if(!bufferId.isValid())
91
Client::bufferModel()->switchToBuffer(bufferId);
94
void ChatMonitorView::showFieldsChanged(bool checked) {
95
QAction *showAction = qobject_cast<QAction *>(sender());
100
_filter->addShowField(showAction->data().toInt());
102
_filter->removeShowField(showAction->data().toInt());
105
void ChatMonitorView::showSettingsPage() {
106
SettingsPageDlg dlg(new ChatMonitorSettingsPage(), this);
45
scene()->setSenderCutoffMode(ChatScene::CutoffLeft);
46
connect(Client::instance(), SIGNAL(coreConnectionStateChanged(bool)), this, SLOT(coreConnectionStateChanged(bool)));
50
void ChatMonitorView::addActionsToMenu(QMenu *menu, const QPointF &pos)
52
ChatView::addActionsToMenu(menu, pos);
54
QAction *showOwnNicksAction = menu->addAction(tr("Show Own Messages"), _filter, SLOT(setShowOwnMessages(bool)));
55
showOwnNicksAction->setCheckable(true);
56
showOwnNicksAction->setChecked(_filter->showOwnMessages());
58
if (scene()->columnByScenePos(pos) == ChatLineModel::SenderColumn) {
61
QAction *showNetworkAction = menu->addAction(tr("Show Network Name"), this, SLOT(showFieldsChanged(bool)));
62
showNetworkAction->setCheckable(true);
63
showNetworkAction->setChecked(_filter->showFields() & ChatMonitorFilter::NetworkField);
64
showNetworkAction->setData(ChatMonitorFilter::NetworkField);
66
QAction *showBufferAction = menu->addAction(tr("Show Buffer Name"), this, SLOT(showFieldsChanged(bool)));
67
showBufferAction->setCheckable(true);
68
showBufferAction->setChecked(_filter->showFields() & ChatMonitorFilter::BufferField);
69
showBufferAction->setData(ChatMonitorFilter::BufferField);
73
menu->addAction(SmallIcon("configure"), tr("Configure..."), this, SLOT(showSettingsPage()));
77
void ChatMonitorView::mouseDoubleClickEvent(QMouseEvent *event)
79
if (scene()->columnByScenePos(event->pos()) != ChatLineModel::SenderColumn) {
80
ChatView::mouseDoubleClickEvent(event);
84
ChatItem *chatItem = scene()->chatItemAt(mapToScene(event->pos()));
91
BufferId bufferId = chatItem->data(MessageModel::BufferIdRole).value<BufferId>();
92
if (!bufferId.isValid())
95
Client::bufferModel()->switchToBuffer(bufferId);
99
void ChatMonitorView::showFieldsChanged(bool checked)
101
QAction *showAction = qobject_cast<QAction *>(sender());
106
_filter->addShowField(showAction->data().toInt());
108
_filter->removeShowField(showAction->data().toInt());
112
void ChatMonitorView::showSettingsPage()
114
SettingsPageDlg dlg(new ChatMonitorSettingsPage(), this);
110
119
// connect only after client is synced to core since ChatMonitorView is created before
111
120
// the ignoreListManager
112
void ChatMonitorView::coreConnectionStateChanged(bool connected) {
114
connect(Client::ignoreListManager(), SIGNAL(ignoreListChanged()), _filter, SLOT(invalidateFilter()));
121
void ChatMonitorView::coreConnectionStateChanged(bool connected)
124
connect(Client::ignoreListManager(), SIGNAL(ignoreListChanged()), _filter, SLOT(invalidateFilter()));