#include <QInputDialog>
#include <QSettings>
#include <QTcpSocket>
-
+#include <QFuture>
+#include <QtConcurrentRun>
AccountDialog::AccountDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::AccountDialog)
{
QListWidgetItem * item = new QListWidgetItem;
- // ========> NEED TO USE QFUTUR
- // QString hostIp = settings.value(key).toString();
- // QTcpSocket * socket = new QTcpSocket(this);
- // socket->connectToHost(hostIp, 80);
- // if (socket->waitForConnected(1000))
- // item->setBackgroundColor(Qt::green);
- // else
- // item->setBackgroundColor(Qt::red);
-
-
item->setText(key);
item->setData(Qt::UserRole, settings.value(key));
if (useKey == key) {
ui->listWidget->addItem(item);
}
settings.endGroup();
+
+
+
}
+
+void AccountDialog::asyncTestConnection()
+{
+ QSettings settings;
+ settings.beginGroup("account");
+
+ for ( int i=0; i<ui->listWidget->count(); ++i)
+ {
+
+ QListWidgetItem * item = ui->listWidget->item(i);
+ QString key = item->text();
+ QString hostIp = settings.value(key).toString();
+ qDebug()<<hostIp;
+ QTcpSocket * socket = new QTcpSocket(this);
+ socket->connectToHost(hostIp, 80);
+
+ if (socket->waitForConnected(1000))
+ item->setBackgroundColor(Qt::green);
+ else
+ item->setBackgroundColor(Qt::red);
+
+
+ }
+
+ settings.endGroup();
+
+}
+
+
void AccountDialog::edit()
{
QString currentIp = ui->listWidget->currentItem()->data(Qt::UserRole).toString();