cmake: avoid de-duplication of user's CXXFLAGS
[quassel.git] / src / qtui / debugbufferviewoverlay.cpp
1 /***************************************************************************
2  *   Copyright (C) 2005-2020 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
33 DebugBufferViewOverlay::DebugBufferViewOverlay(QWidget* parent)
34     : QWidget(parent)
35 {
36     ui.setupUi(this);
37
38     auto* 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     auto* 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(), &BufferViewOverlay::hasChanged, this, &DebugBufferViewOverlay::update);
64 }
65
66 void DebugBufferViewOverlay::update()
67 {
68     BufferViewOverlay* overlay = Client::bufferViewOverlay();
69
70     _allNetworks->setText(overlay->allNetworks() ? "yes" : "no");
71
72     QStringList ids;
73     foreach (int bufferViewId, overlay->bufferViewIds()) {
74         ids << QString::number(bufferViewId);
75     }
76     _bufferViews->setText(ids.join(", "));
77
78     ids.clear();
79     foreach (NetworkId networkId, overlay->networkIds()) {
80         ids << QString::number(networkId.toInt());
81     }
82     _networks->setText(ids.join(", "));
83
84     ids.clear();
85     foreach (BufferId bufferId, overlay->bufferIds()) {
86         ids << QString::number(bufferId.toInt());
87     }
88     _bufferIds->setText(ids.join(", "));
89
90     ids.clear();
91     foreach (BufferId bufferId, overlay->removedBufferIds()) {
92         ids << QString::number(bufferId.toInt());
93     }
94     _removedBufferIds->setText(ids.join(", "));
95
96     ids.clear();
97     foreach (BufferId bufferId, overlay->tempRemovedBufferIds()) {
98         ids << QString::number(bufferId.toInt());
99     }
100     _tempRemovedBufferIds->setText(ids.join(", "));
101
102     _allowedBufferTypes->setText(QString::number(overlay->allowedBufferTypes()));
103     _minimumActivity->setText(QString::number(overlay->minimumActivity()));
104
105     _isInitialized->setText(overlay->isInitialized() ? "yes" : "no");
106 }