Skip to content

Commit

Permalink
Improve debug output for headers save/restore, using class name
Browse files Browse the repository at this point in the history
It will now log:

```
D: 13:03:20,551 ui/itemviews.save_state:833: Save state of FileTreeView's header
D: 13:03:20,551 ui/itemviews.save_state:833: Save state of AlbumTreeView's header
```

Instead of:

```
D: 12:48:28,894 ui/itemviews.save_state:830: Save state of <picard.ui.itemviews.ConfigurableColumnsHeader object at 0x7f6ea0693c70>
D: 12:48:28,894 ui/itemviews.save_state:830: Save state of <picard.ui.itemviews.ConfigurableColumnsHeader object at 0x7f6ea0693d90>
```
  • Loading branch information
zas committed May 8, 2024
1 parent 556ddf0 commit 8a112a0
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions picard/ui/itemviews.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,9 @@ def on_sort_indicator_changed(self, index, order):
def lock(self, is_locked):
super().lock(is_locked)

def __str__(self):
return "%s's header" % str(self.parent().__class__.__name__)


class BaseTreeView(QtWidgets.QTreeWidget):

Expand Down Expand Up @@ -571,7 +574,7 @@ def init_header(self):

def set_header_defaults(self):
header = self.header()
log.debug("Set defaults for %r" % header)
log.debug("Set defaults for %s" % header)

# The following are settings applied to default headers
# of QTreeView and QTreeWidget.
Expand Down Expand Up @@ -816,7 +819,7 @@ def restore_state(self):
header_state = config.persist[self.header_state]
header = self.header()
if header_state and header.restoreState(header_state):
log.debug("Restore state of %r" % header)
log.debug("Restore state of %s" % header)
for i in range(0, self.columnCount()):
header.show_column(i, not self.isColumnHidden(i))
else:
Expand All @@ -827,7 +830,7 @@ def restore_state(self):
def save_state(self):
config = get_config()
header = self.header()
log.debug("Save state of %r" % header)
log.debug("Save state of %s" % header)
if header.is_locked and header.prelock_state is not None:
# if the header is locked, we don't save the current state but the prelock one
config.persist[self.header_state] = header.prelock_state
Expand Down

0 comments on commit 8a112a0

Please sign in to comment.