/* Сopyright (c) 2009 by Nigmatullin Ruslan *************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * *************************************************************************** */ #include "xmlconsole.h" //#include "utils.h" #include #include #include XmlPrompt::XmlPrompt(QWidget *parent) : QDialog(parent) { setAttribute(Qt::WA_DeleteOnClose); setWindowTitle(tr("XML Input")); QVBoxLayout *vb1 = new QVBoxLayout(this); te = new QTextEdit(this); te->setAcceptRichText(false); vb1->addWidget(te); QHBoxLayout *hb1 = new QHBoxLayout(this); QPushButton *pb; pb = new QPushButton(tr("&Send"), this); pb->setDefault(TRUE); connect(pb, SIGNAL(clicked()), SLOT(doTransmit())); hb1->addWidget(pb); hb1->addStretch(1); pb = new QPushButton(tr("&Close"), this); connect(pb, SIGNAL(clicked()), SLOT(close())); hb1->addWidget(pb); vb1->addLayout(hb1); resize(320,240); } XmlPrompt::~XmlPrompt() { } void XmlPrompt::doTransmit() { /* Tag* tg = new Tag("fgfg"); if(!tg->setXmlns( utils::toStd(te->toPlainText())) ) { qDebug() << "not valid"; } else { qDebug() << "valid"; }*/ textReady(te->toPlainText()); close(); } XmlConsole::XmlConsole(const QString &title, QWidget *parent) : QWidget(parent) { ui.setupUi(this); setWindowTitle(title); setAttribute(Qt::WA_QuitOnClose, false); setAttribute(Qt::WA_DeleteOnClose, true); } void XmlConsole::appendTag(const QString &xml, bool in) { if(xml.size()==1) return; QString html = QString("%2

").arg(in?"yellow":"red").arg(Qt::escape(xml).replace("\n","
").replace("><",">
<")); ui.textBrowser->append(html); } void XmlConsole::sendXML() { prompt = new XmlPrompt(this); connect(prompt, SIGNAL(textReady(const QString &)), SLOT(xml_textReady(const QString &))); prompt->show(); } void XmlConsole::xml_textReady(const QString &str) { emit send(str); } void XmlConsole::clearXml() { ui.textBrowser->setHtml(QApplication::translate("XmlConsole", "\n" "\n" "

", 0, QApplication::UnicodeUTF8)); }