diff --git a/egon.py b/egon.py index 9fe1bdd..e61725c 100755 --- a/egon.py +++ b/egon.py @@ -1088,12 +1088,13 @@ class CourseDlg(QDialog): self.bookList = QListWidget() self.booksEdit = QPushButton(self.trUtf8("Add new book")) self.bookMenu = QMenu() - books = getBooksFromDB() + booksDB = getBooksFromDB() actions = [] - for book in books: + for book in booksDB: actions.append(QAction(QString(book.getTitle()), self.bookMenu)) for action in actions: self.bookMenu.addAction(action) + self.connect(action, SIGNAL("triggered()"), self.addNewBookToCourse) self.booksEdit.setMenu(self.bookMenu) self.codeLabel.setBuddy(self.codeEdit) @@ -1113,8 +1114,9 @@ class CourseDlg(QDialog): self.layout.addWidget(self.booksEdit, 4, 1) self.setLayout(self.layout) - def addNewBookToCourse(self, book): - pass + def addNewBookToCourse(self): + book = getBookWithTitleFromDB(booktitle) + self.books.append(book) class AddCourseDlg(CourseDlg): @@ -1141,7 +1143,7 @@ class AddCourseDlg(CourseDlg): while color in colors: color = getRandomColor() colors.append(color) - course = CourseModel(courseCode, courseTitle, courseShort, color, courseBooks) + course = CourseModel(courseCode, courseTitle, courseShort, color, courseBooks) self.close() for book in courseBooks: self.addNewBookCourse(book) @@ -1165,7 +1167,7 @@ class CourseModel(): self.title = title self.short = short self.setFull(code, title) - self.color = color + self.color = color self.books = books def getCode(self):