1
/****************************************************************************
2
** logwindow.cpp - a debug window to log colored messages
3
** Copyright (C) 2001, 2002 Justin Karneges
5
** This program is free software; you can redistribute it and/or
6
** modify it under the terms of the GNU General Public License
7
** as published by the Free Software Foundation; either version 2
8
** of the License, or (at your option) any later version.
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.
15
** You should have received a copy of the GNU General Public License
16
** along with this program; if not, write to the Free Software
17
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
19
****************************************************************************/
24
#include<qpushbutton.h>
25
#include<qbuttongroup.h>
27
LogWindow::LogWindow(QWidget *parent, const char *name)
28
:QWidget(parent, name)
30
setCaption(CAP("Log Window"));
32
QVBoxLayout *vb1 = new QVBoxLayout(this, 8);
34
te = new QTextEdit(this);
35
te->setReadOnly(TRUE);
36
te->setUndoRedoEnabled(FALSE);
37
te->setTextFormat(RichText);
39
te->setPaper(QBrush(Qt::black));
42
QHBoxLayout *hb1 = new QHBoxLayout(vb1);
43
QButtonGroup *bg = new QButtonGroup(2, Vertical, "Log debug messages from:", this);
44
db_check[0] = new QCheckBox("JabXml", bg);
45
db_check[1] = new QCheckBox("Jabber", bg);
46
db_check[2] = new QCheckBox("JabCon", bg);
47
db_check[3] = new QCheckBox("MainWin", bg);
48
db_check[4] = new QCheckBox("ContactView", bg);
49
db_check[5] = new QCheckBox("HighLevel", bg);
50
for(int n = 0; n < 6; ++n)
51
db_check[n]->setChecked(FALSE);
54
QVBoxLayout *vb2 = new QVBoxLayout(hb1);
58
pb = new QPushButton("&XML Input...", this);
59
pb->setFixedWidth(100);
60
connect(pb, SIGNAL(clicked()), SLOT(insertXml()));
63
pb = new QPushButton("&Close", this);
64
pb->setFixedWidth(100);
65
connect(pb, SIGNAL(clicked()), SLOT(close()));
71
LogWindow::~LogWindow()
75
void LogWindow::insertXml()
79
QString text = XmlPrompt::getText(&ok, this);
82
debug_jabber->insertXml(text);
86
void LogWindow::append(int depth, const QString &str)
88
if(!db_check[depth]->isChecked())
91
QColor depth2color[6] = { Qt::yellow, Qt::red, Qt::cyan, Qt::blue, Qt::green, Qt::white };
93
//te->setColor(depth2color[depth]);
95
te->append(QString("<font color=\"%1\">").arg(depth2color[depth].name()) + plain2rich(str) + "</font>\n");
100
XmlPrompt::XmlPrompt(QWidget *parent, const char *name)
101
:QDialog(parent, name, TRUE)
103
setCaption(CAP("Xml Input"));
105
QVBoxLayout *vb1 = new QVBoxLayout(this, 8);
107
te = new QTextEdit(this);
110
QHBoxLayout *hb1 = new QHBoxLayout(vb1);
113
pb = new QPushButton("&Transmit", this);
114
pb->setDefault(TRUE);
115
connect(pb, SIGNAL(clicked()), SLOT(accept()));
119
pb = new QPushButton("&Close", this);
120
connect(pb, SIGNAL(clicked()), SLOT(close()));
126
QString XmlPrompt::getText(bool *ok, QWidget *parent, const char *name)
128
XmlPrompt *p = new XmlPrompt(parent, name);
131
if(p->exec() == Accepted) {
133
result = p->te->text();