QNetworkAccessManager *check[1024];
QNetworkAccessManager *check[1024];
To copy to clipboard, switch view to plain text mode
void Checker::test()
{
int count = ui->hosts->topLevelItemCount();
if(count == 0)
{
QMessageBox::information(this,
"Info",
"Hosts list is empty.");
return;
}
ui->progHosts->setMaximum(count);
ui->progHosts->setValue(0);
for(int i = 0; i < count; ++i)
{
check[i] = new QNetworkAccessManager;
check
[i
]->get
(QNetworkRequest
(QUrl(item
->text
(0))));
connect(check[i], SIGNAL(finished(QNetworkReply *)), this, SLOT(testCallback(QNetworkReply *)));
}
}
void Checker::testCallback(QNetworkReply *reply)
{
if(!item)
return;
if(reply->error())
{
item->setText(2, reply->errorString());
item
->setTextColor
(2,
QColor(255,
0,
0));
}
else
{
item->setText(2, "OK");
item
->setTextColor
(2,
QColor(0,
255,
0));
}
}
void Checker::test()
{
int count = ui->hosts->topLevelItemCount();
if(count == 0)
{
QMessageBox::information(this, "Info", "Hosts list is empty.");
return;
}
ui->progHosts->setMaximum(count);
ui->progHosts->setValue(0);
for(int i = 0; i < count; ++i)
{
QTreeWidgetItem *item = ui->hosts->topLevelItem(i);
check[i] = new QNetworkAccessManager;
check[i]->setProxy(QNetworkProxy(QNetworkProxy::HttpProxy, "somerandomproxy.org", 80));
check[i]->get(QNetworkRequest(QUrl(item->text(0))));
connect(check[i], SIGNAL(finished(QNetworkReply *)), this, SLOT(testCallback(QNetworkReply *)));
}
}
void Checker::testCallback(QNetworkReply *reply)
{
QTreeWidgetItem *item = ui->hosts->topLevelItem(1);
if(!item)
return;
if(reply->error())
{
item->setText(2, reply->errorString());
item->setTextColor(2, QColor(255, 0, 0));
}
else
{
item->setText(2, "OK");
item->setTextColor(2, QColor(0, 255, 0));
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks