From 143ce0015f06f07e38db4d03d0b0f98389997975 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sun, 30 Jun 2013 20:33:41 +0200 Subject: [PATCH 1/2] added __hash__ methods --- openlp/core/lib/serviceitem.py | 6 ++++++ openlp/plugins/custom/lib/db.py | 9 +++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/openlp/core/lib/serviceitem.py b/openlp/core/lib/serviceitem.py index b32e1aaf0..ee1a5c588 100644 --- a/openlp/core/lib/serviceitem.py +++ b/openlp/core/lib/serviceitem.py @@ -485,6 +485,12 @@ class ServiceItem(object): """ return self.unique_identifier != other.unique_identifier + def __hash__(self): + """ + Return the hash for the service item. + """ + return self.unique_identifier + def is_media(self): """ Confirms if the ServiceItem is media diff --git a/openlp/plugins/custom/lib/db.py b/openlp/plugins/custom/lib/db.py index 253ca5432..2f6eb5d6d 100644 --- a/openlp/plugins/custom/lib/db.py +++ b/openlp/plugins/custom/lib/db.py @@ -41,14 +41,19 @@ class CustomSlide(BaseModel): """ CustomSlide model """ - # By default sort the customs by its title considering language specific - # characters. + # By default sort the customs by its title considering language specific characters. def __lt__(self, other): return get_locale_key(self.title) < get_locale_key(other.title) def __eq__(self, other): return get_locale_key(self.title) == get_locale_key(other.title) + def __hash__(self): + """ + Return the hash for a custom slide. + """ + return self.id + def init_schema(url): """ From 72933138a29b5e8c1ab8383f25e133740e8da793 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sun, 30 Jun 2013 20:37:12 +0200 Subject: [PATCH 2/2] clean up --- openlp/plugins/custom/forms/editcustomform.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/openlp/plugins/custom/forms/editcustomform.py b/openlp/plugins/custom/forms/editcustomform.py index 580fbde07..1009ea8d3 100644 --- a/openlp/plugins/custom/forms/editcustomform.py +++ b/openlp/plugins/custom/forms/editcustomform.py @@ -100,8 +100,7 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): self.credit_edit.setText(self.custom_slide.credits) custom_XML = CustomXMLParser(self.custom_slide.text) slide_list = custom_XML.get_verses() - for slide in slide_list: - self.slide_list_view.addItem(slide[1]) + self.slide_list_view.addItems([slide[1] for slide in slide_list]) theme = self.custom_slide.theme_name find_and_set_in_combo_box(self.theme_combo_box, theme) self.title_edit.setFocus()