Quassel IRC  Pre-Release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
chatmonitorview.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005-2015 by the Quassel Project *
3  * devel@quassel-irc.org *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) version 3. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19  ***************************************************************************/
20 
21 #include "chatmonitorview.h"
22 
23 #include <QAction>
24 #include <QIcon>
25 #include <QMenu>
26 #include <QContextMenuEvent>
27 
28 #include "chatmonitorfilter.h"
29 #include "chatlinemodel.h"
30 #include "chatitem.h"
31 #include "chatscene.h"
32 #include "client.h"
33 #include "networkmodel.h"
34 #include "buffermodel.h"
35 #include "messagemodel.h"
36 #include "qtuisettings.h"
37 #include "settingspagedlg.h"
40 
42  : ChatView(filter, parent),
43  _filter(filter)
44 {
46  connect(Client::instance(), SIGNAL(coreConnectionStateChanged(bool)), this, SLOT(coreConnectionStateChanged(bool)));
47 }
48 
49 
50 void ChatMonitorView::addActionsToMenu(QMenu *menu, const QPointF &pos)
51 {
52  ChatView::addActionsToMenu(menu, pos);
53  menu->addSeparator();
54  QAction *showOwnNicksAction = menu->addAction(tr("Show Own Messages"), _filter, SLOT(setShowOwnMessages(bool)));
55  showOwnNicksAction->setCheckable(true);
56  showOwnNicksAction->setChecked(_filter->showOwnMessages());
57 
59  menu->addSeparator();
60 
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);
65 
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);
70  }
71 
72  menu->addSeparator();
73  menu->addAction(QIcon::fromTheme("configure"), tr("Configure..."), this, SLOT(showSettingsPage()));
74 }
75 
76 
78 {
79  if (scene()->columnByScenePos(event->pos()) != ChatLineModel::SenderColumn) {
81  return;
82  }
83 
84  ChatItem *chatItem = scene()->chatItemAt(mapToScene(event->pos()));
85  if (!chatItem) {
86  event->ignore();
87  return;
88  }
89 
90  event->accept();
91  BufferId bufferId = chatItem->data(MessageModel::BufferIdRole).value<BufferId>();
92  if (!bufferId.isValid())
93  return;
94 
96 }
97 
98 
100 {
101  QAction *showAction = qobject_cast<QAction *>(sender());
102  if (!showAction)
103  return;
104 
105  if (checked)
106  _filter->addShowField(showAction->data().toInt());
107  else
108  _filter->removeShowField(showAction->data().toInt());
109 }
110 
111 
113 {
114  SettingsPageDlg dlg(new ChatMonitorSettingsPage(), this);
115  dlg.exec();
116 }
117 
118 
119 // connect only after client is synced to core since ChatMonitorView is created before
120 // the ignoreListManager
122 {
123  if (connected)
124  connect(Client::ignoreListManager(), SIGNAL(ignoreListChanged()), _filter, SLOT(invalidateFilter()));
125 }