1/***************************************************************************
2 * Copyright (C) 2005-2014 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 "debugbufferviewoverlay.h"
22
23#include <QFormLayout>
24#include <QLabel>
25#include <QLineEdit>
26#include <QTextEdit>
27
28#include "buffermodel.h"
29#include "bufferviewoverlay.h"
30#include "bufferviewoverlayfilter.h"
31#include "client.h"
32
33DebugBufferViewOverlay::DebugBufferViewOverlay(QWidget *parent)
34 : QWidget(parent)
35{
36 ui.setupUi(this);
37
38 BufferViewOverlayFilter *filter = new BufferViewOverlayFilter(Client::bufferModel(), Client::bufferViewOverlay());
39
40 filter->setParent(ui.bufferView);
41
42 ui.bufferView->setModel(filter);
43 ui.bufferView->setColumnWidth(0, 250);
44 ui.bufferView->setColumnWidth(1, 250);
45 ui.bufferView->setColumnWidth(2, 80);
46 ui.bufferView->resize(610, 300);
47 ui.bufferView->show();
48
49 QFormLayout *layout = new QFormLayout(ui.overlayProperties);
50 layout->addRow(tr("BufferViews:"), _bufferViews = new QLineEdit(this));
51 layout->addRow(tr("All Networks:"), _allNetworks = new QLabel(this));
52 layout->addRow(tr("Networks:"), _networks = new QLineEdit(this));
53 layout->addRow(tr("Buffers:"), _bufferIds = new QTextEdit(this));
54 layout->addRow(tr("Removed buffers:"), _removedBufferIds = new QTextEdit(this));
55 layout->addRow(tr("Temp. removed buffers:"), _tempRemovedBufferIds = new QTextEdit(this));
56
57 layout->addRow(tr("Allowed buffer types:"), _allowedBufferTypes = new QLabel(this));
58 layout->addRow(tr("Minimum activity:"), _minimumActivity = new QLabel(this));
59
60 layout->addRow(tr("Is initialized:"), _isInitialized = new QLabel(this));
61
62 update();
63 connect(Client::bufferViewOverlay(), SIGNAL(hasChanged()), this, SLOT(update()));
64}
65
66
67void DebugBufferViewOverlay::update()
68{
69 BufferViewOverlay *overlay = Client::bufferViewOverlay();
70
71 _allNetworks->setText(overlay->allNetworks() ? "yes" : "no");
72
73 QStringList ids;
74 foreach(int bufferViewId, overlay->bufferViewIds()) {
75 ids << QString::number(bufferViewId);
76 }
77 _bufferViews->setText(ids.join(", "));
78
79 ids.clear();
80 foreach(NetworkId networkId, overlay->networkIds()) {
81 ids << QString::number(networkId.toInt());
82 }
83 _networks->setText(ids.join(", "));
84
85 ids.clear();
86 foreach(BufferId bufferId, overlay->bufferIds()) {
87 ids << QString::number(bufferId.toInt());
88 }
89 _bufferIds->setText(ids.join(", "));
90
91 ids.clear();
92 foreach(BufferId bufferId, overlay->removedBufferIds()) {
93 ids << QString::number(bufferId.toInt());
94 }
95 _removedBufferIds->setText(ids.join(", "));
96
97 ids.clear();
98 foreach(BufferId bufferId, overlay->tempRemovedBufferIds()) {
99 ids << QString::number(bufferId.toInt());
100 }
101 _tempRemovedBufferIds->setText(ids.join(", "));
102
103 _allowedBufferTypes->setText(QString::number(overlay->allowedBufferTypes()));
104 _minimumActivity->setText(QString::number(overlay->minimumActivity()));
105
106 _isInitialized->setText(overlay->isInitialized() ? "yes" : "no");
107}
108