Table::Table(QObject * parent) : QObject(parent) { ENTER("Table(QObject * parent)"); ADD_ARG("parent", parent); //Création des ordres : for(int i = 0 ; i < 5 ; i++) { joueurs.push_back(-1); // -1 : pas de joueur ordre.push_back(i); noms.push_back(""); } //Mélange de ordre : int r = 0 ; int tmp; for(unsigned int i = 1 ; i < ordre.size() ; i++) { r = rand() % (i + 1) ; //échange des cases i et r tmp = ordre[r]; ordre[r] = ordre[i]; ordre[i] = tmp; } QObject::connect(&partie, SIGNAL(doit_emettre (unsigned int, Protocole::Message, bool)), this, SLOT(doit_transmettre (unsigned int, Protocole::Message, bool))); QObject::connect(&partie, SIGNAL(termine()), this, SLOT(doit_recommencer())); nombre_tables++; DEBUG<<"Il y a maintenant "<<nombre_tables<<" table(s)."<<std::endl; }
void Registro::init() { std::stringstream ss; struct iMessage msg; pid_t pid; while (true) { msg = in->receive(0); ss << owner << " recibi " << Helper::msgToString(msg.message) << " de " << Helper::msgToString(msg.type) << std::endl; Helper::output(stdout, ss); pid = fork(); if (pid < 0) { perror("Registro: fork"); } else if (pid == 0) { switch (msg.message) { case TERMINE: msg.message = CONTINUAR; termine(); break; default: ss << owner << BG_RED << WHITE << " Error" << NORMAL << " mensaje incorrecto " << Helper::msgToString(msg.message) << " de " << Helper::msgToString(msg.type) << std::endl; Helper::output(stderr, ss); exit(EXIT_FAILURE); } out->send(msg); ss << owner << " envie " << Helper::msgToString(msg.message) << " a " << Helper::msgToString(msg.type) << std::endl; Helper::output(stderr, ss, CYAN); exit(EXIT_SUCCESS); } } }
/*! * \brief Constructeur de la fenêtre de visualisation des détails d'une UV * \param u pointeur vers l'UV à afficher * \param uvm référence vers l'UVManager */ UvAfficheur::UvAfficheur(UV& u, UVManager & uvm) : uv(u), M(uvm) { codeLabel = new QLabel("Code : "+uv.getCode(), this); titreLabel= new QLabel("Intitule : "+uv.getTitre(), this); unsigned int n=uv.getNbCredits(); QString c=QString::number(n); creditsLabel= new QLabel("Nombre de credits : "+c, this); categorieLabel = new QLabel("Categorie : "+CategorieToString(uv.getCategorie()), this); QString automne ; QString printemps; if (uv.ouvertureAutomne()==0) automne="non"; else automne="oui"; if (uv.ouverturePrintemps()==0) printemps="non"; else printemps="oui"; ouverturePLabel = new QLabel("Ouverture Printemps : "+printemps, this); ouvertureALabel = new QLabel("Ouverture Automne : "+automne, this); fin=new QPushButton("Consultation terminee", this); coucheH1=new QHBoxLayout; coucheH1->addWidget(codeLabel); coucheH2=new QHBoxLayout; coucheH2->addWidget(titreLabel); coucheH3=new QHBoxLayout; coucheH3->addWidget(creditsLabel); coucheH4=new QHBoxLayout; coucheH4->addWidget(categorieLabel); coucheH5=new QHBoxLayout; coucheH5->addWidget(ouvertureALabel); coucheH5->addWidget(ouverturePLabel); coucheH6 = new QHBoxLayout; coucheH6->addWidget(fin); couche=new QVBoxLayout; couche->addLayout(coucheH1); couche->addLayout(coucheH2); couche->addLayout(coucheH3); couche->addLayout(coucheH4); couche->addLayout(coucheH5); couche->addLayout(coucheH6); setLayout(couche); QObject::connect(fin, SIGNAL(clicked()), this, SLOT(termine())); }