More cleanups - page break bibles

This commit is contained in:
Tim Bentley 2010-07-18 20:04:12 +01:00
parent 44592ae579
commit bf0dad308f
3 changed files with 16 additions and 33 deletions

View File

@ -173,18 +173,9 @@ class Renderer(object):
myCursor = QtGui.QTextCursor(doc) myCursor = QtGui.QTextCursor(doc)
layout = doc.documentLayout() layout = doc.documentLayout()
formatted = [] formatted = []
# if self._theme.display_horizontalAlign == 2:
# shell = """<p color="%s" align=center>""" %\
# self._theme.font_main_color
# elif self._theme.display_horizontalAlign == 1:
# shell = """<p color="%s" align=right>""" %\
# self._theme.font_main_color
# else:
# shell = """<p color="%s">""" % self._theme.font_main_color
shell = u'<p>%s</p>' shell = u'<p>%s</p>'
temp_text = u'' temp_text = u''
old_html_text = u'' old_html_text = u''
page = []
for line in text: for line in text:
# mark line ends # mark line ends
temp_text = temp_text + line + u'<br>' temp_text = temp_text + line + u'<br>'
@ -192,12 +183,10 @@ class Renderer(object):
doc.setHtml(html_text) doc.setHtml(html_text)
#Text too long so gone to next mage #Text too long so gone to next mage
if layout.pageCount() != 1: if layout.pageCount() != 1:
page.append(shell % old_html_text) formatted.append(shell % old_html_text)
formatted.append(page)
temp_text = line temp_text = line
old_html_text = temp_text old_html_text = temp_text
page.append(shell % old_html_text) formatted.append(shell % old_html_text)
formatted.append(page)
log.debug(u'format_slide - End') log.debug(u'format_slide - End')
#return split_text #return split_text
return formatted return formatted

View File

@ -90,7 +90,7 @@ class ServiceItem(object):
self.from_plugin = False self.from_plugin = False
self.capabilities = [] self.capabilities = []
self.is_valid = True self.is_valid = True
self.cache = {} #self.cache = {}
self.icon = None self.icon = None
self.themedata = None self.themedata = None
@ -132,7 +132,7 @@ class ServiceItem(object):
""" """
log.debug(u'Render called') log.debug(u'Render called')
self._display_frames = [] self._display_frames = []
self.clear_cache() #self.clear_cache()
self.bg_frame = None self.bg_frame = None
self.just_rendered = True self.just_rendered = True
if self.service_item_type == ServiceItemType.Text: if self.service_item_type == ServiceItemType.Text:
@ -147,17 +147,11 @@ class ServiceItem(object):
before = time.time() before = time.time()
formated = self.render_manager.format_slide(slide[u'raw_slide']) formated = self.render_manager.format_slide(slide[u'raw_slide'])
for format in formated: for format in formated:
lines = u'' self._display_frames.append({u'title': format,
title = u'' u'text': format.rstrip(),
for line in format:
if title == u'':
title = line
lines += line + u'\n'
self._display_frames.append({u'title': title,
u'text': lines.rstrip(),
u'verseTag': slide[u'verseTag'] }) u'verseTag': slide[u'verseTag'] })
if len(self._display_frames) in self.cache.keys(): # if len(self._display_frames) in self.cache.keys():
del self.cache[len(self._display_frames)] # del self.cache[len(self._display_frames)]
log.log(15, u'Formatting took %4s' % (time.time() - before)) log.log(15, u'Formatting took %4s' % (time.time() - before))
elif self.service_item_type == ServiceItemType.Image: elif self.service_item_type == ServiceItemType.Image:
for slide in self._raw_frames: for slide in self._raw_frames:
@ -189,7 +183,7 @@ class ServiceItem(object):
# else: # else:
# frame = self.render_manager.generate_slide(raw_html, u'') # frame = self.render_manager.generate_slide(raw_html, u'')
frame = None frame = None
self.cache[row] = frame #self.cache[row] = frame
return frame, raw_html[0] return frame, raw_html[0]
def add_from_image(self, path, title, image): def add_from_image(self, path, title, image):
@ -393,8 +387,8 @@ class ServiceItem(object):
""" """
return self._raw_frames[row][u'path'] return self._raw_frames[row][u'path']
def clear_cache(self): # def clear_cache(self):
""" # """
Clear's the service item's cache. # Clear's the service item's cache.
""" # """
self.cache = {} # self.cache = {}

View File

@ -545,8 +545,8 @@ class SlideController(QtGui.QWidget):
self.PreviewListWidget.setCursor(QtCore.Qt.PointingHandCursor) self.PreviewListWidget.setCursor(QtCore.Qt.PointingHandCursor)
before = time.time() before = time.time()
#Clear the old serviceItem cache to release memory #Clear the old serviceItem cache to release memory
if self.serviceItem and self.serviceItem is not serviceItem: # if self.serviceItem and self.serviceItem is not serviceItem:
self.serviceItem.clear_cache() # self.serviceItem.clear_cache()
self.serviceItem = serviceItem self.serviceItem = serviceItem
self.PreviewListWidget.clear() self.PreviewListWidget.clear()
self.PreviewListWidget.setRowCount(0) self.PreviewListWidget.setRowCount(0)