Fix #1924878 ["Undo" in Review Downloaded Metadata doesn't work after overwriting](https://bugs.launchpad.net/calibre/+bug/1924878)

This commit is contained in:
Kovid Goyal 2021-04-25 21:38:12 +05:30
parent 5f927e2ea0
commit ce0898ca53
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -93,6 +93,11 @@ class LineEdit(EditWithComplete):
self.setText(val)
self.setCursorPosition(0)
def set_undoable(self, val):
self.selectAll()
self.insert(val)
self.setCursorPosition(0)
@property
def is_blank(self):
val = self.current_val.strip()
@ -138,6 +143,9 @@ class LanguagesEdit(LE):
def same_as(self, other):
return self.current_val == other.current_val
def set_undoable(self, val):
self.set_lang_codes(val, True)
class RatingsEdit(RatingEdit):
@ -191,6 +199,9 @@ class DateEdit(PubdateEdit):
def same_as(self, other):
return self.text() == other.text()
def set_undoable(self, val):
self.set_value(val)
class SeriesEdit(LineEdit):
@ -274,6 +285,10 @@ class CommentsEdit(Editor):
self.html = val or ''
self.changed.emit()
def set_undoable(self, val):
self.set_html(val, allow_undo=True)
self.changed.emit()
def from_mi(self, mi):
val = mi.get(self.field, default='')
self.current_val = val
@ -486,6 +501,9 @@ class CompareSingle(QWidget):
def revert(self, field):
widgets = self.widgets[field]
neww, oldw = widgets[:2]
if hasattr(neww, 'set_undoable'):
neww.set_undoable(oldw.current_val)
else:
neww.current_val = oldw.current_val
def merge_identifiers(self):