QTfrontend/netwwwwidget.cpp
changeset 645 c71fe8b942ee
parent 638 e1cc516488f2
child 662 b2f914786d87
equal deleted inserted replaced
644:45454744f240 645:c71fe8b942ee
    17  */
    17  */
    18 
    18 
    19 #include <QHttp>
    19 #include <QHttp>
    20 #include <QListWidget>
    20 #include <QListWidget>
    21 #include <QDebug>
    21 #include <QDebug>
       
    22 #include <QDomDocument>
       
    23 #include <QDomElement>
       
    24 #include <QDomNode>
       
    25 #include <QDomText>
    22 
    26 
    23 #include "netwwwwidget.h"
    27 #include "netwwwwidget.h"
    24 #include "hwconsts.h"
    28 #include "hwconsts.h"
    25 
    29 
    26 HWNetWwwWidget::HWNetWwwWidget(QWidget* parent) :
    30 HWNetWwwWidget::HWNetWwwWidget(QWidget* parent) :
    42 
    46 
    43 void HWNetWwwWidget::onClientRead(int id, bool error)
    47 void HWNetWwwWidget::onClientRead(int id, bool error)
    44 {
    48 {
    45 	if (error)
    49 	if (error)
    46 	{
    50 	{
    47 		qDebug() << "Error" << http->errorString();
    51 		qWarning() << "Error" << http->errorString();
    48 		return;
    52 		return;
    49 	}
    53 	}
    50 	serversList->clear();
    54 	serversList->clear();
    51 	serversList->addItem(http->readAll());
    55 
       
    56 	QDomDocument doc;
       
    57 	if (!doc.setContent(http->readAll())) return;
       
    58 
       
    59 	QDomElement docElem = doc.documentElement();
       
    60 
       
    61 	QDomNode n = docElem.firstChild();
       
    62 	while (!n.isNull())
       
    63 	{
       
    64 		QDomElement e = n.toElement(); // try to convert the node to an element.
       
    65 		if(!e.isNull() && (e.tagName() == "ip"))
       
    66 		{
       
    67 			QDomText t = e.firstChild().toText();
       
    68 			if(!t.isNull())
       
    69 				serversList->addItem(t.data());
       
    70 		}
       
    71 		n = n.nextSibling();
       
    72 	}
    52 }
    73 }