diff --git a/calibre-plugin/dialogs.py b/calibre-plugin/dialogs.py index cb3003a6..89b69adb 100644 --- a/calibre-plugin/dialogs.py +++ b/calibre-plugin/dialogs.py @@ -53,13 +53,14 @@ class RejectUrlEntry: matchpat=re.compile(r"^(?P[^,]+)(,(?P(((?P.+) by (?P<auth>.+?)( - (?P<note>.+))?)|.*)))?$") def __init__(self,url_or_line,note=None,title=None,auth=None, - addreasontext=None,fromline=False): - + addreasontext=None,fromline=False,book_id=None): + self.url=url_or_line self.note=note self.title=title self.auth=auth self.valid=False + self.book_id=book_id if fromline: mc = re.match(self.matchpat,url_or_line) @@ -828,7 +829,9 @@ class RejectListTableWidget(QTableWidget): def populate_table_row(self, row, rej): - self.setItem(row, 0, ReadOnlyTableWidgetItem(rej.url)) + url_cell = ReadOnlyTableWidgetItem(rej.url) + url_cell.setData(Qt.UserRole, QVariant(rej.book_id)) + self.setItem(row, 0, url_cell) self.setItem(row, 1, ReadOnlyTableWidgetItem(rej.title)) self.setItem(row, 2, ReadOnlyTableWidgetItem(rej.auth)) @@ -950,10 +953,19 @@ class RejectListDialog(SizePersistedDialog): rejectrows = [] for row in range(self.rejects_table.rowCount()): url = unicode(self.rejects_table.item(row, 0).text()).strip() + book_id = self.rejects_table.item(row, 0).data(Qt.UserRole).toPyObject() title = unicode(self.rejects_table.item(row, 1).text()).strip() auth = unicode(self.rejects_table.item(row, 2).text()).strip() note = unicode(self.rejects_table.cellWidget(row, 3).currentText()).strip() - rejectrows.append(RejectUrlEntry(url,note,title,auth,self.get_reason_text())) + rejectrows.append(RejectUrlEntry(url,note,title,auth,self.get_reason_text(),book_id=book_id)) + return rejectrows + + def get_reject_list_ids(self): + rejectrows = [] + for row in range(self.rejects_table.rowCount()): + book_id = self.rejects_table.item(row, 0).data(Qt.UserRole).toPyObject() + if book_id: + rejectrows.append(book_id) return rejectrows def get_reason_text(self): diff --git a/calibre-plugin/ffdl_plugin.py b/calibre-plugin/ffdl_plugin.py index 358b9189..d06d6c0f 100644 --- a/calibre-plugin/ffdl_plugin.py +++ b/calibre-plugin/ffdl_plugin.py @@ -408,12 +408,12 @@ class FanFictionDownLoaderPlugin(InterfaceAction): def reject_list_urls_finish(self, book_list): - # construct reject list of tuples: - # (calibre_id, url, "title, authors", old reject note). + # construct reject list of objects reject_list = [ RejectUrlEntry(x['url'], x['oldrejnote'], x['title'], - ', '.join(x['author'])) + ', '.join(x['author']), + book_id=x['calibre_id']) for x in book_list if x['good'] ] if reject_list: d = RejectListDialog(self.gui,reject_list, @@ -426,7 +426,7 @@ class FanFictionDownLoaderPlugin(InterfaceAction): rejecturllist.add(d.get_reject_list()) if d.get_deletebooks(): - self.gui.iactions['Remove Books'].delete_books() + self.gui.iactions['Remove Books'].do_library_delete(d.get_reject_list_ids()) else: message="<p>Rejecting FFDL URLs: None of the books selected have FanFiction URLs.</p><p>Proceed to Remove?</p>"