equal
deleted
inserted
replaced
31 connect(pUdpSocket, SIGNAL(readyRead()), this, SLOT(onClientRead())); |
31 connect(pUdpSocket, SIGNAL(readyRead()), this, SLOT(onClientRead())); |
32 } |
32 } |
33 |
33 |
34 void HWNetUdpModel::updateList() |
34 void HWNetUdpModel::updateList() |
35 { |
35 { |
36 games.clear(); |
36 beginResetModel(); |
37 |
37 |
38 reset(); |
38 games.clear(); |
39 |
39 |
40 pUdpSocket->writeDatagram("hedgewars client", QHostAddress::Broadcast, NETGAME_DEFAULT_PORT); |
40 endResetModel(); |
|
41 |
|
42 pUdpSocket->writeDatagram("hedgewars client", QHostAddress::Broadcast, NETGAME_DEFAULT_PORT); |
41 } |
43 } |
42 |
44 |
43 void HWNetUdpModel::onClientRead() |
45 void HWNetUdpModel::onClientRead() |
44 { |
46 { |
|
47 beginResetModel(); |
|
48 |
45 while (pUdpSocket->hasPendingDatagrams()) |
49 while (pUdpSocket->hasPendingDatagrams()) |
46 { |
50 { |
47 QByteArray datagram; |
51 QByteArray datagram; |
48 datagram.resize(pUdpSocket->pendingDatagramSize()); |
52 datagram.resize(pUdpSocket->pendingDatagramSize()); |
49 QHostAddress clientAddr; |
53 QHostAddress clientAddr; |
58 sl << packet.remove(0, 17) << clientAddr.toString() << QString::number(NETGAME_DEFAULT_PORT); |
62 sl << packet.remove(0, 17) << clientAddr.toString() << QString::number(NETGAME_DEFAULT_PORT); |
59 games.append(sl); |
63 games.append(sl); |
60 } |
64 } |
61 } |
65 } |
62 |
66 |
63 reset(); |
67 endResetModel(); |
64 } |
68 } |
65 |
69 |
66 QVariant HWNetUdpModel::data(const QModelIndex &index, |
70 QVariant HWNetUdpModel::data(const QModelIndex &index, |
67 int role) const |
71 int role) const |
68 { |
72 { |