/* * printFile function * Prints the data from a .dat file to the console. * @param *file a pointer to a file */ void printFile(FILE *file) { int data = 0; //integer to hold the value read from the file int location = 0; //integer for the spot in the file //resets the file back to the beginning rewind(file); //reads the data from the beginning of the file fread(&data, sizeof(int), 1, file); //prints out the title for the forthcoming data puts("Value \t Count \t\tHistogram"); //loop to run until the file ends while(!feof(file)) { //prints out the current integer and the number of times it was randomly selected printf("%2d %9d\t\t", location++, data); //calls the addAsterisk function addAsterisk(data); //puts a newline putchar('\n'); //reads the next integer in the file fread(&data, sizeof(int), 1, file); } return; }
MobileWindow::MobileWindow(MusicPlayer* player) { ui.setupUi(this); this->player = player; //initFolderList(); // SIGNALS // CALL NUMBERS connect(ui.call1Button, SIGNAL(clicked()), this, SLOT(add1())); connect(ui.call2Button, SIGNAL(clicked()), this, SLOT(add2())); connect(ui.call3Button, SIGNAL(clicked()), this, SLOT(add3())); connect(ui.call4Button, SIGNAL(clicked()), this, SLOT(add4())); connect(ui.call5Button, SIGNAL(clicked()), this, SLOT(add5())); connect(ui.call6Button, SIGNAL(clicked()), this, SLOT(add6())); connect(ui.call7Button, SIGNAL(clicked()), this, SLOT(add7())); connect(ui.call8Button, SIGNAL(clicked()), this, SLOT(add8())); connect(ui.call9Button, SIGNAL(clicked()), this, SLOT(add9())); connect(ui.call0Button, SIGNAL(clicked()), this, SLOT(add0())); connect(ui.callAsteriskButton, SIGNAL(clicked()), this, SLOT(addAsterisk())); connect(ui.callHashButton, SIGNAL(clicked()), this, SLOT(addHash())); // CALL, HANG UP AND DELETE BUTTONS connect(ui.removeButton, SIGNAL(clicked()), this, SLOT(removeDigit())); connect(ui.callButton, SIGNAL(clicked()), this, SLOT(call())); connect(ui.hangUpButton, SIGNAL(clicked()), this, SLOT(hangUp())); // CONTACTS connect(ui.contactList, SIGNAL(itemSelectionChanged()), this, SLOT(contactSelected())); // FILL CONTACTS ddbb.readFromFile("ddbb\\contacts.xml"); QList<Contact*> contacts = ddbb.getContacts(); foreach (Contact* c,contacts) { ui.contactList->addItem(c->name); }