Skip to content

Commit

Permalink
Revamp code a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
zas committed May 19, 2024
1 parent ef939ff commit 861419e
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions picard/ui/metadatabox.py
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,14 @@ def _update_items(self, result=None, error=None):
alignment = QtCore.Qt.AlignmentFlag.AlignLeft | QtCore.Qt.AlignmentFlag.AlignTop

for i, tag in enumerate(self.tag_diff.tag_names):
is_preserved = tag in self.preserved_tags
if tag == '~length' or is_preserved:
self.tag_diff.set_bits(tag, TagStatus.NOTREMOVABLE | TagStatus.READONLY)
new_item_flags = orig_flags
elif tag != '~length':
self.tag_diff.unset_bits(tag, TagStatus.NOTREMOVABLE | TagStatus.READONLY)
new_item_flags = new_flags

color = self.colors.get(self.tag_diff.tag_status(tag),
self.colors[TagStatus.NOCHANGE])

Expand Down Expand Up @@ -726,18 +734,14 @@ def _update_items(self, result=None, error=None):
new_item = QtWidgets.QTableWidgetItem()
new_item.setTextAlignment(alignment)
self.setItem(i, self.COLUMN_NEW, new_item)
if is_preserved or tag == '~length':
self.tag_diff.set_bits(tag, TagStatus.NOTREMOVABLE | TagStatus.READONLY)
new_item.setFlags(orig_flags)
else:
if tag != '~length':
self.tag_diff.unset_bits(tag, TagStatus.NOTREMOVABLE | TagStatus.READONLY)
new_item.setFlags(new_flags)
self._set_item_value(new_item, self.tag_diff.new, tag)
new_item.setFlags(new_item_flags)

font = new_item.font()
strikeout = self.tag_diff.tag_status(tag) == TagStatus.REMOVED
font.setStrikeOut(strikeout)
new_item.setFont(font)

self._set_item_value(new_item, self.tag_diff.new, tag)
new_item.setForeground(color)

# Adjust row height to content size
Expand Down

0 comments on commit 861419e

Please sign in to comment.