mirror of
https://github.com/fergalmoran/picard.git
synced 2026-02-25 09:03:59 +00:00
Add support for hashable ListWidgetItem
This commit is contained in:
@@ -44,3 +44,16 @@ class HashableTreeWidgetItem(QtWidgets.QTreeWidgetItem):
|
||||
|
||||
def __hash__(self):
|
||||
return hash(str(self.id))
|
||||
|
||||
|
||||
class HashableListWidgetItem(QtWidgets.QListWidgetItem):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.id = uuid.uuid4()
|
||||
|
||||
def __eq__(self, other):
|
||||
return self.id == other.id
|
||||
|
||||
def __hash__(self):
|
||||
return hash(str(self.id))
|
||||
|
||||
@@ -21,6 +21,7 @@ from PyQt5 import QtCore, QtGui, QtWidgets
|
||||
from picard import config
|
||||
from picard.const import PICARD_URLS
|
||||
from picard.script import ScriptParser
|
||||
from picard.ui import HashableListWidgetItem
|
||||
from picard.ui.options import OptionsPage, OptionsCheckError, register_options_page
|
||||
from picard.ui.ui_options_script import Ui_ScriptingOptionsPage
|
||||
|
||||
@@ -272,7 +273,7 @@ class ScriptingOptionsPage(OptionsPage):
|
||||
numbered_name = _(DEFAULT_NUMBERED_SCRIPT_NAME) % (count + 1)
|
||||
script = ScriptItem(pos=count, name=numbered_name)
|
||||
|
||||
list_item = QtWidgets.QListWidgetItem()
|
||||
list_item = HashableListWidgetItem()
|
||||
list_widget = AdvancedScriptItem(numbered_name)
|
||||
self.setSignals(list_widget, list_item)
|
||||
self.ui.script_list.addItem(list_item)
|
||||
@@ -388,7 +389,7 @@ class ScriptingOptionsPage(OptionsPage):
|
||||
self.list_of_scripts = config.setting["list_of_scripts"]
|
||||
for s_pos, s_name, s_enabled, s_text in self.list_of_scripts:
|
||||
script = ScriptItem(s_pos, s_name, s_enabled, s_text)
|
||||
list_item = QtWidgets.QListWidgetItem()
|
||||
list_item = HashableListWidgetItem()
|
||||
list_widget = AdvancedScriptItem(name=s_name, state=s_enabled)
|
||||
self.setSignals(list_widget, list_item)
|
||||
self.ui.script_list.addItem(list_item)
|
||||
|
||||
@@ -337,7 +337,7 @@ class XmlWebService(QtCore.QObject):
|
||||
return self.add_task(func, host, port, priority, important=important)
|
||||
|
||||
def stop(self):
|
||||
for reply in self._active_requests.keys():
|
||||
for reply in list(self._active_requests.keys()):
|
||||
reply.abort()
|
||||
self._init_queues()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user