4 #include "../definition.h"
5 class MemberList:virtual public QTableWidget{
8 MemberList(QWidget *parent=NULL);
10 void remove_selected();
11 void remove_all_contents();
12 QList<AddressAndPort> addressPortList() const;
13 QStringList name() const;
14 friend QDataStream &operator<<(QDataStream &out,const MemberList &value){
15 QHash<QString,AddressAndPort> AddressList;
16 for(int row=0;row<value.rowCount();row++){
17 QStringList AddrAndPort=value.item(row,1)->text().split(":");
18 AddressList.insertMulti(value.item(row,0)->text(),AddressAndPort(QHostAddress(AddrAndPort[0]),(AddrAndPort.count()==2)? AddrAndPort[1].toUShort():default_port));
24 friend QDataStream &operator>>(QDataStream &in, MemberList &value){
25 QHash<QString,AddressAndPort> AddressList;
27 value.remove_all_contents();
28 for(QHash<QString,AddressAndPort>::iterator index=AddressList.begin();index!=AddressList.end();index++){
29 QTableWidgetItem *name=new QTableWidgetItem(index.key()),
30 *AddressPort=new QTableWidgetItem(QString("%1:%2").
31 arg(index.value().first.toString()).
32 arg(index.value().second));
33 value.insertRow(value.rowCount());
34 value.setItem(value.rowCount()-1,0,name);
35 value.setItem(value.rowCount()-1,1,AddressPort);
41 void keyReleaseEvent(QKeyEvent *);