Esempio n. 1
0
 def do_embed(self, book_ids, only_fmts=None):
     pd = QProgressDialog(
         _('Embedding updated metadata into book files...'), _('&Stop'), 0,
         len(book_ids), self.gui)
     pd.setWindowModality(Qt.WindowModal)
     errors = []
     self.job_data = (0, tuple(book_ids), pd, only_fmts, errors)
     self.pd_timer.start()
Esempio n. 2
0
 def __init__(self, parent, book_ids, output_format, queue, db, user_recs,
         args, use_saved_single_settings=True):
     QProgressDialog.__init__(self, '',
             QString(), 0, len(book_ids), parent)
     self.setWindowTitle(_('Queueing books for bulk conversion'))
     self.book_ids, self.output_format, self.queue, self.db, self.args, self.user_recs = \
             book_ids, output_format, queue, db, args, user_recs
     self.parent = parent
     self.use_saved_single_settings = use_saved_single_settings
     self.i, self.bad, self.jobs, self.changed = 0, [], [], False
     QTimer.singleShot(0, self.do_book)
     self.exec_()
Esempio n. 3
0
 def process_duplicates(self):
     duplicates = self.db_adder.duplicates
     if not duplicates:
         return self.duplicates_processed()
     self.pd.hide()
     files = [
         _('%(title)s by %(author)s') %
         dict(title=x[0].title, author=x[0].format_field('authors')[1])
         for x in duplicates
     ]
     if question_dialog(
             self._parent, _('Duplicates found!'),
             _('Books with the same title as the following already '
               'exist in the database. Add them anyway?'),
             '\n'.join(files)):
         pd = QProgressDialog(_('Adding duplicates...'), '', 0,
                              len(duplicates), self._parent)
         pd.setCancelButton(None)
         pd.setValue(0)
         pd.show()
         self.__p_d = pd
         self.__d_a = DuplicatesAdder(self._parent, self.db, duplicates,
                                      self.db_adder)
         self.__d_a.added.connect(pd.setValue)
         self.__d_a.adding_done.connect(self.duplicates_processed)
     else:
         return self.duplicates_processed()
Esempio n. 4
0
 def __init__(self, bookdb, options_texte, nb, newimage, newimagepath):
     QProgressDialog.__init__(self, None, None, 0, nb)
     self.setWindowTitle('Traitement des fichiers')
     self.setCancelButtonText('Annuler')
     icon = QtGui.QIcon()
     icon.addPixmap(QtGui.QPixmap("resources/PL128.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
     self.setWindowIcon(icon)
     QtCore.QMetaObject.connectSlotsByName(self)
     self.nb = nb
     self.newimage = newimage
     self.newimagepath = newimagepath
     self.badbook = []
     self.setMinimum(0)
     self.setMaximum(self.nb)
     self.setMinimumWidth(500)
     # QTimer.singleShot(0, self.distribujob)
     self.show()
     self.distribujob(options_texte, nb)
Esempio n. 5
0
    def __init__(self, gui, book_ids, tdir, statistics_cols_map,
                 pages_algorithm, use_goodreads, overwrite_existing, queue, db):
        QProgressDialog.__init__(self, '', QString(), 0, len(book_ids), gui)
        self.setWindowTitle('Queueing books for counting statistics')
        self.setMinimumWidth(500)
        self.book_ids, self.tdir, self.queue, self.db = book_ids, tdir, queue, db
        self.statistics_cols_map = statistics_cols_map
        self.pages_algorithm = pages_algorithm
        self.use_goodreads = use_goodreads
        self.overwrite_existing = overwrite_existing
        self.gui = gui
        self.i, self.books_to_scan = 0, []
        self.bad = OrderedDict()
        self.input_order = [f.lower() for f in prefs['input_format_order']]

        self.page_col_label = self.word_col_label = None
        self.labels_map = dict((col_name, db.field_metadata.key_to_label(col_name))
                               for col_name in statistics_cols_map.itervalues() if col_name)

        QTimer.singleShot(0, self.do_book)
        self.exec_()
Esempio n. 6
0
 def process_duplicates(self):
     duplicates = self.db_adder.duplicates
     if not duplicates:
         return self.duplicates_processed()
     self.pd.hide()
     from calibre.gui2.dialogs.duplicates import DuplicatesQuestion
     self.__d_q = d = DuplicatesQuestion(self.db, duplicates, self._parent)
     duplicates = tuple(d.duplicates)
     if duplicates:
         pd = QProgressDialog(_('Adding duplicates...'), '', 0,
                              len(duplicates), self._parent)
         pd.setCancelButton(None)
         pd.setValue(0)
         pd.show()
         self.__p_d = pd
         self.__d_a = DuplicatesAdder(self._parent, self.db, duplicates,
                                      self.db_adder)
         self.__d_a.added.connect(pd.setValue)
         self.__d_a.adding_done.connect(self.duplicates_processed)
     else:
         return self.duplicates_processed()
Esempio n. 7
0
    def process_duplicates(self):
        duplicates = self.db_adder.duplicates
        if not duplicates:
            return self.duplicates_processed()
        self.pd.hide()
        from calibre.gui2.dialogs.duplicates import DuplicatesQuestion

        self.__d_q = d = DuplicatesQuestion(self.db, duplicates, self._parent)
        duplicates = tuple(d.duplicates)
        if duplicates:
            pd = QProgressDialog(_("Adding duplicates..."), "", 0, len(duplicates), self._parent)
            pd.setCancelButton(None)
            pd.setValue(0)
            pd.show()
            self.__p_d = pd
            self.__d_a = DuplicatesAdder(self._parent, self.db, duplicates, self.db_adder)
            self.__d_a.added.connect(pd.setValue)
            self.__d_a.adding_done.connect(self.duplicates_processed)
        else:
            return self.duplicates_processed()
Esempio n. 8
0
File: add.py Progetto: Eksmo/calibre
 def process_duplicates(self):
     duplicates = self.db_adder.duplicates
     if not duplicates:
         return self.duplicates_processed()
     self.pd.hide()
     files = [_('%(title)s by %(author)s')%dict(title=x[0].title,
         author=x[0].format_field('authors')[1]) for x in duplicates]
     if question_dialog(self._parent, _('Duplicates found!'),
                     _('Books with the same title as the following already '
                     'exist in the database. Add them anyway?'),
                     '\n'.join(files)):
         pd = QProgressDialog(_('Adding duplicates...'), '', 0, len(duplicates),
                 self._parent)
         pd.setCancelButton(None)
         pd.setValue(0)
         pd.show()
         self.__p_d = pd
         self.__d_a = DuplicatesAdder(self._parent, self.db, duplicates,
                 self.db_adder)
         self.__d_a.added.connect(pd.setValue)
         self.__d_a.adding_done.connect(self.duplicates_processed)
     else:
         return self.duplicates_processed()
Esempio n. 9
0
 def process_duplicates(self):
     duplicates = self.db_adder.duplicates
     if not duplicates:
         return self.duplicates_processed()
     self.pd.hide()
     duplicate_message = []
     for x in duplicates:
         duplicate_message.append(_("Already in calibre:"))
         matching_books = self.db.books_with_same_title(x[0])
         for book_id in matching_books:
             aut = [a.replace("|", ",") for a in (self.db.authors(book_id, index_is_id=True) or "").split(",")]
             duplicate_message.append(
                 "\t"
                 + _("%(title)s by %(author)s")
                 % dict(title=self.db.title(book_id, index_is_id=True), author=authors_to_string(aut))
             )
         duplicate_message.append(_("You are trying to add:"))
         duplicate_message.append(
             "\t" + _("%(title)s by %(author)s") % dict(title=x[0].title, author=x[0].format_field("authors")[1])
         )
         duplicate_message.append("")
     if question_dialog(
         self._parent,
         _("Duplicates found!"),
         _("Books with the same title as the following already " "exist in calibre. Add them anyway?"),
         "\n".join(duplicate_message),
     ):
         pd = QProgressDialog(_("Adding duplicates..."), "", 0, len(duplicates), self._parent)
         pd.setCancelButton(None)
         pd.setValue(0)
         pd.show()
         self.__p_d = pd
         self.__d_a = DuplicatesAdder(self._parent, self.db, duplicates, self.db_adder)
         self.__d_a.added.connect(pd.setValue)
         self.__d_a.adding_done.connect(self.duplicates_processed)
     else:
         return self.duplicates_processed()
Esempio n. 10
0
 def process_duplicates(self):
     duplicates = self.db_adder.duplicates
     if not duplicates:
         return self.duplicates_processed()
     self.pd.hide()
     duplicate_message = []
     for x in duplicates:
         duplicate_message.append(_('Already in calibre:'))
         matching_books = self.db.books_with_same_title(x[0])
         for book_id in matching_books:
             aut = [a.replace('|', ',') for a in (self.db.authors(book_id,
                 index_is_id=True) or '').split(',')]
             duplicate_message.append('\t'+ _('%(title)s by %(author)s')%
                     dict(title=self.db.title(book_id, index_is_id=True),
                     author=authors_to_string(aut)))
         duplicate_message.append(_('You are trying to add:'))
         duplicate_message.append('\t'+_('%(title)s by %(author)s')%
                 dict(title=x[0].title,
                 author=x[0].format_field('authors')[1]))
         duplicate_message.append('')
     if question_dialog(self._parent, _('Duplicates found!'),
                     _('Books with the same title as the following already '
                     'exist in calibre. Add them anyway?'),
                     '\n'.join(duplicate_message)):
         pd = QProgressDialog(_('Adding duplicates...'), '', 0, len(duplicates),
                 self._parent)
         pd.setCancelButton(None)
         pd.setValue(0)
         pd.show()
         self.__p_d = pd
         self.__d_a = DuplicatesAdder(self._parent, self.db, duplicates,
                 self.db_adder)
         self.__d_a.added.connect(pd.setValue)
         self.__d_a.adding_done.connect(self.duplicates_processed)
     else:
         return self.duplicates_processed()
Esempio n. 11
0
    def download_button_clicked(self):
        tags = str(self.custom_tags.text())

        # url_id = self.recipes.model.data(1, QtCore.Qt.UserRole)    # TODO: 获得选中的recipes
        url_id = str(self.row_clicked(self.recipes.currentIndex()))

        if url_id == 'None':
            QtGui.QMessageBox.information(self, u"Error", u"选择需要爬取的网站!")
            return

        readlist_content = self.plainTextEdit.toPlainText()

        if readlist_content == '':
            QtGui.QMessageBox.information(self, u"Error", u"请在文本框中输入网址")
            return

        read_list_path = Path.read_list_path

        readList_file = open(read_list_path, 'w')
        readList_file.write(readlist_content)

        readList_file.close()

        game = EEBook(recipe_kind=url_id)

        progress_dlg = QProgressDialog(self)        # TODO: 设置大小, 区域
        progress_dlg.setWindowModality(Qt.WindowModal)
        progress_dlg.setMinimumDuration(5)
        progress_dlg.setWindowTitle(u"请等待")
        progress_dlg.setLabelText(u"制作中...请稍候")
        progress_dlg.setCancelButtonText(u"取消")
        progress_dlg.resize(350, 250)
        progress_dlg.show()
        progress_dlg.setRange(0, 20)

        for i in range(0, 15):
            progress_dlg.setValue(i)
            QThread.msleep(100)

        for i in range(15, 20):
            progress_dlg.setValue(i)
            QThread.msleep(100)
            if progress_dlg.wasCanceled():
                QtGui.QMessageBox.information(self, u"Error", u"电子书制作失败, 请重新操作")
                return

            try:
                filename = game.begin()      # TODO: 一次只能生成一本书
            except TypeError:
                QtGui.QMessageBox.information(self, u"Error", u"第一次使用请登录")
                progress_dlg.close()
                return
            progress_dlg.close()

            info_filename = ','.join(filename)
            QtGui.QMessageBox.information(self, u"info", u"电子书"+str(info_filename)+u"制作成功")

            for item in filename:
                file_path = EPUBSTOR_DIR + '/' + item
                Path.copy(str(file_path+'.epub'), LIBRARY_DIR)
                file_name = os.path.basename(str(file_path))
                book_id = file_name.split('.epub')[0]

                Path.mkdir(LIBRARY_DIR + book_id)
                shutil.move(LIBRARY_DIR+book_id+'.epub', LIBRARY_DIR+book_id)

                book = Book(str(book_id))
                book.date = time.strftime(ISOTIMEFORMAT, time.localtime())
                book.tags += tags.replace(' ', '')
                book.tags += ','+str(self.now_url)
                if self.add_title_tag.isChecked():
                    book.tags += ','+str(book.title)
                insert_library(book)
            return
Esempio n. 12
0
 def showProgress(self, modal = True):
     """
     Open the progress dialog to show the current job progress.
     """
     #Replace "self.edit_cntl.win" with "None"
     #---Huaicai 7/7/05: To fix bug 751, the "win" may be none.
     #Feel awkward for the design of our code.        
     simProgressDialog = QProgressDialog()
     simProgressDialog.setModal(True)
     simProgressDialog.setObjectName("progressDialog")
     simProgressDialog.setWindowIcon(geticon('ui/border/MainWindow'))
     if self.Calculation == 'Energy':
         simProgressDialog.setWindowTitle("Calculating Energy ...Please Wait")
     else:
         simProgressDialog.setWindowTitle("Optimizing ...Please Wait")
    
     progBar = QProgressBar(simProgressDialog)
     progBar.setMaximum(0)
     progBar.setMinimum(0)
     progBar.setValue(0)
     progBar.setTextVisible(False)
     simProgressDialog.setBar(progBar)
     simProgressDialog.setAutoReset(False)
     simProgressDialog.setAutoClose(False)
     
     return simProgressDialog
Esempio n. 13
0
    def showProgress(self, modal=True):
        """
        Open the progress dialog to show the current job progress.
        """
        #Replace "self.edit_cntl.win" with "None"
        #---Huaicai 7/7/05: To fix bug 751, the "win" may be none.
        #Feel awkward for the design of our code.
        simProgressDialog = QProgressDialog()
        simProgressDialog.setModal(True)
        simProgressDialog.setObjectName("progressDialog")
        simProgressDialog.setWindowIcon(geticon('ui/border/MainWindow'))
        if self.Calculation == 'Energy':
            simProgressDialog.setWindowTitle(
                "Calculating Energy ...Please Wait")
        else:
            simProgressDialog.setWindowTitle("Optimizing ...Please Wait")

        progBar = QProgressBar(simProgressDialog)
        progBar.setMaximum(0)
        progBar.setMinimum(0)
        progBar.setValue(0)
        progBar.setTextVisible(False)
        simProgressDialog.setBar(progBar)
        simProgressDialog.setAutoReset(False)
        simProgressDialog.setAutoClose(False)

        return simProgressDialog
Esempio n. 14
0
 def do_embed(self, book_ids, only_fmts=None):
     pd = QProgressDialog(_('Embedding updated metadata into book files...'), _('&Stop'), 0, len(book_ids), self.gui)
     pd.setWindowModality(Qt.WindowModal)
     errors = []
     self.job_data = (0, tuple(book_ids), pd, only_fmts, errors)
     self.pd_timer.start()
Esempio n. 15
0
    def download_button_clicked(self):
        tags = str(self.custom_tags.text())

        # url_id = self.recipes.model.data(1, QtCore.Qt.UserRole)    # TODO: 获得选中的recipes
        url_id = str(self.row_clicked(self.recipes.currentIndex()))

        if url_id == 'None':
            QtGui.QMessageBox.information(self, u"Error", u"选择需要爬取的网站!")
            return

        readlist_content = self.plainTextEdit.toPlainText()

        if readlist_content == '':
            QtGui.QMessageBox.information(self, u"Error", u"请在文本框中输入网址")
            return

        read_list_path = Path.read_list_path

        readList_file = open(read_list_path, 'w')
        readList_file.write(readlist_content)

        readList_file.close()

        game = EEBook(recipe_kind=url_id)

        progress_dlg = QProgressDialog(self)  # TODO: 设置大小, 区域
        progress_dlg.setWindowModality(Qt.WindowModal)
        progress_dlg.setMinimumDuration(5)
        progress_dlg.setWindowTitle(u"请等待")
        progress_dlg.setLabelText(u"制作中...请稍候")
        progress_dlg.setCancelButtonText(u"取消")
        progress_dlg.resize(350, 250)
        progress_dlg.show()
        progress_dlg.setRange(0, 20)

        for i in range(0, 15):
            progress_dlg.setValue(i)
            QThread.msleep(100)

        for i in range(15, 20):
            progress_dlg.setValue(i)
            QThread.msleep(100)
            if progress_dlg.wasCanceled():
                QtGui.QMessageBox.information(self, u"Error",
                                              u"电子书制作失败, 请重新操作")
                return

            try:
                filename = game.begin()  # TODO: 一次只能生成一本书
            except TypeError:
                QtGui.QMessageBox.information(self, u"Error", u"第一次使用请登录")
                progress_dlg.close()
                return
            progress_dlg.close()

            info_filename = ','.join(filename)
            QtGui.QMessageBox.information(
                self, u"info", u"电子书" + str(info_filename) + u"制作成功")

            for item in filename:
                file_path = EPUBSTOR_DIR + '/' + item
                Path.copy(str(file_path + '.epub'), LIBRARY_DIR)
                file_name = os.path.basename(str(file_path))
                book_id = file_name.split('.epub')[0]

                Path.mkdir(LIBRARY_DIR + book_id)
                shutil.move(LIBRARY_DIR + book_id + '.epub',
                            LIBRARY_DIR + book_id)

                book = Book(str(book_id))
                book.date = time.strftime(ISOTIMEFORMAT, time.localtime())
                book.tags += tags.replace(' ', '')
                book.tags += ',' + str(self.now_url)
                if self.add_title_tag.isChecked():
                    book.tags += ',' + str(book.title)
                insert_library(book)
            return