示例#1
0
 def getter(self):
     val = self.main_widget.dateTime()
     if val <= UNDEFINED_QDATETIME:
         val = None
     else:
         val = qt_to_dt(val)
     return val
示例#2
0
 def displayText(self, val, locale):
     d = val.toDateTime()
     if d <= UNDEFINED_QDATETIME:
         return ''
     self.format = tweaks['gui_pubdate_display_format']
     if self.format is None:
         self.format = 'MMM yyyy'
     return format_date(qt_to_dt(d, as_utc=False), self.format)
示例#3
0
 def fget(self):
     return qt_to_dt(self.dateTime(), as_utc=False)
示例#4
0
 def displayText(self, val, locale):
     d = val.toDateTime()
     if d <= UNDEFINED_QDATETIME:
         return ''
     return format_date(qt_to_dt(d, as_utc=False), self.format)
示例#5
0
 def displayText(self, val, locale):
     d = qt_to_dt(val)
     if is_date_undefined(d):
         return ''
     return format_date(d, self.format)
示例#6
0
    def accept(self):
        self.save_state()
        if len(self.ids) < 1:
            return QDialog.accept(self)
        try:
            source = self.s_r_sf_itemdata(None)
        except:
            source = ''
        do_sr = source and self.s_r_obj

        if self.s_r_error is not None and do_sr:
            error_dialog(self, _('Search/replace invalid'),
                    _('Search pattern is invalid: %s')%self.s_r_error.message,
                    show=True)
            return False
        self.changed = bool(self.ids)
        # Cache values from GUI so that Qt widgets are not used in
        # non GUI thread
        for w in getattr(self, 'custom_column_widgets', []):
            w.gui_val

        remove_all = self.remove_all_tags.isChecked()
        remove = []
        if not remove_all:
            remove = unicode(self.remove_tags.text()).strip().split(',')
        add = unicode(self.tags.text()).strip().split(',')
        au = unicode(self.authors.text())
        aus = unicode(self.author_sort.text())
        do_aus = self.author_sort.isEnabled()
        rating = self.rating.value()
        pub = unicode(self.publisher.text())
        do_series = self.write_series
        clear_series = self.clear_series.isChecked()
        clear_pub = self.clear_pub.isChecked()
        series = unicode(self.series.currentText()).strip()
        do_autonumber = self.autonumber_series.isChecked()
        do_series_restart = self.series_numbering_restarts.isChecked()
        series_start_value = self.series_start_number.value()
        do_remove_format = self.remove_format.currentIndex() > -1
        remove_format = unicode(self.remove_format.currentText())
        do_swap_ta = self.swap_title_and_author.isChecked()
        do_remove_conv = self.remove_conversion_settings.isChecked()
        do_auto_author = self.auto_author_sort.isChecked()
        do_title_case = self.change_title_to_title_case.isChecked()
        do_title_sort = self.update_title_sort.isChecked()
        clear_languages = self.clear_languages.isChecked()
        restore_original = self.restore_original.isChecked()
        languages = self.languages.lang_codes
        pubdate = adddate = None
        if self.apply_pubdate.isChecked():
            pubdate = qt_to_dt(self.pubdate.dateTime())
        if self.apply_adddate.isChecked():
            adddate = qt_to_dt(self.adddate.dateTime())

        cover_action = None
        if self.cover_remove.isChecked():
            cover_action = 'remove'
        elif self.cover_generate.isChecked():
            cover_action = 'generate'
        elif self.cover_from_fmt.isChecked():
            cover_action = 'fromfmt'
        elif self.cover_trim.isChecked():
            cover_action = 'trim'
        elif self.cover_clone.isChecked():
            cover_action = 'clone'

        args = Settings(remove_all, remove, add, au, aus, do_aus, rating, pub, do_series,
                do_autonumber, do_remove_format, remove_format, do_swap_ta,
                do_remove_conv, do_auto_author, series, do_series_restart,
                series_start_value, do_title_case, cover_action, clear_series, clear_pub,
                pubdate, adddate, do_title_sort, languages, clear_languages,
                restore_original, self.comments)

        self.set_field_calls = defaultdict(dict)
        bb = MyBlockingBusy(args, self.ids, self.db, self.refresh_books,
            getattr(self, 'custom_column_widgets', []),
            self.do_search_replace, do_sr, self.set_field_calls, parent=self)

        # The metadata backup thread causes database commits
        # which can slow down bulk editing of large numbers of books
        self.model.stop_metadata_backup()
        try:
            bb.exec_()
        finally:
            self.model.start_metadata_backup()

        bb.thread = bb.db = bb.cc_widgets = None

        if bb.error is not None:
            return error_dialog(self, _('Failed'),
                    bb.error[0], det_msg=bb.error[1],
                    show=True)

        dynamic['s_r_search_mode'] = self.search_mode.currentIndex()
        self.db.clean()
        return QDialog.accept(self)
示例#7
0
 def displayText(self, val, locale):
     d = qt_to_dt(val)
     if is_date_undefined(d):
         return ''
     return format_date(d, self.format)
示例#8
0
 def displayText(self, val, locale):
     d = val.toDateTime()
     if d <= UNDEFINED_QDATETIME:
         return ''
     return format_date(qt_to_dt(d, as_utc=False), self.format)
示例#9
0
 def fget(self):
     return qt_to_dt(self.dateTime(), as_utc=False)
示例#10
0
 def displayText(self, val, locale):
     d = convert_qvariant(val)
     if d <= UNDEFINED_QDATETIME:
         return ''
     return format_date(qt_to_dt(d, as_utc=False), self.format)