~ubuntu-branches/ubuntu/vivid/quassel/vivid-updates

« back to all changes in this revision

Viewing changes to src/qtui/chatmonitorview.cpp

  • Committer: Package Import Robot
  • Author(s): Scott Kitterman
  • Date: 2013-03-06 15:07:41 UTC
  • mfrom: (1.1.49)
  • Revision ID: package-import@ubuntu.com-20130306150741-pys1igw1g8uhja38
Tags: 0.9~beta1-0ubuntu1
* New upstream beta release
  - Remove debian/patches/0001-Support-intermediate-CA-certificates.patch,
    incorporated upstream
  - Remove 0002-Allow-the-core-to-use-expired-certificates.patch,
    incorporated upstream
  - Update kubuntu_02_enable_message_indicator.diff for 0.9

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/***************************************************************************
2
 
 *   Copyright (C) 2005-09 by the Quassel Project                          *
 
2
 *   Copyright (C) 2005-2013 by the Quassel Project                        *
3
3
 *   devel@quassel-irc.org                                                 *
4
4
 *                                                                         *
5
5
 *   This program is free software; you can redistribute it and/or modify  *
15
15
 *   You should have received a copy of the GNU General Public License     *
16
16
 *   along with this program; if not, write to the                         *
17
17
 *   Free Software Foundation, Inc.,                                       *
18
 
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 
18
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
19
19
 ***************************************************************************/
20
20
 
21
21
#include "chatmonitorview.h"
39
39
#include "clientignorelistmanager.h"
40
40
 
41
41
ChatMonitorView::ChatMonitorView(ChatMonitorFilter *filter, QWidget *parent)
42
 
  : ChatView(filter, parent),
 
42
    : ChatView(filter, parent),
43
43
    _filter(filter)
44
44
{
45
 
  scene()->setSenderCutoffMode(ChatScene::CutoffLeft);
46
 
  connect(Client::instance(), SIGNAL(coreConnectionStateChanged(bool)), this, SLOT(coreConnectionStateChanged(bool)));
47
 
}
48
 
 
49
 
void ChatMonitorView::addActionsToMenu(QMenu *menu, const QPointF &pos) {
50
 
  ChatView::addActionsToMenu(menu, pos);
51
 
  menu->addSeparator();
52
 
  QAction *showOwnNicksAction = menu->addAction(tr("Show Own Messages"), _filter, SLOT(setShowOwnMessages(bool)));
53
 
  showOwnNicksAction->setCheckable(true);
54
 
  showOwnNicksAction->setChecked(_filter->showOwnMessages());
55
 
 
56
 
  if(scene()->columnByScenePos(pos) == ChatLineModel::SenderColumn) {
57
 
    menu->addSeparator();
58
 
 
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);
63
 
 
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);
68
 
  }
69
 
 
70
 
  menu->addSeparator();
71
 
  menu->addAction(SmallIcon("configure"), tr("Configure..."), this, SLOT(showSettingsPage()));
72
 
}
73
 
 
74
 
void ChatMonitorView::mouseDoubleClickEvent(QMouseEvent *event) {
75
 
  if(scene()->columnByScenePos(event->pos()) != ChatLineModel::SenderColumn) {
76
 
    ChatView::mouseDoubleClickEvent(event);
77
 
    return;
78
 
  }
79
 
 
80
 
  ChatItem *chatItem = scene()->chatItemAt(mapToScene(event->pos()));
81
 
  if(!chatItem) {
82
 
    event->ignore();
83
 
    return;
84
 
  }
85
 
 
86
 
  event->accept();
87
 
  BufferId bufferId = chatItem->data(MessageModel::BufferIdRole).value<BufferId>();
88
 
  if(!bufferId.isValid())
89
 
    return;
90
 
 
91
 
  Client::bufferModel()->switchToBuffer(bufferId);
92
 
}
93
 
 
94
 
void ChatMonitorView::showFieldsChanged(bool checked) {
95
 
  QAction *showAction = qobject_cast<QAction *>(sender());
96
 
  if(!showAction)
97
 
    return;
98
 
 
99
 
  if(checked)
100
 
    _filter->addShowField(showAction->data().toInt());
101
 
  else
102
 
    _filter->removeShowField(showAction->data().toInt());
103
 
}
104
 
 
105
 
void ChatMonitorView::showSettingsPage() {
106
 
  SettingsPageDlg dlg(new ChatMonitorSettingsPage(), this);
107
 
  dlg.exec();
108
 
}
 
45
    scene()->setSenderCutoffMode(ChatScene::CutoffLeft);
 
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
 
 
58
    if (scene()->columnByScenePos(pos) == ChatLineModel::SenderColumn) {
 
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(SmallIcon("configure"), tr("Configure..."), this, SLOT(showSettingsPage()));
 
74
}
 
75
 
 
76
 
 
77
void ChatMonitorView::mouseDoubleClickEvent(QMouseEvent *event)
 
78
{
 
79
    if (scene()->columnByScenePos(event->pos()) != ChatLineModel::SenderColumn) {
 
80
        ChatView::mouseDoubleClickEvent(event);
 
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
 
 
95
    Client::bufferModel()->switchToBuffer(bufferId);
 
96
}
 
97
 
 
98
 
 
99
void ChatMonitorView::showFieldsChanged(bool checked)
 
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
 
 
112
void ChatMonitorView::showSettingsPage()
 
113
{
 
114
    SettingsPageDlg dlg(new ChatMonitorSettingsPage(), this);
 
115
    dlg.exec();
 
116
}
 
117
 
109
118
 
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) {
113
 
  if(connected)
114
 
    connect(Client::ignoreListManager(), SIGNAL(ignoreListChanged()), _filter, SLOT(invalidateFilter()));
 
121
void ChatMonitorView::coreConnectionStateChanged(bool connected)
 
122
{
 
123
    if (connected)
 
124
        connect(Client::ignoreListManager(), SIGNAL(ignoreListChanged()), _filter, SLOT(invalidateFilter()));
115
125
}