中国象棋的C++代码
#include "chess_zn.h"
QTcpSocket * Chess_ZN::client = new QTcpSocket;
QUndoStack * Chess_ZN::undoStack = new QUndoStack();
int Chess_ZN::second = 120;
bool Chess_ZN::isTurn = false;
Chess_ZN::Chess_ZN(QWidget *parent)
: QWidget(parent)
{
init();
initElse();
}
void Chess_ZN::initElse(){
treeitem = 1;
timer=new QTimer;
portmap=0;
isConn = true;
start = false;
isTimer = false;
isSearch = false;
connect(timer,SIGNAL(timeout()),this,SLOT(stopWatch()));
connect(wigettree[1],SIGNAL(itemClicked(QTreeWidgetItem*,int)),this,SLOT(getInfo(QTreeWidgetItem*)));
connect(wigettree[0],SIGNAL(itemClicked(QTreeWidgetItem*,int)),this,SLOT(connectToHost_PK(QTreeWidgetItem*)));
connect(client,SIGNAL(connected()),this,SLOT(connected()));
//连接一旦断开
connect(client,SIGNAL(error(QAbstractSocket::SocketError)),this,SLOT(error(QAbstractSocket::SocketError )));
connect(client,SIGNAL(readyRead()),this,SLOT(readyRead()));
peer = new PeerManager(this);
peer->setServerPort(10001);
items=wigettree[1]->currentItem();
item_pk=wigettree[0]->currentItem();
item_pk_info=wigettree[0]->currentItem();
connect(undoStack, SIGNAL(canUndoChanged(bool)),action2[8], SLOT(setEnabled(bool)));
connect(undoStack, SIGNAL(canUndoChanged(bool)),action2[9], SLOT(setEnabled(bool)));
connect(undoStack, SIGNAL(canUndoChanged(bool)),action2[10], SLOT(setEnabled(bool)));
connect(undoStack, SIGNAL(canUndoChanged(bool)),action2[11], SLOT(setEnabled(bool)));
connect(undoStack, SIGNAL(canUndoChanged(bool)),button[0], SLOT(setEnabled(bool)));
connect(undoStack, SIGNAL(canUndoChanged(bool)),button[1], SLOT(setEnabled(bool)));
connect(undoStack, SIGNAL(canUndoChanged(bool)),button[2], SLOT(setEnabled(bool)));
connect(undoStack, SIGNAL(canUndoChanged(bool)),button[3], SLOT(setEnabled(bool)));
timer->start(1000);
createUndoView();
isChoose = true;
tableeditor=new TableEditor("users");
}
void Chess_ZN::createUndoView()
{
undoVie