#include"paihao.h"
#include<QtGui>
#include"server.h"
static int gerenxyw=0;
static int qiyexyw=0;
static int vipxyw=0;
paihao::paihao()
{
setWindowTitle(tr("操作窗口"));
//first
label=new QLabel(tr("个人业务"));
xywbut1=new QPushButton(tr("下一位"));
QVBoxLayout *wbuju1 = new QVBoxLayout;
wbuju1->addWidget(label);
wbuju1->addWidget(xywbut1);
//second
label1=new QLabel(tr("企业业务"));
xywbut2=new QPushButton(tr("下一位"));
QVBoxLayout *wbuju2 = new QVBoxLayout;
wbuju2->addWidget(label1);
wbuju2->addWidget(xywbut2);
//third
label2=new QLabel(tr("vip业务"));
xywbut3=new QPushButton(tr("下一位"));
QVBoxLayout *wbuju3 = new QVBoxLayout;
wbuju2->addWidget(label2);
wbuju2->addWidget(xywbut3);
QVBoxLayout * sbuju1=new QVBoxLayout;
sbuju1->addLayout(wbuju1);
sbuju1->addLayout(wbuju2);
sbuju1->addLayout(wbuju3);
qdbut1=new QPushButton(tr("确定"));
QPushButton *tcbut =new QPushButton(tr("退出"));
QHBoxLayout * sbuju2=new QHBoxLayout;
sbuju2->addWidget(qdbut1);
sbuju2->addWidget(tcbut);
QVBoxLayout * main=new QVBoxLayout;
main->addLayout(sbuju1);
main->addLayout(sbuju2);
setLayout(main);
setFixedSize(300,260);
xianshi = new Child();
connect(qdbut1,SIGNAL(clicked()),this,SLOT(qdbut1slot()));
connect(tcbut,SIGNAL(clicked()),this,SLOT(close()));
connect(xywbut1,SIGNAL(clicked()),this,SLOT(xyw1slot()));
connect(xywbut2,SIGNAL(clicked()),this,SLOT(xyw2slot()));
connect(xywbut3,SIGNAL(clicked()),this,SLOT(xyw3slot()));
connect(xianshi,SIGNAL(infoSend(const QString &)),this,SLOT(infoRecv(const QString &)));
}
void paihao::qdbut1slot()
{
qdbut1->setEnabled(false);
//创建子窗体
xianshi->setAutoFillBackground(true);
QPalette palette =xianshi->palette();
palette.setBrush(QPalette::Window,QBrush(QPixmap("./333.bmp").scaled(xianshi->size(),Qt::IgnoreAspectRatio,Qt::SmoothTransformation)));
xianshi->setPalette(palette);
xianshi->show();
server *server1 = new server(this);
connect(server1,SIGNAL(updateServer(QString,int)),this,SLOT(updateServer(QString,int)));
printf("创建连接!\n");
// fflush(stdout);
}
void paihao::xyw1slot()
{
extern int i;
if(gerenxyw<i)
{
gerenxyw++;
printf("%d\n",gerenxyw);
QString gerenlabel;
gerenlabel.append(tr("正在为"));
gerenlabel.append(QString::number(gerenxyw));
gerenlabel.append(tr("号顾客服务"));
label->setText(gerenlabel);
QString cdgeren;
cdgeren.append(tr("请个人"));
cdgeren.append(QString::number(gerenxyw));
cdgeren.append(tr("号客户到一号窗口办理业务!"));
xianshi->chuandi.setText(cdgeren);
}
else
{ printf("没人了!\n");
mr=QString(tr("个人业务没人了!"));
label->setText(mr);
mr=QString(tr("本窗口空闲中!"));
xianshi->chuandi.setText(mr);
}
}
void paihao::xyw2slot()
{
extern int j;
if(qiyexyw<j)
{
qiyexyw++;
printf("%d\n",qiyexyw);
QString qiyelabel;
qiyelabel.append(tr("正在为"));
qiyelabel.append(QString::number(qiyexyw));
qiyelabel.append(tr("号顾客服务"));
label1->setText(qiyelabel);
QString cdqiye;
cdqiye.append(tr("请企业"));
cdqiye.append(QString::number(qiyexyw));
cdqiye.append(tr("号客户到一号窗口办理业务!"));
xianshi->chuandi.setText(cdqiye);
}
else
{
printf("没人了!\n");
mr=QString(tr("企业业务没人了!"));
label1->setText(mr);
mr=QString(tr("本窗口空闲中"));
xianshi->chuandi.setText(mr);
}
}
void paihao::xyw3slot()
{
extern int k;
if(vipxyw<k)
{
vipxyw++;
printf("%d\n",vipxyw);
QString viplabel;
viplabel.append(tr("正在为"));
viplabel.append(QString::number(vipxyw));
viplabel.append(tr("号顾客服务"));
label2->setText(viplabel);
QString cdvip;
cdvip.append(tr("请vip"));
cdvip.append(QString::number(vipxyw));
cdvip.append(tr("号客户到一号窗口办理业务!"));
xianshi->chuandi.setText(cdvip);
}
else
{
printf("没人了!\n");
mr=QString(tr("vip业务没人了!"));
label2->setText(mr);
mr=QString(tr("本窗口空闲中"));
xianshi->chuandi.setText(mr);
}
}
void paihao::updateServer(QString msg,int length)
{
//label->addItem(msg.left(length));
}