Fix another error in the manage category editor when setting was

This commit is contained in:
Kovid Goyal 2023-04-22 11:20:05 +05:30
parent a91889f390
commit 89391da7b7
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -593,12 +593,8 @@ class TagListEditor(QDialog, Ui_TagListEditor):
for item in items:
id_ = int(item.data(Qt.ItemDataRole.UserRole))
self.to_rename[id_] = new_text
orig = self.table.item(item.row(), 2)
if orig is None:
orig = was_item()
self.table.setItem(item.row(), 2, orig)
self.set_was_from_item(item)
item.setText(new_text)
orig.setData(Qt.ItemDataRole.DisplayRole, item.initial_text())
self.table.blockSignals(False)
def undo_edit(self):
@ -717,8 +713,7 @@ class TagListEditor(QDialog, Ui_TagListEditor):
self.to_delete.add(id_)
item.set_is_deleted(True)
row = item.row()
orig = self.table.item(row, 2)
orig.setData(Qt.ItemDataRole.DisplayRole, item.initial_text())
self.set_was_from_item(item)
link = self.table.item(row, 3)
link.setFlags(link.flags() & ~(Qt.ItemFlag.ItemIsSelectable|Qt.ItemFlag.ItemIsEditable))
link.setIcon(QIcon.ic('trash.png'))
@ -728,6 +723,13 @@ class TagListEditor(QDialog, Ui_TagListEditor):
if row >= 0:
self.table.scrollToItem(self.table.item(row, 0))
def set_was_from_item(self, item):
orig = self.table.item(item.row(), 2)
if orig is None:
orig = was_item()
self.table.setItem(item.row(), 2, orig)
orig.setData(Qt.ItemDataRole.DisplayRole, item.initial_text())
def record_sort(self, section):
# Note what sort was done so we can redo it when the table is rebuilt
sort_name = self.sort_names[section]