Esempio n. 1
0
/**
 * @brief MainWindow::fillDemoData befüllt Datenbank mit Demo-Daten, falls sie leer ist.
 * @param more wenn true, dann wird Datenbank auch befüllt, wenn bereits Daten in DB sind.
 */
void MainWindow::fillDemoData(bool more){
    QString addNo = "";
    if (more){
        qsrand( QDateTime::currentDateTime().toTime_t() );
        addNo = " ("+QString::number(qrand()%100)+")";
    }

    if (more || (lendlib->getMList().empty() && lendlib->getPList().empty())){
        int m1 = addMedium(book,"Die Bibel"+addNo,"");
        int m2 = addMedium(book,"Eragon"+addNo,"Christopher Paolini");
        addMedium(book,"Harry Potter"+addNo, "J. K. Rowling");
        int m4 = addMedium(cd,"Take That: Best of"+addNo, "Take That");
        int m5 = addMedium(dvd,"Harry Potter"+addNo, "Chris Columbus");
        int m6 =  addMedium(other,"Programmierung I Skript"+addNo,"");

        int p1 = addPerson("Hans"+addNo);
        int p2 = addPerson("Klaus"+addNo);
        int p3 = addPerson("Gabi"+addNo);
        addPerson("Brunhilde"+addNo);

        lendMedium(m1, p1);
        lendMedium(m2, p2);
        lendMedium(m4, p1);
        lendMedium(m5, p1);
        lendMedium(m6, p3);
    }
}
Esempio n. 2
0
	void Menu::keyEvent(const KeyPressEvent& event)
	{
		gui.keyEvent(event);

		if (event.getCode() == SDLK_RETURN)
		{
			addPerson();
		}

		if (event.getCode() == SDLK_F1)
		{
			play();
		}

		if (event.getCode() == SDLK_F3)
		{
			if (deleteQuestion())
			{
				cleanPersonData();
			}
		}

		if (event.getCode() == SDLK_ESCAPE)
		{
			close();
		}
	}
//========PRIVATE FUNCTIONS==========
//--menus--
void Interface::addCompOrPerson()
{
    newMenu("ADD VIEW");

    char ch = ' ';

    cout << "(1) to add a computer scientist\n"
            "(2) to add a computer\n"
            "enter anything else to go to main menu \n";
    printLines();

    cout << "Choice: ";
    cin.ignore(1, '\n');
    ch = cin.get();

    switch(ch)
    {
    case '1':
        addPerson();
        break;
    case '2':
        addComputer();
        break;
    default:
        break;
    }
}
Esempio n. 4
0
void MainWindow::on_captureButton_clicked()
{
    addPerson();
    if(numberImages > 0)
    {
        ui->doneButton->setEnabled(true);
    }
}
Esempio n. 5
0
/**
 * if @param family or @param person equals to "0", nothing will happen
 * or a family and/or a person will be created if needed
 */
int Pedigree::add(const std::string& family, const std::string& person) {
  if (family == "0" || person == "0") return 0;

  int fid, pid;
  fid = getFamilyID(family);
  pid = getPersonID(person);

  if (fid < 0 && pid < 0) {  // both new
    addFamily(family);
    addPerson(person);
    fid = getFamilyID(family);
    pid = getPersonID(person);
    this->family[fid].addPerson(pid);
    this->people[pid].setFamily(fid);
    return 0;
  } else if (fid < 0 && pid >= 0) {  // new fam, old indv,
    fprintf(stderr,
            "Duplicated person [ %s ] in a new family [ %s ], this is not a "
            "supported feature.\n",
            person.c_str(), family.c_str());
    return -1;
  } else if (fid >= 0 && pid < 0) {  // known fam, new indv
    addPerson(person);
    pid = getPersonID(person);
    this->family[fid].addPerson(pid);
    this->people[pid].setFamily(fid);
    return 0;
  } else {  // both known
    bool OK = this->family[fid].containPerson(pid) &&
              this->people[pid].getFamily() == fid;
    if (!OK) {
      // TODO: when different family have the same person id, then this line
      // will have problem
      // see: ~/rvtests.dev/test.meta/in.ped
      fprintf(stderr,
              "Duplicated person [ %s ] in the duplicated family [ %s ], but "
              "not consistent to previous entries\n",
              person.c_str(), family.c_str());
      return -1;
    }
    return 0;
  }
  return 0;
};
Esempio n. 6
0
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent),ui(new Ui::MainWindow)
{
    ui->setupUi(this);



    InitData();
    Resetbro();
    connect(&stuForm,SIGNAL(add()),this,SLOT(addPerson()));
    connect(&stuForm,SIGNAL(Insert()),this,SLOT(InsertPeoson()));
}
Esempio n. 7
0
/**
 * @brief MainWindow::addPersonButton reagiert, wenn der Button zum Hinzufügen einer Person gedrückt wurde.
 */
void MainWindow::addPersonButton(){
    /// Setzt in jedem Fall einen Namen voraus
    if(ui->addPersonName->text().isEmpty()){
        QMessageBox msgBox;
        msgBox.setText("Bitte einen Namen eingeben.");
        msgBox.exec();
    } else {
        /// Fügt Person hinzu
        addPerson(ui->addPersonName->text());
        ui->addPersonName->setText("");
    }
}
Esempio n. 8
0
KAboutApplication::KAboutApplication( const KAboutData *aboutData, QWidget *parent, const char *name, bool modal)
        : AboutDlgBase(parent, name, modal)
{
    SET_WNDPROC

    setCaption(caption());



    connect(btnOK, SIGNAL(clicked()), this, SLOT(close()));
    setIcon(Pict("licq"));
    lblIcon->setPixmap(Icon("licq").pixmap(QIconSet::Large, QIconSet::Normal));
    lblVersion->setText(i18n("%1 Version: %2") .arg(aboutData->appName()) .arg(aboutData->version()));
    txtAbout->setText((QString("<center><br>%1<br><br>%2<br><br>") +
                       "<a href=\"%3\">%4</a><br><br>" +
                       i18n("Bug report") + ": <a href=\"mailto:%5\">%6</a>" +
                       "</center>")
                      .arg(quote(aboutData->shortDescription()))
                      .arg(quote(aboutData->copyrightStatement()))
                      .arg(quote(aboutData->homepage()))
                      .arg(quote(aboutData->homepage()))
                      .arg(quote(aboutData->bugAddress()))
                      .arg(quote(aboutData->bugAddress())));
    QString txt;
    QValueList<KAboutPerson>::ConstIterator it;
    for (it = aboutData->authors().begin();
            it != aboutData->authors().end(); ++it)
    {
        txt += addPerson(&(*it));
        txt += "<br>";
    }
    txtAuthors->setText(txt);
    txt = "";
    QValueList<KAboutTranslator> translators = aboutData->translators();
    QValueList<KAboutTranslator>::ConstIterator itt;
    if (!translators.isEmpty()){
        for (itt = translators.begin();
                itt != translators.end(); ++itt)
        {
            const KAboutTranslator &t = *itt;
            txt += QString("%1 &lt;<a href=\"mailto:%2\">%3</a>&gt;<br>")
                   .arg(quote(t.name()))
                   .arg(quote(t.emailAddress()))
                   .arg(quote(t.emailAddress()));
            txt += "<br>";
        }
        txtTranslations->setText(txt);
    }else{
        tabMain->removePage(tabTranslation);
    }
    txtLicence->setText(quote(aboutData->license()));
}
Esempio n. 9
0
int main(void) {
    FILE *file;
    int switchRun;
    int endRequested = 0;
    struct person *list = NULL;
    file = fopen(FILENAME, "r");
    if (file == NULL) {
        perror("Cant read file");
        return 1;
    }

    list = loadFromFile(file);

    printf("- LOADED ---------------------\n");
    printPersons(list);

    while (endRequested == 0) {
        printf("- MENU ---------------------\n");
        printf("[1] - addPerson\n");
        printf("[2] - deletePerson\n");
        printf("[3] - age\n");
        printf("[4] - city == 'Presov'\n");
        printf("other - close\n");
        scanf("%d", &switchRun);
        switch (switchRun) {
            case 1 :
                list = addPerson(list);
                break;
            case 2 :
                list = delPerson(list);
                break;
            case 3 :
                age(list);
                break;
            case 4 :
                city(list, "Presov");
                break;
            default:
                endRequested = 1;
        }
    }
    freeItems(list);
    return 0;
}
Esempio n. 10
0
MainMenuItem::MainMenuItem()
  : m_defaultItemSize( 55 )
{
  m_timer.setSingleShot( true );
  connect( &m_timer, SIGNAL( timeout() ), SLOT( hideItems() ) );

  setItemSize( m_defaultItemSize );

  setBrush( QColor( 230,229,229 ) );

  QPen pen;
  pen.setBrush( Qt::NoBrush );
  setPen( pen );

  QGraphicsTextItem *textItem = new QGraphicsTextItem( i18n("Menu"), this );

  int textWidth = textItem->boundingRect().width();
  int textHeight = textItem->boundingRect().height();

  textItem->setPos( - textWidth / 2, - textHeight / 2 );

  m_fanMenu = new FanMenu( this );
  m_fanMenu->setZValue( 50 );
  m_fanMenu->hide();
  m_fanMenu->setStartAngle( 170 );
  m_fanMenu->setEndAngle( 280 );
  m_fanMenu->setRadius( 220 );
  m_fanMenu->setSpacing( 5 );

  FanMenuItem *menuItem = m_fanMenu->addItem( i18n("Clone\ngroup") );
  connect( menuItem, SIGNAL( clicked() ), SIGNAL( cloneGroup() ) );
  menuItem = m_fanMenu->addItem( i18n("Remove\ngroup") );
  connect( menuItem, SIGNAL( clicked() ), SIGNAL( removeGroup() ) );
  menuItem = m_fanMenu->addItem( i18n("Add\ngroup") );
  connect( menuItem, SIGNAL( clicked() ), SIGNAL( addGroup() ) );
  menuItem = m_fanMenu->addItem( i18n("Add\nperson") );
  connect( menuItem, SIGNAL( clicked() ), SIGNAL( addPerson() ) );

  m_fanMenu->setupItems( 90 );

  setAcceptHoverEvents( true );
}
Esempio n. 11
0
int main () {
    char name[NAME_LEN];
    int number_people = 0;  // total number of people
    int money = 0;
    int number_gpeople = 0; // number of people who receive the gifts
    int i = 0;
    int j = 0;

    FILE *fin  = fopen( "gift1.in", "r" );
    FILE *fout = fopen( "gift1.out", "w" );

    // get number of people
    fscanf( fin, "%d", &number_people );

    // get people
    for( i = 0; i < number_people; i++){
        fscanf( fin, "%s", name );
        addPerson( people + i, name);
    }

    // change money
    for( i = 0; i < number_people; i++){
        fscanf( fin, "%s", name );
        fscanf( fin, "%d %d", &money, &number_gpeople );
        changeMoney( people, name, -money );
        if( number_gpeople != 0){
            changeMoney( people, name, money % number_gpeople );
            for( j = 0; j < number_gpeople; j++){
                fscanf( fin, "%s", name );
                changeMoney( people, name, money / number_gpeople );
            }
        }
    }
    
    // print money
    for( i = 0; i < number_people; i++){
        fprintf( fout, "%s %d\n", ( people + i )->name, ( people + i )->money );
    }

    return 0;
}
Esempio n. 12
0
int testRealistic() {
	int memoryNeeded = 0;
	int i;
	int j;

	for (j = 0; j < 1000; j++) {
		for (i = 0; i < 1000; i++) {
			int nameLength = (1 + rand() % 200);
			memoryNeeded += nameLength + sizeof(Node);
			char *name = malloc(nameLength);
			if (!name) continue;
			addPerson(name);
			int j;
			for (j = 0; j < nameLength; j++) {
				name[j] = 65 + rand() % 25;
			}
			//printf("%s\n", name);
		}
		removeRandomPeople();
	}
	return memoryNeeded;	
}
Esempio n. 13
0
/*Output: none*/
void *handleClient(void *args)
{
  void *ret = (void *)calloc(1, sizeof(void));
  int i;
  int size = 0;
  int sockfd = *(int *)(args);
  char *response;
  char *message = (char *)calloc(MAX_STR + 1, sizeof(char));
  char **commands;
  
  /*Loop until client is done.*/
  while(1)
  {
    memset(message, '\0', MAX_STR + 1);
    size = recv(sockfd, message, MAX_STR + 1, 0); /*Add one so we can append '\0'*/
    if(size < 0)
    {
      perror("Error reading socket");
      free(message);
      return ret;
    }
    
    printf("\nGot: %s", message);
    fflush(NULL);
    commands = parseCommand(message);
    
    if(commands == NULL)
    {
      /*tell user to try again*/
    }
    else if(strcmp(commands[0], "EXIT") == 0)
    {
      printf("\nClient: %d exiting", sockfd);
      free(message);
      close(sockfd);
      return ret;
    }
    else if(strcmp(commands[0], "ADD_PERSON") == 0)
    {
      perror("chose add person");
      response = addPerson(commands);
    }
    else if(strcmp(commands[0], "GET_SSNS") == 0)
    {
      response = getSSNs(commands[1]);
    }
    else
    {
      perror("chose else");
      response = getInfo(commands[0], commands[1]);
    }      
    
    /*free the command list*/
    for(i=0 ; i<MAX_STR ; i++)
    {
      free(commands[i]);
    }
    free(commands);
    
    printf("sending message: %s", response);
    fflush(NULL);
    send(sockfd, response, strlen(response), 0);
    perror("sent message");
    free(response);
  }
}
Esempio n. 14
0
Person modify( vector<Person>& people ) {      // User menu that changes a persons template for the modify person operation
    QTextStream in(stdin);
    Person temp;
    string gender;
    QString birth, death, name, numId;
    char modify;
    int id = 0;

    cout << "Select a person to modify(input the number displayed before the name): ";
    while( !(id > 0 && id <= int( people.size() ) )) {
        numId = in.readLine();
        id = numId.toInt();
    }

    temp = people[id-1];

    cout << "  1. Name\n" <<
            "  2. Gender\n" <<
            "  3. Birth date\n" <<
            "  4. Death date\n" <<
            "  5. All" << endl;
    cout << "What would you like to modify: ";
    cin >> modify;

    switch( modify ) {
    case '1':                                   //To modify name only
        cout << "Name: ";
        cin.ignore();
        name = "";
        while( name == "" )
                name = in.readLine();
        temp.setName( name );
        break;

    case '2':                                   //To modify gender only
        cout << "Gender(male/female): ";
        do{
            cin >> gender;
            cin.ignore();
            if(gender == "male" || gender == "Male")
                temp.setGender( 1 );
            else if(gender == "female" || gender == "Female")
                temp.setGender( 2 );
            else
                cout << "Not a valid entry!";
        } while( !(temp.getGender( ) == 1 || temp.getGender( ) == 2) );
        break;

    case '3':                                   //To modify birth year only
        do{
            cout << "Birth year(dd.mm.yyyy): ";
            birth = in.readLine();
            temp.setBirth( QDate::fromString( birth, "dd.MM.yyyy" ) );
            if( !(temp.getBirth().isValid()) )
                cout <<"Not a valid date!"<< endl;

        }while( !(temp.getBirth().isValid()) );
        break;

    case '4':                                   //To modify death year only
        do{
            cout << "Death year(dd.mm.yyyy, enter 0 if person is still alive): ";
            death = in.readLine();
            temp.setDeath( QDate::fromString( death, "dd.MM.yyyy" ) );
            if( death == "0" )
                break;
            if( !(temp.getDeath().isValid()) )
                cout <<"Not a valid date!" << endl;
        }while( !(temp.getDeath().isValid()) );
        break;

    case '5':                                   //To modify all
        temp = addPerson();

        break;

    default:
        cout << "Not a valid option" << endl;
        break;
    }

    temp.setId( people[id-1].getId() );

    cout << endl;
    return temp;
}
Esempio n. 15
0
/**
 * @brief MainWindow::fillLibFromFile füllt die Datenbank mit den Daten aus den entsprechenden .csv Dateien
 * (lendlibLend.csv für die Beziehung, lendlibMedia.csv für die Medien und lendlibPerson.csv für Personen)
 */
void MainWindow::fillLibFromFile(){
    QFile lendFile("lendlibLend.csv");
    QFile mFile("lendlibMedia.csv");
    QFile pFile("lendlibPerson.csv");
    QList<int> idList;
    /// Lese alle Medien aus
    if (mFile.open(QIODevice::ReadOnly|QFile::Truncate)) {
        int lineNumber = 1;
        mFile.readLine();
        while (!mFile.atEnd()) {
            QByteArray line = mFile.readLine().replace(QByteArray("\n"),QByteArray(""));
            lineNumber++;
            QList<QByteArray> lineElements = line.split('\t');
            /// - Prüfe, ob Format richtig ist (4 Spalten)
            if (lineElements.length() == 4){
                int newID = lineElements[0].toInt();
                /// - Prüfe, ob ID in .csv korrekt ist
                if(idList.contains(newID)){
                    errString = "Fehler beim Lesen der Datei 'lendlibMedia.csv' in Zeile "+ QString::number(lineNumber)+" (ID bereits vorhanden).";
                    readErr = true;
                    return;
                }
                idList.append(newID);
                MType mType;
                switch (lineElements[1].toInt()){
                case 0:
                    mType = book;
                    break;
                case 1:
                    mType = cd;
                    break;
                case 2:
                    mType = dvd;
                    break;
                default:
                    mType = other;
                }
                /// - Füge Medium hinzu
                addMedium(mType,QString::fromStdString(lineElements[2].toStdString()),QString::fromStdString(lineElements[3].toStdString()),newID);
            } else {
                errString = "Fehler beim Lesen der Datei 'lendlibMedia.csv' in Zeile "+ QString::number(lineNumber)+" (Zeile enthält nicht 3 Elemente).";
                readErr = true;
                return;
            }
        }
    }
    /// Lese alle Personen aus
    if (pFile.open(QIODevice::ReadOnly|QFile::Truncate)) {
        int lineNumber = 1;
        pFile.readLine();
        while (!pFile.atEnd()) {
            QByteArray line = pFile.readLine().replace(QByteArray("\n"),QByteArray(""));
            lineNumber++;
            QList<QByteArray> lineElements = line.split('\t');
            /// - Prüfe, ob Format richtig ist (2 Spalten)
            if (lineElements.length() == 2){
                int newID = lineElements[0].toInt();
                /// - Prüfe, ob ID in .csv korrekt ist
                if(idList.contains(newID)){
                    errString = "Fehler beim Lesen der Datei 'lendlibPerson.csv' in Zeile "+ QString::number(lineNumber)+" (ID bereits vorhanden).";
                    readErr = true;
                    return;
                }
                idList.append(newID);
                /// - Füge Person hinzu
                addPerson(QString::fromStdString(lineElements[1].toStdString()),newID);
            } else {
                errString = "Fehler beim Lesen der Datei 'lendlibPerson.csv' in Zeile "+ QString::number(lineNumber)+" (Zeile enthält nicht 2 Elemente).";
                readErr = true;
                return;
            }
        }
    }
    /// Lese alle Ausleih-Relationen aus
    if (lendFile.open(QIODevice::ReadOnly|QFile::Truncate)) {
        int lineNumber = 1;
        lendFile.readLine();
        while (!lendFile.atEnd()) {
            QByteArray line = lendFile.readLine().replace(QByteArray("\n"),QByteArray(""));
            lineNumber++;
            QList<QByteArray> lineElements = line.split('\t');
            /// - Prüfe, ob Format richtig ist (2 Spalten)
            if (lineElements.length() == 2){
                int mediumID = lineElements[0].toInt();
                int personID = lineElements[1].toInt();
                /// - Prüfe, ob die Medium-ID einem Medium entspricht
                if(!lendlib->isMediumEntry(mediumID)){
                    errString = "Fehler beim Lesen der Datei 'lendlibLend.csv' in Zeile "+ QString::number(lineNumber)+" (ID ist kein Medium).";
                    readErr = true;
                    return;
                }
                /// - Prüfe, ob die Personen-ID einer Person entspricht
                if(!lendlib->isPersonEntry(personID)){
                    cerr << lineElements[0].toStdString() << " "<< mediumID << "\n";
                    cerr << lineElements[1].toStdString() << " "<< personID << "\n";
                    errString = "Fehler beim Lesen der Datei 'lendlibLend.csv' in Zeile "+ QString::number(lineNumber)+" (ID ist keine Person).";
                    readErr = true;
                    return;
                }
                /// - Füge Ausleih-Relation hinzu
                lendMedium(mediumID, personID);
            } else {
                errString = "Fehler beim Lesen der Datei 'lendlibLend.csv' in Zeile "+ QString::number(lineNumber)+" (Zeile enthält nicht 2 Elemente).";
                readErr = true;
                return;
            }
        }
    }
}
Esempio n. 16
0
void mkTest() {

	printf(" Seller\n");
	srand(0);
	Seller *s;
	s = createSeller(HIGH, 1);
	assert(checkT(s->price==HIGH,"Seller is HIGH"));
	assert(checkT(s->que==NULL,"Seller starts with empty que"));
	assert(checkN(s->lastRow,1,"HIGH seller starts in row 1"));
	free(s);
	s = createSeller(MEDIUM, 1);
	assert(checkN(s->lastRow,5,"MEDIUM seller starts in row 5"));
	free(s);
	s = createSeller(LOW, 1);
	assert(checkN(s->lastRow,10,"LOW seller starts in row 10"));

	printf(" Person\n");
	Person *p = createPerson(s);
	assert(checkN(p->arrival,43,"p->arrival"));
	assert(checkT(s==p->seller,"checkT"));
	assert(checkT((p->next==p->prev) && (p->prev==p),"p is self referential"));

	// add person to seller
	//   we need 4 people to test que management
	//   for our testing set arrival to 0 and do not thread
	printf(" Add Person\n");
	int i;
	for(i=0; i<4;i++) {
		p=createPerson(s);
		p->arrival = 0;
		addPerson(p);
	}
	assert(checkN(s->que->id,1,"First customer id"));
	assert(checkN(s->que->next->id,2,"Second customer id"));
	assert(checkN(s->que->next->next->id,3,"Third customer id"));
	assert(checkN(s->que->next->next->next->id,4,"Fourth/Last customer id"));
	assert(checkN(s->que->next->next->next->next->id,4,"Fifth customer id (tail points to self"));

	assert(checkT(s->que->inQ==TRUE,"First customer id"));
	assert(checkT(s->que->next->inQ==TRUE,"Second customer id"));
	assert(checkT(s->que->next->next->inQ==TRUE,"Third customer id"));
	assert(checkT(s->que->next->next->next->inQ==TRUE,"Fourth/Last customer id"));

	printf(" Remove Person\n");
	// test removals
	p = removePerson(s->que);// remove person 1
	assert(checkN(p->id,1,"First person on que removed"));
	assert(checkN(s->que->id,2,"First person on que now number 2"));

	p = removePerson(s->que->next); // remove person 3
	assert(checkN(p->id,3,"Second(middle) person on que removed"));
	assert(checkN(s->que->id,2,"First person on que now number 2"));
	assert(checkN(s->que->next->id,4,"Second person should now be #4"));

	p = removePerson(s->que->next); // remove person 4
	assert(checkN(p->id,4,"Second(tail) person on que removed"));
	assert(checkN(s->que->id,2,"First person on que now number 2"));
	assert(checkN(s->que->id,s->que->next->id,"Only one person left on que #2"));
	assert(checkT((p->next==p->prev) && (p->prev==p),"p(2) is self referential"));

	p = removePerson(s->que);// remove person 2 (single person left)
	assert(checkN(p->id,2,"Last person on que removed"));
	assert(checkT(s->que==NULL,"Seller que now empty"));

	p = removePerson(s->que);// remove person from empty que
	assert(checkT(p==NULL,"NULL pointer expected"));

	//
	printf(" getSeat()\n");
	p=createPerson(s); // current low price seller
	p->id = 42;
	// check if row full algorithm even works
	assert(checkT(!isRowFull(&hall,8),"Is row 8 full NO"));

	printf("   LOW\n");
	getSeat(&hall,p,LOW);
	// first call to low assigns 10,10
	Person *cp = hall.seats[10][10];
	assert(checkT(cp!=NULL,"Seat 10,10 occupied"));
	assert(checkN(cp->id,42,"Customer 42 has the seat"));

	printf("   HIGH\n");
	p->seller->lastRow=1;
	getSeat(&hall,p,HIGH);
	// first call to low assigns 1,1
	cp = hall.seats[1][1];
	assert(checkT(cp!=NULL,"Seat 1,1 occupied"));
	assert(checkN(cp->id,42,"Customer 42 has the seat"));

	printf("   MEDIUM\n");
	p->seller->lastRow=5;
	getSeat(&hall,p,MEDIUM);
	// first call to low assigns 5,10
	cp = hall.seats[5][10];
	assert(checkT(cp!=NULL,"Seat 5,10 occupied"));
	assert(checkN(cp->id,42,"Customer 42 has the seat"));

	p->seller->lastRow=3;
	getSeat(&hall,p,MEDIUM);
	// first call to low assigns 3,10
	cp = hall.seats[3][10];
	assert(checkT(cp!=NULL,"Seat 3,10 occupied"));
	assert(checkN(cp->id,42,"Customer 42 has the seat"));

	p->seller->lastRow=6;
	getSeat(&hall,p,MEDIUM);
	// first call to low assigns 6,1
	cp = hall.seats[6][1];
	assert(checkT(cp!=NULL,"Seat 6,1 occupied"));
	assert(checkN(cp->id,42,"Customer 42 has the seat"));

	// need non-threaded test for sellTickets method


	// non-threaded test for frustratedPerson()

	printf(" frustratedPerson()\n");
	s = createSeller(HIGH,103);
	p=createPerson(s);
	p->arrival=0;
	addPerson(p);
	frustratedPerson(p);
	assert(checkT(s->que==NULL,"Person has left the building"));
}
Esempio n. 17
0
KAboutApplication::KAboutApplication( const KAboutData *aboutData, QWidget *parent, const char *name, bool modal)
        : AboutDlgBase(parent, name, modal)
{
    SET_WNDPROC("about")
    setButtonsPict(this);
    setCaption(caption());

    connect(btnOK, SIGNAL(clicked()), this, SLOT(close()));
    setIcon(Pict("licq"));
    const QIconSet *icon = Icon("licq");
    if (icon)
        lblIcon->setPixmap(icon->pixmap(QIconSet::Large, QIconSet::Normal));
    lblVersion->setText(i18n("%1 Version: %2") .arg(aboutData->appName()) .arg(aboutData->version()));
    txtAbout->setText((QString("<center><br>%1<br><br>%2<br><br>") +
                       "<a href=\"%3\">%4</a><br><br>" +
                       i18n("Bug report") + ": <a href=\"mailto:%5\">%6</a><br>" +
                       i18n("Note: This is english mailing list") +
                       "</center>")
                      .arg(quote(aboutData->shortDescription()))
                      .arg(quote(aboutData->copyrightStatement()))
                      .arg(quote(aboutData->homepage()))
                      .arg(quote(aboutData->homepage()))
                      .arg(quote(aboutData->bugAddress()))
                      .arg(quote(aboutData->bugAddress())));
    QString txt;
    QValueList<KAboutPerson>::ConstIterator it;
    for (it = aboutData->authors().begin();
            it != aboutData->authors().end(); ++it)
    {
        txt += addPerson(&(*it));
        txt += "<br>";
    }
    txtAuthors->setText(txt);
    txt = "";
    QValueList<KAboutTranslator> translators = aboutData->translators();
    QValueList<KAboutTranslator>::ConstIterator itt;
    if (!translators.isEmpty()){
        for (itt = translators.begin();
                itt != translators.end(); ++itt)
        {
            const KAboutTranslator &t = *itt;
            txt += QString("%1 &lt;<a href=\"mailto:%2\">%3</a>&gt;<br>")
                   .arg(quote(t.name()))
                   .arg(quote(t.emailAddress()))
                   .arg(quote(t.emailAddress()));
            txt += "<br>";
        }
        txtTranslations->setText(txt);
    }else{
        tabMain->removePage(tabTranslation);
    }
    QString license = aboutData->license();
    license += "\n\n";
    QFile f(QFile::decodeName(app_file("COPYING").c_str()));
    if (f.open(IO_ReadOnly)){
        for (;;){
            QString s;
            if (f.readLine(s, 512) == -1)
                break;
            license += s;
        }
    }
    txtLicence->setText(quote(license));
}
Esempio n. 18
0
	void Menu::initialize()
	{
		appService.getConsole().printLine("\n===Menu initialization===");
		menuBannerTexture = appService.getTextureManager().load(D6_TEXTURE_MENU_PATH, TextureFilter::LINEAR, true);
		appService.getConsole().printLine("...Starting GUI library");
		gui.screenSize(video.getScreen().getClientWidth(), video.getScreen().getClientHeight(),
			(video.getScreen().getClientWidth() - 800) / 2, (video.getScreen().getClientHeight() - 600) / 2);

		listbox[0] = new Gui::ListBox(gui, true);
		listbox[0]->setPosition(10, 199, 94, 12, 16);

		listbox[ALL_PLAYER_LIST] = new Gui::ListBox(gui, true);
		listbox[ALL_PLAYER_LIST]->setPosition(10, 470, 20, 13, 18);
		listbox[ALL_PLAYER_LIST]->onDoubleClick([this](Gui::ListBox& listBox, Int32 index, const std::string& item) {
			addPlayer(index);
		});

		listbox[CUR_PLAYERS_LIST] = new Gui::ListBox(gui, false);
		listbox[CUR_PLAYERS_LIST]->setPosition(200, 470, 20, D6_MAX_PLAYERS, 18);
		listbox[CUR_PLAYERS_LIST]->onDoubleClick([this](Gui::ListBox& listBox, Int32 index, const std::string& item) {
			removePlayer(index);
		});

		listbox[3] = new Gui::ListBox(gui, true);
		listbox[3]->setPosition(654, 410, 13, 6, 16);

		listbox[4] = new Gui::ListBox(gui, true);
		listbox[4]->setPosition(520, 363, 13, 3, 16);

		listbox[5] = new Gui::ListBox(gui, false);
		listbox[5]->setPosition(654, 470, 15, 2, 16);
		listbox[5]->addItem("Fullscreen");
		listbox[5]->addItem("Split screen");

		listbox[6] = new Gui::ListBox(gui, true);
		listbox[6]->setPosition(520, 470, 13, 5, 16);

		loadPersonProfiles(D6_FILE_PROFILES);
		loadPersonData(D6_FILE_PHIST);

		button[0] = new Gui::Button(gui);
		button[0]->setPosition(200, 282, 80, 25);
		button[0]->setCaption(">>");
		button[0]->onClick([this](Gui::Button&) {
			addPlayer(listbox[ALL_PLAYER_LIST]->selectedIndex());
		});

		button[1] = new Gui::Button(gui);
		button[1]->setPosition(200, 253, 80, 25);
		button[1]->setCaption("<<");
		button[1]->onClick([this](Gui::Button&) {
			removePlayer(listbox[CUR_PLAYERS_LIST]->selectedIndex());
		});

		button[2] = new Gui::Button(gui);
		button[2]->setPosition(284, 282, 80, 25);
		button[2]->setCaption("Remove");
		button[2]->onClick([this](Gui::Button&) {
			deletePerson();
			rebuildTable();
		});

		button[3] = new Gui::Button(gui);
		button[3]->setPosition(284, 253, 80, 25);
		button[3]->setCaption("Add");
		button[3]->onClick([this](Gui::Button&) {
			addPerson();
		});

		button[6] = new Gui::Button(gui);
		button[6]->setPosition(370, 282, 125, 25);
		button[6]->setCaption("Clear (F3)");
		button[6]->onClick([this](Gui::Button&) {
			if (deleteQuestion())
			{
				cleanPersonData();
			}
		});

		button[4] = new Gui::Button(gui);
		button[4]->setPosition(520, 299, 125, 73);
		button[4]->setCaption("Play (F1)");
		button[4]->onClick([this](Gui::Button&) {
			play();
		});

		button[5] = new Gui::Button(gui);
		button[5]->setPosition(654, 299, 125, 73);
		button[5]->setCaption("Quit (ESC)");
		button[5]->onClick([this](Gui::Button&) {
			close();
		});

		label[0] = new Gui::Label(gui);
		label[0]->setPosition(10, 219, 772, 18);
		label[0]->setCaption("    Name   | Games | Wins | Shots | Accuracy | Kills | Penalties | Points | Alive | Time");

		label[1] = new Gui::Label(gui);
		label[1]->setPosition(520, 383, 125, 18);
		label[1]->setCaption("Background");

		label[2] = new Gui::Label(gui);
		label[2]->setPosition(654, 429, 125, 18);
		label[2]->setCaption("Level");

		label[3] = new Gui::Label(gui);
		label[3]->setPosition(654, 489, 125, 18);
		label[3]->setCaption("Screen mode");

		label[4] = new Gui::Label(gui);
		label[4]->setPosition(520, 489, 125, 18);
		label[4]->setCaption("Zoom");

		label[5] = new Gui::Label(gui);
		label[5]->setPosition(10, 489, 181, 18);
		label[5]->setCaption("Persons");

		label[6] = new Gui::Label(gui);
		label[6]->setPosition(200, 489, 165, 18);
		label[6]->setCaption("Players");

		label[7] = new Gui::Label(gui);
		label[7]->setPosition(370, 489, 120, 18);
		label[7]->setCaption("Controller");

		textbox = new Gui::Textbox(gui);
		textbox->setPosition(370, 252, 14, 10, D6_ALL_CHR);

		// Switchbox - volba ovladani
		for (Size i = 0; i < D6_MAX_PLAYERS; i++)
		{
			controlSwitch[i] = new Gui::Spinner(gui);
			controlSwitch[i]->setPosition(370, 468 - i * 18, 120, 0);

			// TODO: Might be deleted in future if the use case is fully covered with detect-all functionality
			Gui::Button* button = new Gui::Button(gui);
			button->setCaption("D");
			button->setPosition(494, 466 - i * 18, 17, 17);
			button->onClick([this,i](Gui::Button&) {
				detectControls(i);
			});
		}

		// Button to detect all user's controllers in a batch
		Gui::Button* button = new Gui::Button(gui);
		button->setCaption("D");
		button->setPosition(490, 487, 24, 17);
		button->onClick([this](Gui::Button&){
			Size curPlayersCount = listbox[CUR_PLAYERS_LIST]->size();
			for (Size j = 0; j < curPlayersCount; j++)
			{
				detectControls(j);
			}
		});

		initializeGameModes();
		gameModeSwitch = new Gui::Spinner(gui);
		for(auto& gameMode : gameModes)
		{
			gameModeSwitch->addItem(gameMode->getName());
		}
		gameModeSwitch->setPosition(10, 0, 330, 20);

		joyRescan();

		backgroundCount = File::countFiles(D6_TEXTURE_BCG_PATH, D6_TEXTURE_EXTENSION);
		levelList.initialize(D6_FILE_LEVEL, D6_LEVEL_EXTENSION);

		listbox[3]->addItem("Random");
		for (Size i = 0; i < levelList.getLength(); i++)
		{
			listbox[3]->addItem(levelList.getFileName(i).substr(0, levelList.getFileName(i).rfind(".")));
		}

		listbox[4]->addItem("Random");
		for (Size i = 0; i < backgroundCount; i++)
		{
			listbox[4]->addItem(std::to_string(i + 1));
		}

		for (Int32 i = 5; i < 21; i++)
		{
			listbox[6]->addItem(std::to_string(i));
		}
		listbox[6]->selectItem(8).scrollToView(8);

		menuTrack = sound.loadModule("sound/undead.xm");
	}