bzr-revno: 863
This commit is contained in:
Raoul Snyman 2010-06-20 14:37:22 +02:00
commit 068cb0ff8b
3 changed files with 13 additions and 9 deletions

View File

@ -90,7 +90,7 @@ class ServiceItem(object):
self.from_plugin = False
self.capabilities = []
self.is_valid = True
self.cache = []
self.cache = {}
self.icon = None
def add_capability(self, capability):
@ -129,7 +129,7 @@ class ServiceItem(object):
"""
log.debug(u'Render called')
self._display_frames = []
self.cache = []
self.clear_cache()
if self.service_item_type == ServiceItemType.Text:
log.debug(u'Formatting slides')
if self.theme is None:
@ -149,7 +149,8 @@ class ServiceItem(object):
self._display_frames.append({u'title': title,
u'text': lines.rstrip(),
u'verseTag': slide[u'verseTag'] })
self.cache.insert(len(self._display_frames), None)
if len(self._display_frames) in self.cache.keys():
del self.cache[len(self._display_frames)]
log.log(15, u'Formatting took %4s' % (time.time() - before))
elif self.service_item_type == ServiceItemType.Image:
for slide in self._raw_frames:
@ -172,8 +173,7 @@ class ServiceItem(object):
else:
self.render_manager.set_override_theme(self.theme)
format = self._display_frames[row][u'text'].split(u'\n')
#if screen blank then do not display footer
if len(self.cache) > 0 and self.cache[row] is not None:
if self.cache.get(row):
frame = self.cache[row]
else:
if format[0]:
@ -385,3 +385,8 @@ class ServiceItem(object):
"""
return self._raw_frames[row][u'path']
def clear_cache(self):
"""
Clear's the service item's cache.
"""
self.cache = {}

View File

@ -661,8 +661,7 @@ class ServiceManager(QtGui.QWidget):
filename = unicode(filename)
name = filename.split(os.path.sep)
if filename:
SettingsManager.set_last_dir(
self.parent.serviceSettingsSection,
SettingsManager.set_last_dir(self.parent.serviceSettingsSection,
os.path.split(filename)[0])
zip = None
file_to = None
@ -697,7 +696,7 @@ class ServiceManager(QtGui.QWidget):
self.onNewService()
for item in items:
serviceitem = ServiceItem()
serviceitem.RenderManager = self.parent.RenderManager
serviceitem.render_manager = self.parent.RenderManager
serviceitem.set_from_service(item, self.servicePath)
self.validateItem(serviceitem)
self.addServiceItem(serviceitem)

View File

@ -537,7 +537,7 @@ class SlideController(QtGui.QWidget):
before = time.time()
#Clear the old serviceItem cache to release memory
if self.serviceItem and self.serviceItem is not serviceItem:
self.serviceItem.cache = []
self.serviceItem.clear_cache()
self.serviceItem = serviceItem
self.PreviewListWidget.clear()
self.PreviewListWidget.setRowCount(0)