461 BtnNetConnect->setFont(*font14); |
462 BtnNetConnect->setFont(*font14); |
462 BtnNetConnect->setText(QPushButton::tr("Connect")); |
463 BtnNetConnect->setText(QPushButton::tr("Connect")); |
463 GBClayout->addWidget(BtnNetConnect, 2, 2); |
464 GBClayout->addWidget(BtnNetConnect, 2, 2); |
464 |
465 |
465 tvServersList = new QTableView(ConnGroupBox); |
466 tvServersList = new QTableView(ConnGroupBox); |
|
467 tvServersList->setSelectionBehavior(QAbstractItemView::SelectRows); |
466 GBClayout->addWidget(tvServersList, 1, 0, 1, 3); |
468 GBClayout->addWidget(tvServersList, 1, 0, 1, 3); |
467 |
469 |
468 BtnUpdateSList = new QPushButton(ConnGroupBox); |
470 BtnUpdateSList = new QPushButton(ConnGroupBox); |
469 BtnUpdateSList->setFont(*font14); |
471 BtnUpdateSList->setFont(*font14); |
470 BtnUpdateSList->setText(QPushButton::tr("Update")); |
472 BtnUpdateSList->setText(QPushButton::tr("Update")); |
485 } |
487 } |
486 |
488 |
487 void PageNet::updateServersList() |
489 void PageNet::updateServersList() |
488 { |
490 { |
489 if (rbLocalGame->isChecked()) |
491 if (rbLocalGame->isChecked()) |
490 tvServersList->setModel(new HWNetUdpModel()); |
492 tvServersList->setModel(new HWNetUdpModel(tvServersList)); |
491 else |
493 else |
492 tvServersList->setModel(new HWNetWwwModel()); |
494 tvServersList->setModel(new HWNetWwwModel(tvServersList)); |
493 |
495 |
494 static_cast<HWNetServersModel *>(tvServersList->model())->updateList(); |
496 static_cast<HWNetServersModel *>(tvServersList->model())->updateList(); |
495 |
497 |
496 connect(BtnUpdateSList, SIGNAL(clicked()), static_cast<HWNetServersModel *>(tvServersList->model()), SLOT(updateList())); |
498 connect(BtnUpdateSList, SIGNAL(clicked()), static_cast<HWNetServersModel *>(tvServersList->model()), SLOT(updateList())); |
497 // connect(netServersWidget->serversList, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(slotConnect())); |
499 connect(tvServersList, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(slotConnect())); |
498 } |
500 } |
499 |
501 |
500 void PageNet::slotConnect() |
502 void PageNet::slotConnect() |
501 { |
503 { |
502 emit connectClicked("localhost", 46631); |
504 HWNetServersModel * model = static_cast<HWNetServersModel *>(tvServersList->model()); |
|
505 QModelIndex mi = tvServersList->currentIndex(); |
|
506 if(!mi.isValid()) |
|
507 { |
|
508 QMessageBox::information(this, tr("Error"), tr("Please, select server from the list above")); |
|
509 return; |
|
510 } |
|
511 QString host = model->index(mi.row(), 1).data().toString(); |
|
512 quint16 port = model->index(mi.row(), 2).data().toUInt(); |
|
513 emit connectClicked(host, 46631); |
503 } |
514 } |
504 |
515 |
505 PageNetServer::PageNetServer(QWidget* parent) : QWidget(parent) |
516 PageNetServer::PageNetServer(QWidget* parent) : QWidget(parent) |
506 { |
517 { |
507 QFont * font14 = new QFont("MS Shell Dlg", 14); |
518 QFont * font14 = new QFont("MS Shell Dlg", 14); |