Skip to content

Commit 5350b2c

Browse files
committed
Fixed CheckboxListItem hiding QListWidgetItem.data()
1 parent 6c08a62 commit 5350b2c

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

picard/ui/checkbox_list_item.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
# Copyright (C) 2018 Sambhav Kothari
66
# Copyright (C) 2018, 2020-2024 Laurent Monin
7-
# Copyright (C) 2022 Philipp Wolfer
7+
# Copyright (C) 2022, 2024 Philipp Wolfer
88
#
99
# This program is free software; you can redistribute it and/or
1010
# modify it under the terms of the GNU General Public License
@@ -27,12 +27,10 @@
2727

2828
class CheckboxListItem(QListWidgetItem):
2929

30-
def __init__(self, text='', checked=False, data=None):
31-
super().__init__()
32-
self.setText(text)
30+
def __init__(self, text='', checked=False):
31+
super().__init__(text)
3332
self.setFlags(self.flags() | Qt.ItemFlag.ItemIsUserCheckable)
3433
self.setCheckState(Qt.CheckState.Checked if checked else Qt.CheckState.Unchecked)
35-
self.data = data
3634

3735
@property
3836
def checked(self):

picard/ui/options/cover.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Picard, the next-generation MusicBrainz tagger
44
#
55
# Copyright (C) 2006-2007 Lukáš Lalinský
6-
# Copyright (C) 2010, 2018-2021 Philipp Wolfer
6+
# Copyright (C) 2010, 2018-2021, 2024 Philipp Wolfer
77
# Copyright (C) 2012, 2014 Wieland Hoffmann
88
# Copyright (C) 2012-2014 Michael Wiencek
99
# Copyright (C) 2013-2015, 2018-2021, 2023-2024 Laurent Monin
@@ -25,6 +25,7 @@
2525
# along with this program; if not, write to the Free Software
2626
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2727

28+
from PyQt6.QtCore import Qt
2829

2930
from picard.config import (
3031
Option,
@@ -83,7 +84,8 @@ def _load_cover_art_providers(self):
8384
"""
8485
self.ui.ca_providers_list.clear()
8586
for p in cover_art_providers():
86-
item = CheckboxListItem(_(p.title), checked=p.enabled, data=p.name)
87+
item = CheckboxListItem(_(p.title), checked=p.enabled)
88+
item.setData(Qt.ItemDataRole.UserRole, p.name)
8789
self.ui.ca_providers_list.addItem(item)
8890

8991
def load(self):
@@ -101,7 +103,7 @@ def load(self):
101103

102104
def _ca_providers(self):
103105
for item in qlistwidget_items(self.ui.ca_providers_list):
104-
yield (item.data, item.checked)
106+
yield (item.data(Qt.ItemDataRole.UserRole), item.checked)
105107

106108
def save(self):
107109
config = get_config()

0 commit comments

Comments
 (0)