void MainWindow::createUi() { this->setWindowIcon(QIcon(":/main/app.png")); this->ui->actionQuit->setIcon(QIcon(":/toolbar/application_exit.png")); this->ActionNew = new QAction(QIcon(":/toolbar/filenew.png"), tr("New"), this); this->ActionSave = new QAction(QIcon(":/toolbar/document_save.png"), tr("New"), this); this->ActionPrint = new QAction(QIcon(":/toolbar/printer.png"), tr("Print"), this); this->ActionSearch = new QAction(QIcon(":/toolbar/edit_find.png"), tr("Search"), this); this->ActionShowAll = new QAction(QIcon(":/toolbar/edit_clear_list.png"), tr("Search"), this); this->ActionBarcodeScanner = new QAction(QIcon(":/toolbar/barcode.png"), tr("Scan from Barcode"), this); this->ActionBarcodeScanner->setCheckable(true); this->ToolBar = new QToolBar(this); this->ToolBar->addAction(this->ActionNew); this->ToolBar->addAction(this->ActionSave); this->ToolBar->addAction(this->ActionPrint); this->ToolBar->addSeparator(); this->ToolBar->addAction(this->ActionSearch); this->ToolBar->addAction(this->ActionShowAll); this->ToolBar->addAction(this->ActionBarcodeScanner); this->ToolBar->setWindowTitle(tr("Main ToolBar")); this->addToolBar(ToolBar); this->OverView = new overview(this); newBook(); this->setDockNestingEnabled(true); this->addDockWidget(Qt::LeftDockWidgetArea,(QDockWidget*)this->OverView); this->ui->scrollArea->setWidgetResizable(true); connect(this->ui->actionAbout_2,SIGNAL(triggered()), this,SLOT(showVersion())); connect(this->ui->actionAbout_Qt_2,SIGNAL(triggered()), this,SLOT(showQt())); connect(this->ActionNew,SIGNAL(triggered()), this,SLOT(newBook())); connect(this->ActionBarcodeScanner,SIGNAL(triggered(bool)), this,SLOT(toggleScanner(bool))); }
int main() { FILE *fp; int choice; int i=0; if ((fp = fopen("books.dat","rb+"))==NULL) //create binary file with blank records if file pointer returns NULL { printf("File does not exist\nCreating Binary File with blank records..."); struct book blankBook = { "","",0,0,0.0,0.0}; fp = fopen("books.dat","wb+"); for ( i = 1; i <= 100; i++ ) //write 100 blank book structures { fwrite( &blankBook, sizeof( struct book ), 1, fp ); } fclose ( fp ); main(); } else //menu { while ( ( choice = enterChoice() ) != 5 ) { switch ( choice ) { case 1: writeToTextFile( fp ); break; case 2: updatePrice( fp ); break; case 3: newBook( fp ); break; case 4: deleteBook( fp ); break; default: printf( "Incorrect choice\n" ); break; } } fclose( fp ); } return 0; }
void doSomeStuff(){ printf("Creating account for Dan Brown\n"); struct Writer danBrown = newWriter( "Dan Brown", "danbrown", "password" ); addWriter(&danBrown, &eBookStore); printf("Created account for Dan Brown with ID %d\n\n", danBrown.id); printf("Adding the book Angels and Demons\n"); struct Book angelsAndDemons = newBook( "Angels and Demons", "Dan Brown", "Science and Mythology and Stuff", "In not so distant past...", danBrown.id, 100 ); publishBook(&angelsAndDemons, &eBookStore); printf("Added the book Angels and Demons with ID %d\n\n", angelsAndDemons.id); printf("Adding the book Da Vinci Code\n"); struct Book daVinciCode = newBook( "Da Vinci Code", "Dan Brown", "Its about the hipster Leo", "Once upon a time...", danBrown.id, 100 ); publishBook(&daVinciCode, &eBookStore); printf("Added the book Da Vinci Code with ID %d\n\n", daVinciCode.id); printf("Books published by %s on our platform are,\n", danBrown.name); for(int i=0;i<danBrown.bookCount;i++){ int bookID = danBrown.bookIDs[i]; struct Book *b = eBookStore.bookDataStore.books[bookID]; printf("#%d:\t%s\n", i+1, b->title); } printf("\n"); printf("Finding books similar to %s\n", daVinciCode.title); assignSimilarBooks(&daVinciCode, &eBookStore); for(int i=0;i<daVinciCode.similarBookCount;i++){ int bookID = daVinciCode.similarBooks[i]; struct Book *b = eBookStore.bookDataStore.books[bookID]; printf("#%d:\t%s\n", i+1, b->title); } printf("\n"); printf("Creating customer account for Robert Langdon\n"); struct Customer robertLangdon = newCustomer("robertlangdon", "password"); addCustomerToDataStore(&robertLangdon, &eBookStore.customerDataStore); printf("Created customer account for Robert Langdon with user id %d\n\n", robertLangdon.id); printf("Searching for books with the title 'Angels and Demons'\n"); struct Book* searchResult = searchBooksInDataStore(1, "Angels and Demons", 1, &eBookStore.bookDataStore)[0]; printf("Found one book with the name %s by the author %s\n", searchResult->title, searchResult->author); printf("Its summary is, %s\n\n", searchResult->summary); printf("Submitting an excellent review for %s from user name %s\n", searchResult->title, robertLangdon.username); addReview(searchResult, &robertLangdon, 5, "Awesome read! :)", &eBookStore); printf("Fetching all reviews for %s,\n", searchResult->title); for(int i=0;i<searchResult->reviewCount;i++){ printf("#%d: Rating: %d Comments: %s\n", i+1, searchResult->reviews[i]->rating, searchResult->reviews[i]->body); } printf("Average rating of %s is %f\n\n", searchResult->title, getAverageRating(searchResult)); printf("That's all for this demo folks! :)\n"); }
void addBook(library_t * self,const char * name){ book_t * nB = newBook(name); List_add(self->book,List_getSize(self->book),nB); }