QTfrontend/pages.cpp
changeset 671 a8970859f50e
parent 668 0d7683a66d61
child 672 08ed55ea1e2a
equal deleted inserted replaced
670:b4cc7ac9011f 671:a8970859f50e
    28 #include <QApplication>
    28 #include <QApplication>
    29 #include <QSpinBox>
    29 #include <QSpinBox>
    30 #include <QTextEdit>
    30 #include <QTextEdit>
    31 #include <QRadioButton>
    31 #include <QRadioButton>
    32 #include <QTableView>
    32 #include <QTableView>
       
    33 #include <QMessageBox>
    33 
    34 
    34 #include "pages.h"
    35 #include "pages.h"
    35 #include "sdlkeys.h"
    36 #include "sdlkeys.h"
    36 #include "hwconsts.h"
    37 #include "hwconsts.h"
    37 #include "gamecfgwidget.h"
    38 #include "gamecfgwidget.h"
   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);