From 3359726be2164e35cf78bbd34beb4538fbe6430f Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Fri, 20 May 2011 17:14:10 +0200 Subject: [PATCH 01/12] improved media item sorting --- openlp/plugins/custom/lib/mediaitem.py | 5 +++++ openlp/plugins/songs/lib/mediaitem.py | 11 +++-------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/openlp/plugins/custom/lib/mediaitem.py b/openlp/plugins/custom/lib/mediaitem.py index 66b1c3675..72db3bfa4 100644 --- a/openlp/plugins/custom/lib/mediaitem.py +++ b/openlp/plugins/custom/lib/mediaitem.py @@ -25,6 +25,8 @@ ############################################################################### import logging +import locale +import operator from PyQt4 import QtCore, QtGui from sqlalchemy.sql import or_, func @@ -135,6 +137,9 @@ class CustomMediaItem(MediaManagerItem): def loadList(self, list): self.listView.clear() + # Sort the customs by its title considering language specific + # characters. + list.sort(cmp=locale.strcoll, key=operator.attrgetter('title')) for customSlide in list: custom_name = QtGui.QListWidgetItem(customSlide.title) custom_name.setData( diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 5f961b2f2..19a2924b3 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -26,6 +26,7 @@ import logging import locale +import operator from PyQt4 import QtCore, QtGui from sqlalchemy.sql import or_ @@ -229,7 +230,8 @@ class SongMediaItem(MediaManagerItem): def displayResultsSong(self, searchresults): log.debug(u'display results Song') self.listView.clear() - searchresults.sort(cmp=self.collateSongTitles) + # Sort the songs by its title considering language specific characters. + searchresults.sort(cmp=locale.strcoll, key=operator.attrgetter('title')) for song in searchresults: author_list = [author.display_name for author in song.authors] song_title = unicode(song.title) @@ -472,13 +474,6 @@ class SongMediaItem(MediaManagerItem): Receiver.send_message(u'service_item_update', u'%s:%s' % (editId, item._uuid)) - def collateSongTitles(self, song_1, song_2): - """ - Locale aware collation of song titles - """ - return locale.strcoll(unicode(song_1.title.lower()), - unicode(song_2.title.lower())) - def search(self, string): """ Search for some songs From 5a7aa2fb9fde71785dfbee7641f9c7a1ad6b2b70 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Fri, 20 May 2011 17:18:57 +0200 Subject: [PATCH 02/12] do not override list --- openlp/plugins/custom/lib/mediaitem.py | 10 +++++----- openlp/plugins/presentations/lib/mediaitem.py | 10 ++++------ 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/openlp/plugins/custom/lib/mediaitem.py b/openlp/plugins/custom/lib/mediaitem.py index 72db3bfa4..f22771eff 100644 --- a/openlp/plugins/custom/lib/mediaitem.py +++ b/openlp/plugins/custom/lib/mediaitem.py @@ -135,15 +135,15 @@ class CustomMediaItem(MediaManagerItem): self.onPreviewClick() self.onRemoteEditClear() - def loadList(self, list): + def loadList(self, custom_slides): self.listView.clear() # Sort the customs by its title considering language specific # characters. - list.sort(cmp=locale.strcoll, key=operator.attrgetter('title')) - for customSlide in list: - custom_name = QtGui.QListWidgetItem(customSlide.title) + custom_slides.sort(cmp=locale.strcoll, key=operator.attrgetter('title')) + for custom_slide in custom_slides: + custom_name = QtGui.QListWidgetItem(custom_slide.title) custom_name.setData( - QtCore.Qt.UserRole, QtCore.QVariant(customSlide.id)) + QtCore.Qt.UserRole, QtCore.QVariant(custom_slide.id)) self.listView.addItem(custom_name) def onNewClick(self): diff --git a/openlp/plugins/presentations/lib/mediaitem.py b/openlp/plugins/presentations/lib/mediaitem.py index 7660c9099..5cc6f1fe1 100644 --- a/openlp/plugins/presentations/lib/mediaitem.py +++ b/openlp/plugins/presentations/lib/mediaitem.py @@ -149,20 +149,18 @@ class PresentationMediaItem(MediaManagerItem): else: self.presentationWidget.hide() - def loadList(self, list, initialLoad=False): + def loadList(self, files, initialLoad=False): """ Add presentations into the media manager This is called both on initial load of the plugin to populate with existing files, and when the user adds new files via the media manager """ currlist = self.getFileList() - titles = [] - for file in currlist: - titles.append(os.path.split(file)[1]) + titles = [os.path.split(file)[1] for file in currlist] Receiver.send_message(u'cursor_busy') if not initialLoad: - self.parent.formparent.displayProgressBar(len(list)) - for file in list: + self.parent.formparent.displayProgressBar(len(files)) + for file in files: if not initialLoad: self.parent.formparent.incrementProgressBar() if currlist.count(file) > 0: From f753070f53bebc8f85d877ad666f4db0be9ca9c6 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Fri, 20 May 2011 19:06:38 +0200 Subject: [PATCH 03/12] fix for windows --- openlp/plugins/custom/lib/mediaitem.py | 3 ++- openlp/plugins/songs/lib/mediaitem.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/custom/lib/mediaitem.py b/openlp/plugins/custom/lib/mediaitem.py index f22771eff..064a558ba 100644 --- a/openlp/plugins/custom/lib/mediaitem.py +++ b/openlp/plugins/custom/lib/mediaitem.py @@ -139,7 +139,8 @@ class CustomMediaItem(MediaManagerItem): self.listView.clear() # Sort the customs by its title considering language specific # characters. - custom_slides.sort(cmp=locale.strcoll, key=operator.attrgetter('title')) + custom_slides.sort( + cmp=locale.strcoll, key=operator.attrgetter('title').lower()) for custom_slide in custom_slides: custom_name = QtGui.QListWidgetItem(custom_slide.title) custom_name.setData( diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 19a2924b3..eb65fa775 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -231,7 +231,8 @@ class SongMediaItem(MediaManagerItem): log.debug(u'display results Song') self.listView.clear() # Sort the songs by its title considering language specific characters. - searchresults.sort(cmp=locale.strcoll, key=operator.attrgetter('title')) + searchresults.sort( + cmp=locale.strcoll, key=operator.attrgetter('title').lower()) for song in searchresults: author_list = [author.display_name for author in song.authors] song_title = unicode(song.title) From 594caf0a193a1e3e4ed80c856363b28681bda1c4 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 23 May 2011 12:34:42 +0200 Subject: [PATCH 04/12] fix for windows --- openlp/plugins/custom/lib/mediaitem.py | 2 +- openlp/plugins/songs/lib/mediaitem.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/custom/lib/mediaitem.py b/openlp/plugins/custom/lib/mediaitem.py index 064a558ba..e56200ee7 100644 --- a/openlp/plugins/custom/lib/mediaitem.py +++ b/openlp/plugins/custom/lib/mediaitem.py @@ -140,7 +140,7 @@ class CustomMediaItem(MediaManagerItem): # Sort the customs by its title considering language specific # characters. custom_slides.sort( - cmp=locale.strcoll, key=operator.attrgetter('title').lower()) + cmp=locale.strcoll, key=lambda custom: custom.title.lower()) for custom_slide in custom_slides: custom_name = QtGui.QListWidgetItem(custom_slide.title) custom_name.setData( diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index eb65fa775..cbdb20462 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -232,7 +232,7 @@ class SongMediaItem(MediaManagerItem): self.listView.clear() # Sort the songs by its title considering language specific characters. searchresults.sort( - cmp=locale.strcoll, key=operator.attrgetter('title').lower()) + cmp=locale.strcoll, key=lambda song: song.title.lower()) for song in searchresults: author_list = [author.display_name for author in song.authors] song_title = unicode(song.title) From 73293c2985daeead5ac3e5ec61d3709d1fd019d8 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 23 May 2011 13:14:05 +0200 Subject: [PATCH 05/12] removed imports --- openlp/plugins/custom/lib/mediaitem.py | 1 - openlp/plugins/songs/lib/mediaitem.py | 1 - 2 files changed, 2 deletions(-) diff --git a/openlp/plugins/custom/lib/mediaitem.py b/openlp/plugins/custom/lib/mediaitem.py index e56200ee7..d19f462d7 100644 --- a/openlp/plugins/custom/lib/mediaitem.py +++ b/openlp/plugins/custom/lib/mediaitem.py @@ -26,7 +26,6 @@ import logging import locale -import operator from PyQt4 import QtCore, QtGui from sqlalchemy.sql import or_, func diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index cbdb20462..0dabeb766 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -26,7 +26,6 @@ import logging import locale -import operator from PyQt4 import QtCore, QtGui from sqlalchemy.sql import or_ From ce5c354e06c587df7c0b04ab68ff2dddf0bf2a66 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 23 May 2011 13:49:14 +0200 Subject: [PATCH 06/12] fix for head --- openlp/plugins/custom/lib/mediaitem.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/plugins/custom/lib/mediaitem.py b/openlp/plugins/custom/lib/mediaitem.py index 054a75424..e137d69e3 100644 --- a/openlp/plugins/custom/lib/mediaitem.py +++ b/openlp/plugins/custom/lib/mediaitem.py @@ -146,7 +146,7 @@ class CustomMediaItem(MediaManagerItem): QtCore.Qt.UserRole, QtCore.QVariant(custom_slide.id)) self.listView.addItem(custom_name) # Auto-select the item if name has been set - if customSlide.title == self.autoSelectItem : + if custom_slide.title == self.autoSelectItem: self.listView.setCurrentItem(custom_name) def onNewClick(self): From ffd017799f7574e66562a4828c1003555169a77e Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 23 May 2011 19:28:52 +0200 Subject: [PATCH 07/12] new 'word by word' algorithm --- openlp/core/lib/renderer.py | 68 +++++++++++++++++++++++++++++-------- 1 file changed, 54 insertions(+), 14 deletions(-) diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index bba85d176..f06fba539 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -231,7 +231,11 @@ class Renderer(object): pages.extend(new_pages) # Bibles elif item.is_capable(ItemCapabilities.AllowsWordSplit): + import time + import datetime + start = time.time() pages = self._paginate_slide_words(text, line_break) + print unicode(datetime.timedelta(seconds=time.time() - start)) return pages def _calculate_default(self, screen): @@ -367,7 +371,7 @@ class Renderer(object): """ log.debug(u'_paginate_slide_words - Start') - line_end = u'' + line_end = u' ' if line_break: line_end = u'
' formatted = [] @@ -375,6 +379,7 @@ class Renderer(object): previous_raw = u'' lines = text.split(u'\n') for line in lines: + line = line.strip() styled_line = expand_tags(line) html = self.page_shell + previous_html + styled_line + HTML_END self.web.setHtml(html) @@ -402,24 +407,59 @@ class Renderer(object): previous_html = styled_line + line_end previous_raw = line + line_end continue - words = self._words_split(line) - for word in words: - styled_word = expand_tags(word) - html = self.page_shell + previous_html + styled_word + \ - HTML_END + # Figure out how many words of the line will fit on screen. + # Instead of just looping of the list of words we follow a + # certain tactic, namely we try if the half of line fits. If it + # does we try if the half of the other half and the first half + # (75%) will still fit. In the case that the first half does not + # fit, we try if 25% will fit. + raw_words = self._words_split(line) + html_words = [expand_tags(word) for word in raw_words] + smallest_index = 0 + highest_index = len(html_words) - 1 + index = int(highest_index / 2) + while True: + html = self.page_shell + previous_html + \ + u''.join(html_words[:index + 1]).strip() + HTML_END self.web.setHtml(html) - # Text too long so go to next page if self.web_frame.contentsSize().height() > \ self.page_height: - while previous_raw.endswith(u'
'): - previous_raw = previous_raw[:-4] - formatted.append(previous_raw) + # We know that it does not fit, so change/calculate the + # new index and highest_index accordingly. + highest_index = index + index = int(index - (index - smallest_index) / 2) + else: + smallest_index = index + index = int(index + (highest_index - index) / 2) + # We found the number of words which will fit + if smallest_index == index or highest_index == index: + formatted.append(previous_raw.rstrip(u'
') + + u''.join(raw_words[:index + 1])) previous_html = u'' previous_raw = u'' - previous_html += styled_word - previous_raw += word - previous_html += line_end - previous_raw += line_end + else: + continue + # Check if the rest of the line fits on the slide. If it + # does we do not have to do the much more intensive "word by + # word" checking. + html = self.page_shell + \ + u''.join(html_words[index + 1:]).strip() + HTML_END + self.web.setHtml(html) + if self.web_frame.contentsSize().height() <= \ + self.page_height: + previous_html = \ + u''.join(html_words[index + 1:]).strip() + line_end + previous_raw = \ + u''.join(raw_words[index + 1:]).strip() + line_end + break + else: + # The other words do not fit, thus reset the indexes, + # create a new list and continue with "word by word". + raw_words = raw_words[index + 1:] + html_words = html_words[index + 1:] + smallest_index = 0 + highest_index = len(html_words) - 1 + index = int(highest_index / 2) else: previous_html += styled_line + line_end previous_raw += line + line_end From 86023454916178161633cf51ef1655a5fc032dad Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 23 May 2011 20:23:45 +0200 Subject: [PATCH 08/12] removed print --- openlp/core/lib/renderer.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index f06fba539..ea6c3b4ce 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -231,11 +231,7 @@ class Renderer(object): pages.extend(new_pages) # Bibles elif item.is_capable(ItemCapabilities.AllowsWordSplit): - import time - import datetime - start = time.time() pages = self._paginate_slide_words(text, line_break) - print unicode(datetime.timedelta(seconds=time.time() - start)) return pages def _calculate_default(self, screen): From 5b7dc621123e5860bbdb11d3e87cf5e5092182dd Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 23 May 2011 20:41:49 +0200 Subject: [PATCH 09/12] comments --- openlp/core/lib/renderer.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index f413bd778..6b20f7670 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -335,7 +335,7 @@ class Renderer(object): styled_text += styled_line html = self.page_shell + styled_text + HTML_END self.web.setHtml(html) - # Text too long so go to next page + # Text too long so go to next page. if self.web_frame.contentsSize().height() > self.page_height: if force_page and line_count > 0: Receiver.send_message(u'theme_line_count', line_count) @@ -378,7 +378,7 @@ class Renderer(object): styled_line = expand_tags(line) html = self.page_shell + previous_html + styled_line + HTML_END self.web.setHtml(html) - # Text too long so go to next page + # Text too long so go to next page. if self.web_frame.contentsSize().height() > self.page_height: # Check if there was a verse before the current one and append # it, when it fits on the page. @@ -426,7 +426,7 @@ class Renderer(object): else: smallest_index = index index = int(index + (highest_index - index) / 2) - # We found the number of words which will fit + # We found the number of words which will fit. if smallest_index == index or highest_index == index: formatted.append(previous_raw.rstrip(u'
') + u''.join(raw_words[:index + 1])) From 5473d3c817febdad4e622c7d63df61efbff00623 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Tue, 24 May 2011 07:23:28 +0200 Subject: [PATCH 10/12] added windows comment --- openlp/plugins/custom/lib/mediaitem.py | 2 +- openlp/plugins/songs/lib/mediaitem.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/openlp/plugins/custom/lib/mediaitem.py b/openlp/plugins/custom/lib/mediaitem.py index e137d69e3..85e6e51f2 100644 --- a/openlp/plugins/custom/lib/mediaitem.py +++ b/openlp/plugins/custom/lib/mediaitem.py @@ -137,7 +137,7 @@ class CustomMediaItem(MediaManagerItem): def loadList(self, custom_slides): self.listView.clear() # Sort the customs by its title considering language specific - # characters. + # characters. lower() is needed for windows! custom_slides.sort( cmp=locale.strcoll, key=lambda custom: custom.title.lower()) for custom_slide in custom_slides: diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 45827da0b..23632ca58 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -230,6 +230,7 @@ class SongMediaItem(MediaManagerItem): log.debug(u'display results Song') self.listView.clear() # Sort the songs by its title considering language specific characters. + # lower() is needed for windows! searchresults.sort( cmp=locale.strcoll, key=lambda song: song.title.lower()) for song in searchresults: From 2377a5f5ff915f19b08fd0f5a144d6f324bf25cd Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Tue, 24 May 2011 09:02:13 +0200 Subject: [PATCH 11/12] fix for Esther 8:7 --- openlp/core/lib/renderer.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index 6b20f7670..cb65dc057 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -402,12 +402,8 @@ class Renderer(object): previous_html = styled_line + line_end previous_raw = line + line_end continue - # Figure out how many words of the line will fit on screen. - # Instead of just looping of the list of words we follow a - # certain tactic, namely we try if the half of line fits. If it - # does we try if the half of the other half and the first half - # (75%) will still fit. In the case that the first half does not - # fit, we try if 25% will fit. + # Figure out how many words of the line will fit on screen by + # using the algorithm known as "binary chop". raw_words = self._words_split(line) html_words = [expand_tags(word) for word in raw_words] smallest_index = 0 @@ -428,6 +424,7 @@ class Renderer(object): index = int(index + (highest_index - index) / 2) # We found the number of words which will fit. if smallest_index == index or highest_index == index: + index = smallest_index formatted.append(previous_raw.rstrip(u'
') + u''.join(raw_words[:index + 1])) previous_html = u'' From ca6e172f5accf4113f2a2b4757797b4f07b23d4d Mon Sep 17 00:00:00 2001 From: Stevan Pettit Date: Tue, 24 May 2011 08:57:58 -0400 Subject: [PATCH 12/12] modified: scripts/windows-builder.py --- scripts/windows-builder.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/windows-builder.py b/scripts/windows-builder.py index 26394f189..750f14916 100644 --- a/scripts/windows-builder.py +++ b/scripts/windows-builder.py @@ -95,6 +95,12 @@ Visual C++ 2008 Express Edition windows-builder.py This script, of course. It should be in the "scripts" directory of OpenLP. +psvince.dll + This dll is used during the actual install of OpenLP to check if OpenLP is + running on the users machine prior to the setup. If OpenLP is running, + the install will fail. The dll can be obtained from here: + http://www.vincenzo.net/isxkb/index.php?title=PSVince) + """ import os