示例#1
0
文件: convert.py 项目: yws/calibre
    def do_convert(self, book_ids, bulk=None):
        previous = self.gui.library_view.currentIndex()
        rows = [
            x.row()
            for x in self.gui.library_view.selectionModel().selectedRows()
        ]
        num = 0
        if bulk or (bulk is None and len(book_ids) > 1):
            self.__bulk_queue = convert_bulk_ebook(
                self.gui,
                self.queue_convert_jobs,
                self.gui.library_view.model().db,
                book_ids,
                out_format=prefs['output_format'],
                args=(rows, previous, self.book_converted))
            if self.__bulk_queue is None:
                return
            num = len(self.__bulk_queue.book_ids)
        else:
            jobs, changed, bad = convert_single_ebook(
                self.gui,
                self.gui.library_view.model().db,
                book_ids,
                out_format=prefs['output_format'])
            self.queue_convert_jobs(jobs, changed, bad, rows, previous,
                                    self.book_converted)
            num = len(jobs)

        if num > 0:
            self.gui.jobs_pointer.start()
            self.gui.status_bar.show_message(
                ngettext('Starting conversion of the book',
                         'Starting conversion of {} books', num).format(num),
                2000)
示例#2
0
    def convert_ebook(self, checked, bulk=None):
        book_ids = self.get_books_for_conversion()
        if book_ids is None:
            return
        previous = self.gui.library_view.currentIndex()
        rows = [x.row() for x in self.gui.library_view.selectionModel().selectedRows()]
        num = 0
        if bulk or (bulk is None and len(book_ids) > 1):
            self.__bulk_queue = convert_bulk_ebook(
                self.gui,
                self.queue_convert_jobs,
                self.gui.library_view.model().db,
                book_ids,
                out_format=prefs["output_format"],
                args=(rows, previous, self.book_converted),
            )
            if self.__bulk_queue is None:
                return
            num = len(self.__bulk_queue.book_ids)
        else:
            jobs, changed, bad = convert_single_ebook(
                self.gui, self.gui.library_view.model().db, book_ids, out_format=prefs["output_format"]
            )
            self.queue_convert_jobs(jobs, changed, bad, rows, previous, self.book_converted)
            num = len(jobs)

        if num > 0:
            self.gui.jobs_pointer.start()
            self.gui.status_bar.show_message(_("Starting conversion of %d book(s)") % num, 2000)
示例#3
0
    def do_convert(self, book_ids, bulk=None):
        previous = self.gui.library_view.currentIndex()
        rows = [x.row() for x in
                self.gui.library_view.selectionModel().selectedRows()]
        num = 0
        if bulk or (bulk is None and len(book_ids) > 1):
            self.__bulk_queue = convert_bulk_ebook(self.gui, self.queue_convert_jobs,
                self.gui.library_view.model().db, book_ids,
                out_format=prefs['output_format'], args=(rows, previous,
                    self.book_converted))
            if self.__bulk_queue is None:
                return
            num = len(self.__bulk_queue.book_ids)
        else:
            jobs, changed, bad = convert_single_ebook(self.gui,
                self.gui.library_view.model().db, book_ids, out_format=prefs['output_format'])
            self.queue_convert_jobs(jobs, changed, bad, rows, previous,
                    self.book_converted)
            num = len(jobs)

        if num > 0:
            self.gui.jobs_pointer.start()
            self.gui.status_bar.show_message(ngettext(
                'Starting conversion of the book', 'Starting conversion of {} books', num).format(num), 2000)