# HG changeset patch # User unc0rr # Date 1197750538 0 # Node ID 0d7683a66d61af55b6c20c210604b2971f7a2d6d # Parent 194dc62d1519adf2e554976a511abccd7760410d - Share much code between models - Update some labels diff -r 194dc62d1519 -r 0d7683a66d61 QTfrontend/hwform.cpp --- a/QTfrontend/hwform.cpp Sat Dec 15 20:08:08 2007 +0000 +++ b/QTfrontend/hwform.cpp Sat Dec 15 20:28:58 2007 +0000 @@ -91,7 +91,6 @@ connect(ui.pageOptions->WeaponsButt, SIGNAL(clicked()), this, SLOT(GoToSelectWeapon())); connect(ui.pageNet->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); - connect(ui.pageNet->BtnNetConnect, SIGNAL(clicked()), this, SLOT(NetConnectServer())); connect(ui.pageNet->BtnSpecifyServer, SIGNAL(clicked()), this, SLOT(NetConnect())); connect(ui.pageNet->BtnNetSvrStart, SIGNAL(clicked()), this, SLOT(GoToNetServer())); connect(ui.pageNet, SIGNAL(connectClicked(const QString &, quint16)), this, SLOT(NetConnectServer(const QString &, quint16))); diff -r 194dc62d1519 -r 0d7683a66d61 QTfrontend/netserverslist.cpp --- a/QTfrontend/netserverslist.cpp Sat Dec 15 20:08:08 2007 +0000 +++ b/QTfrontend/netserverslist.cpp Sat Dec 15 20:28:58 2007 +0000 @@ -31,3 +31,38 @@ { } + +QVariant HWNetServersModel::headerData(int section, + Qt::Orientation orientation, int role) const +{ + if (role != Qt::DisplayRole) + return QVariant(); + + if (orientation == Qt::Horizontal) + { + switch (section) + { + case 0: return tr("Title"); + case 1: return tr("IP"); + case 2: return tr("Port"); + default: return QVariant(); + } + } else + return QString("%1").arg(section + 1); +} + +int HWNetServersModel::rowCount(const QModelIndex &parent) const +{ + if (parent.isValid()) + return 0; + else + return games.size(); +} + +int HWNetServersModel::columnCount(const QModelIndex & parent) const +{ + if (parent.isValid()) + return 0; + else + return 3; +} diff -r 194dc62d1519 -r 0d7683a66d61 QTfrontend/netserverslist.h --- a/QTfrontend/netserverslist.h Sat Dec 15 20:08:08 2007 +0000 +++ b/QTfrontend/netserverslist.h Sat Dec 15 20:28:58 2007 +0000 @@ -20,6 +20,7 @@ #define _NET_SERVERSLIST_INCLUDED #include +#include class HWNetServersModel : public QAbstractTableModel { @@ -28,8 +29,15 @@ public: HWNetServersModel(QObject *parent = 0); + QVariant headerData(int section, Qt::Orientation orientation, int role) const; + int rowCount(const QModelIndex & parent) const; + int columnCount(const QModelIndex & parent) const; + public slots: virtual void updateList(); + +protected: + QList games; }; #endif // _NET_SERVERSLIST_INCLUDED diff -r 194dc62d1519 -r 0d7683a66d61 QTfrontend/netudpwidget.cpp --- a/QTfrontend/netudpwidget.cpp Sat Dec 15 20:08:08 2007 +0000 +++ b/QTfrontend/netudpwidget.cpp Sat Dec 15 20:28:58 2007 +0000 @@ -69,38 +69,3 @@ return games[index.row()][index.column()]; } - -QVariant HWNetUdpModel::headerData(int section, - Qt::Orientation orientation, int role) const -{ - if (role != Qt::DisplayRole) - return QVariant(); - - if (orientation == Qt::Horizontal) - { - switch (section) - { - case 0: return tr("Title"); - case 1: return tr("IP"); - case 2: return tr("Port"); - default: return QVariant(); - } - } else - return QString("%1").arg(section + 1); -} - -int HWNetUdpModel::rowCount(const QModelIndex &parent) const -{ - if (parent.isValid()) - return 0; - else - return games.size(); -} - -int HWNetUdpModel::columnCount(const QModelIndex & parent) const -{ - if (parent.isValid()) - return 0; - else - return 3; -} diff -r 194dc62d1519 -r 0d7683a66d61 QTfrontend/netudpwidget.h --- a/QTfrontend/netudpwidget.h Sat Dec 15 20:08:08 2007 +0000 +++ b/QTfrontend/netudpwidget.h Sat Dec 15 20:28:58 2007 +0000 @@ -20,7 +20,6 @@ #ifndef _NET_UDPWIDGET_INCLUDED #define _NET_UDPWIDGET_INCLUDED -#include #include "netserverslist.h" class QUdpSocket; @@ -33,9 +32,6 @@ HWNetUdpModel(QObject *parent = 0); QVariant data(const QModelIndex &index, int role) const; - QVariant headerData(int section, Qt::Orientation orientation, int role) const; - int rowCount(const QModelIndex & parent) const; - int columnCount(const QModelIndex & parent) const; public slots: void updateList(); @@ -45,7 +41,6 @@ private: QUdpSocket* pUdpSocket; - QList games; }; #endif // _NET_UDPWIDGET_INCLUDED diff -r 194dc62d1519 -r 0d7683a66d61 QTfrontend/netwwwwidget.cpp --- a/QTfrontend/netwwwwidget.cpp Sat Dec 15 20:08:08 2007 +0000 +++ b/QTfrontend/netwwwwidget.cpp Sat Dec 15 20:28:58 2007 +0000 @@ -45,41 +45,6 @@ return games[index.row()][index.column()]; } -QVariant HWNetWwwModel::headerData(int section, - Qt::Orientation orientation, int role) const -{ - if (role != Qt::DisplayRole) - return QVariant(); - - if (orientation == Qt::Horizontal) - { - switch (section) - { - case 0: return tr("Title"); - case 1: return tr("IP"); - case 2: return tr("Port"); - default: return QVariant(); - } - } else - return QString("%1").arg(section + 1); -} - -int HWNetWwwModel::rowCount(const QModelIndex &parent) const -{ - if (parent.isValid()) - return 0; - else - return games.size(); -} - -int HWNetWwwModel::columnCount(const QModelIndex & parent) const -{ - if (parent.isValid()) - return 0; - else - return 3; -} - void HWNetWwwModel::updateList() { QString request = QString("protocol_version=%1") diff -r 194dc62d1519 -r 0d7683a66d61 QTfrontend/netwwwwidget.h --- a/QTfrontend/netwwwwidget.h Sat Dec 15 20:08:08 2007 +0000 +++ b/QTfrontend/netwwwwidget.h Sat Dec 15 20:28:58 2007 +0000 @@ -19,7 +19,6 @@ #ifndef _NET_WWWWIDGET_INCLUDED #define _NET_WWWWIDGET_INCLUDED -#include #include "netserverslist.h" class QHttp; @@ -32,13 +31,9 @@ HWNetWwwModel(QObject *parent = 0); QVariant data(const QModelIndex &index, int role) const; - QVariant headerData(int section, Qt::Orientation orientation, int role) const; - int rowCount(const QModelIndex & parent) const; - int columnCount(const QModelIndex & parent) const; private: QHttp * http; - QList games; private slots: void onClientRead(int id, bool error); diff -r 194dc62d1519 -r 0d7683a66d61 QTfrontend/pages.cpp --- a/QTfrontend/pages.cpp Sat Dec 15 20:08:08 2007 +0000 +++ b/QTfrontend/pages.cpp Sat Dec 15 20:28:58 2007 +0000 @@ -437,16 +437,16 @@ QGroupBox * NetTypeGroupBox = new QGroupBox(this); NetTypeGroupBox->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); - NetTypeGroupBox->setTitle(QGroupBox::tr("Connection type")); + NetTypeGroupBox->setTitle(QGroupBox::tr("Servers list")); pageLayout->addWidget(NetTypeGroupBox, 0, 1); QVBoxLayout * GBTlayout = new QVBoxLayout(NetTypeGroupBox); rbLocalGame = new QRadioButton(NetTypeGroupBox); - rbLocalGame->setText(tr("Local game")); + rbLocalGame->setText(tr("Local")); rbLocalGame->setChecked(true); GBTlayout->addWidget(rbLocalGame); rbInternetGame = new QRadioButton(NetTypeGroupBox); - rbInternetGame->setText(tr("Internet game")); + rbInternetGame->setText(tr("Internet")); GBTlayout->addWidget(rbInternetGame); ConnGroupBox = new QGroupBox(this); @@ -481,6 +481,7 @@ pageLayout->addWidget(BtnBack, 3, 0); connect(rbLocalGame, SIGNAL(toggled(bool)), this, SLOT(updateServersList())); + connect(BtnNetConnect, SIGNAL(clicked()), this, SLOT(slotConnect())); } void PageNet::updateServersList()