void BasePage::addBook(){ WContainerWidget *container = new WContainerWidget(); Wt::WTemplate *t = new Wt::WTemplate(Wt::WString::tr("addBookForm")); WLineEdit *editTitle = new WLineEdit(container); editTitle->setPlaceholderText("title"); t->bindWidget("title", editTitle); WLineEdit *editAuthor = new WLineEdit(container); editAuthor->setPlaceholderText("author"); t->bindWidget("author", editAuthor); WLineEdit *editAuthorYears = new WLineEdit(container); editAuthorYears->setPlaceholderText("years of life"); t->bindWidget("years", editAuthorYears); WLineEdit *editGenre = new WLineEdit(container); editGenre->setPlaceholderText("genre"); t->bindWidget("genre", editGenre); WLineEdit *editYear = new WLineEdit(container); editYear->setPlaceholderText("year"); t->bindWidget("year", editYear); WLineEdit *editSeria = new WLineEdit(container); editSeria->setPlaceholderText("seria"); t->bindWidget("seria", editSeria); WLineEdit *editNumOfBooks = new WLineEdit(container); editNumOfBooks->setPlaceholderText("num of books"); t->bindWidget("numOfBooks", editNumOfBooks); WLineEdit *editNumInSeria = new WLineEdit(container); editNumInSeria->setPlaceholderText("number in seria"); t->bindWidget("numInSeria", editNumInSeria); WLineEdit *editMark = new WLineEdit(container); editMark->setPlaceholderText("mark"); editMark->setValidator(new Wt::WIntValidator(1, 10)); t->bindWidget("mark", editMark); WPushButton *button = new WPushButton("Add book", container); button->setMargin(10, Top | Bottom); button->clicked().connect(std::bind([=] () {BookManager bm; bm.addBook(editTitle->valueText().toUTF8(), editAuthor->valueText().toUTF8(), editAuthorYears->valueText().toUTF8(), editGenre->valueText().toUTF8(), intoInt(editYear), editSeria->valueText().toUTF8(), intoInt(editNumOfBooks), intoInt(editNumInSeria), intoInt(editMark)); })); t->bindWidget("button", button); _pagecontent->addWidget(t); }
/*void BasePage::addAuthor(){ WContainerWidget *container1 = new WContainerWidget(); Wt::WTemplate *r = new Wt::WTemplate(Wt::WString::tr("addAuthorForm")); WLineEdit *editName = new WLineEdit(container1); editName->setPlaceholderText("name"); r->bindWidget("name", editName); WLineEdit *editYears = new WLineEdit(container1); editYears->setPlaceholderText("years"); r->bindWidget("years", editYears); WPushButton *button = new WPushButton("Add author", container1); button->setMargin(10, Top | Bottom); button->clicked().connect(std::bind([=] () {BookManager am; am.addAuthor("123","2016"); })); r->bindWidget("button", button); _pagecontent->addWidget(r); }*/ void BasePage::addMark(const Dbo::collection<Dbo::ptr<Book> >& listaddmark){ WTable *table = new WTable(); table->setHeaderCount(1); table->setStyleClass("tablestyle"); table->elementAt(0, 0)->addWidget(new WText("<p align='left'> # </p>")); table->elementAt(0, 1)->addWidget(new WText("<p align='left'> Title of book </p>")); table->elementAt(0, 2)->addWidget(new WText("<p align='left'> Author </p>")); table->elementAt(0, 3)->addWidget(new WText("<p align='left'> Genre </p>")); table->elementAt(0, 4)->addWidget(new WText("<p align='left'> Add your mark </p>")); _pagecontent->addWidget(table); int row=1; for (Dbo::collection<Dbo::ptr<Book> >::const_iterator i = listaddmark.begin(); i != listaddmark.end(); ++i){ Dbo::ptr<Book> book = *i; table->setStyleClass("tablestyle th,td,tr"); //headers table->elementAt(row, 0) ->addWidget(new WText(WString::fromUTF8("{1}") .arg(row))); //titles table->elementAt(row, 1) ->addWidget(new WText(WString::fromUTF8("{1}") .arg(book.get()->title))); //authors table->elementAt(row, 2) ->addWidget(new WText(WString::fromUTF8("{1}") .arg((book.get()->author.get()->name)))); //genres table->elementAt(row, 3) ->addWidget(new WText(WString::fromUTF8("{1}") .arg((book.get()->genre.get()->genre)))); //add mark WLineEdit *editAddMark = new WLineEdit(table->elementAt(row,4)); editAddMark->setPlaceholderText("Add mark"); table->elementAt(row, 4) ->addWidget(editAddMark); table->elementAt(row, 4) ->addWidget(new WText("<br></br>")); WPushButton *button = new WPushButton("Add mark", table->elementAt(row,4)); button->setMargin(10, Top | Bottom); table->elementAt(row, 4) ->addWidget(button); /*button->clicked().connect(std::bind([] ( Dbo::ptr<Book> book) { BookManager bm; std::cout<<book.get()->title; int curMark=book.get()->mark; int curNumMarks=book.get()->numMarks; bm.refreshRate(book.get()->id, curMark+5, curNumMarks+1, session); },*i ));*/ row++; _pagecontent->addWidget(table); } }