From a5615fd4fea32e533972ea0451c477ae20eb1287 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 17 May 2009 16:24:02 +0100 Subject: [PATCH] Corrections to Renderer to handle slides not lines Fixes to Bibleplugin to renderer multiple verses per slide Pass Bible Theme to RenderManager --- openlp/core/lib/renderer.py | 2 +- openlp/core/lib/rendermanager.py | 2 +- openlp/core/lib/serviceitem.py | 2 +- openlp/plugins/bibles/lib/biblestab.py | 1 + openlp/plugins/bibles/lib/mediaitem.py | 17 +++++---- openlp/plugins/bibles/lib/textlistdata.py | 45 +++++++++++++++-------- 6 files changed, 42 insertions(+), 27 deletions(-) diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index 7335da9b1..0490ed3ee 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -118,7 +118,7 @@ class Renderer: """ log.debug(u'format_slide %s', words) verses = [] - verses_text = words.splitlines() + verses_text = words.split(u'\n\n') for verse in verses_text: lines = verse.split(u'\n') verses.append(self.split_set_of_lines(lines, footer)[0]) diff --git a/openlp/core/lib/rendermanager.py b/openlp/core/lib/rendermanager.py index 48196a445..49b1f515d 100644 --- a/openlp/core/lib/rendermanager.py +++ b/openlp/core/lib/rendermanager.py @@ -123,7 +123,7 @@ class RenderManager: self.calculate_default(self.screen_list[self.current_display]['size']) self.build_text_rectangle(self.themedata) self.renderer.set_frame_dest(self.width, self.height) - return self.renderer.format_slide(words, footer) + return self.renderer.format_slide(words, False) def generate_slide(self,main_text, footer_text): log.debug(u'generate slide') diff --git a/openlp/core/lib/serviceitem.py b/openlp/core/lib/serviceitem.py index d0b30016c..eb8ce751c 100644 --- a/openlp/core/lib/serviceitem.py +++ b/openlp/core/lib/serviceitem.py @@ -47,7 +47,7 @@ class ServiceItem(): self.frames = [] self.raw_footer = None self.theme = None - log.debug(u'Service item created for %s', self.shortname) + log.debug(u'Service item created for %s ', self.shortname) def addIcon(self, icon): self.iconic_representation = buildIcon(icon) diff --git a/openlp/plugins/bibles/lib/biblestab.py b/openlp/plugins/bibles/lib/biblestab.py index e28139e45..ccb37cb4c 100644 --- a/openlp/plugins/bibles/lib/biblestab.py +++ b/openlp/plugins/bibles/lib/biblestab.py @@ -198,6 +198,7 @@ class BiblesTab(SettingsTab): self.BibleThemeComboBox.setCurrentIndex(self.bible_theme) else: pass # TODO need to code + self.bible_theme = None def save(self): self.config.set_config("paragraph style", str(self.paragraph_style)) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index d179d1654..5fedf9883 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -369,13 +369,14 @@ class BibleMediaItem(MediaManagerItem): def generateSlideData(self, service_item): log.debug(u'Bible Preview Button pressed') items = self.BibleListView.selectedIndexes() - old_chapter = '' + old_chapter = u'' raw_slides=[] raw_footer = [] + bible_text = u'' for item in items: text = self.BibleListData.getValue(item) - verse = text[:text.find("(")] - bible = text[text.find("(") + 1:text.find(")")] + verse = text[:text.find(u'(')] + bible = text[text.find(u'(') + 1:text.find(u')')] self.searchByReference(bible, verse) book = self.search_results[0][0] chapter = str(self.search_results[0][1]) @@ -392,15 +393,15 @@ class BibleMediaItem(MediaManagerItem): else: loc = self.formatVerse(old_chapter, chapter, verse, u'', u'') old_chapter = chapter - raw_slides.append(loc + u' '+text) + bible_text = bible_text + u' '+ loc + u' '+ text service_item.title = book + u' ' + loc if len(raw_footer) <= 1: raw_footer.append(book) - if len(raw_slides) > 0: - service_item.theme = None - service_item.raw_slides = raw_slides - service_item.raw_footer = raw_footer + service_item.theme = self.parent.bibles_tab.bible_theme + raw_slides.append(bible_text) + service_item.raw_slides = raw_slides + service_item.raw_footer = raw_footer def formatVerse(self, old_chapter, chapter, verse, opening, closing): loc = opening diff --git a/openlp/plugins/bibles/lib/textlistdata.py b/openlp/plugins/bibles/lib/textlistdata.py index 6119a1325..16ef37db5 100644 --- a/openlp/plugins/bibles/lib/textlistdata.py +++ b/openlp/plugins/bibles/lib/textlistdata.py @@ -1,3 +1,22 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 +""" +OpenLP - Open Source Lyrics Projection +Copyright (c) 2008 Raoul Snyman +Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free Software +Foundation; version 2 of the License. + +This program is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A +PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place, Suite 330, Boston, MA 02111-1307 USA +""" import logging from PyQt4.QtCore import * @@ -6,7 +25,7 @@ from PyQt4.QtGui import * class TextListData(QAbstractListModel): """ - An abstract list of strings + An abstract list of strings """ global log log=logging.getLogger(u'TextListData') @@ -14,18 +33,18 @@ class TextListData(QAbstractListModel): def __init__(self): QAbstractListModel.__init__(self) - self.items=[] # will be a list of (database id , title) tuples + self.items = [] # will be a list of (database id , title) tuples def resetStore(self): #reset list so can be reloaded - self.items=[] - + self.items = [] + def rowCount(self, parent): return len(self.items) def insertRow(self, row, id, title): self.beginInsertRows(QModelIndex(),row,row) - log.debug("insert row %d:%s for id %d"%(row,title, id)) + log.debug(u'insert row %d:%s for id %d'%(row,title, id)) self.items.insert(row, (id, title)) self.endInsertRows() @@ -36,18 +55,15 @@ class TextListData(QAbstractListModel): def addRow(self, id, title): self.insertRow(len(self.items), id, title) - + def data(self, index, role): row=index.row() if row > len(self.items): # if the last row is selected and deleted, we then get called with an empty row! return QVariant() - if role==Qt.DisplayRole: - retval= self.items[row][1] -# elif role == Qt.ToolTipRole: #not sure if need as it shows the database row number -# retval= self.items[row][0] + if role == Qt.DisplayRole: + retval = self.items[row][1] else: - retval= QVariant() -# log.info("Returning"+ str(retval)) + retval = QVariant() if type(retval) is not type(QVariant): return QVariant(retval) else: @@ -60,10 +76,7 @@ class TextListData(QAbstractListModel): def getValue(self, index): row = index.row() return self.items[row][1] - + def deleteRow(self, index): row = index.row() self.removeRow(row) - -if __name__=="__main__": - sxml=TextListData()