← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~trb143/openlp/servicing2 into lp:openlp

 

Tim Bentley has proposed merging lp:~trb143/openlp/servicing2 into lp:openlp.

Requested reviews:
    openlp.org Core (openlp-core)

Complete OOS for Songs, Bibles, Images, Custom.
Fix unicode bugs in Bibles.
Clean Up image plugin.
-- 
https://code.launchpad.net/~trb143/openlp/servicing2/+merge/7726
Your team openlp.org Core is subscribed to branch lp:openlp.
=== modified file 'openlp.pyw'
--- openlp.pyw	2009-06-07 19:34:24 +0000
+++ openlp.pyw	2009-06-20 10:44:12 +0000
@@ -26,7 +26,7 @@
 from openlp.core.lib import Receiver
 
 logging.basicConfig(level=logging.DEBUG,
-    format=u'%(asctime)s %(msecs)d %(name)-12s %(levelname)-8s %(message)s',
+    format=u'%(asctime)s:%(msecs)3d %(name)-15s %(levelname)-8s %(message)s',
     datefmt=u'%m-%d %H:%M:%S', filename=u'openlp.log', filemode=u'w')
 
 from openlp.core.resources import *

=== modified file 'openlp/core/lib/renderer.py'
--- openlp/core/lib/renderer.py	2009-06-19 18:41:38 +0000
+++ openlp/core/lib/renderer.py	2009-06-20 10:44:12 +0000
@@ -136,8 +136,6 @@
         if footer_lines is not None:
             bbox1 = self._render_lines_unaligned(footer_lines, True)
         # reset the frame. first time do not worry about what you paint on.
-        #self._frame = QtGui.QPixmap(self._frame.width(), self._frame.height()) #(self._bg_frame)
-        #self._frame.fill(QtCore.Qt.transparent)
         # reset the frame. first time do not worry about what you paint on.
         self._frame = QtGui.QImage(self._bg_frame)
         x, y = self._correctAlignment(self._rect, bbox)
@@ -445,4 +443,4 @@
         im.save(u'renderer.png', u'png')
         if image2 is not None:
             im = image2.toImage()
-            im.save(u'renderer2.png', u'png')
\ No newline at end of file
+            im.save(u'renderer2.png', u'png')

=== modified file 'openlp/core/lib/rendermanager.py'
--- openlp/core/lib/rendermanager.py	2009-06-19 18:41:38 +0000
+++ openlp/core/lib/rendermanager.py	2009-06-20 11:23:34 +0000
@@ -139,10 +139,24 @@
         self.renderer.set_frame_dest(self.width, self.height)
         return self.renderer.generate_frame_from_lines(main_text, footer_text)
 
+    def resize_image(self, image):
+        preview = QtGui.QImage(image)
+        w = self.width
+        h = self.height
+        preview = preview.scaled(w, h, QtCore.Qt.KeepAspectRatio, QtCore.Qt.SmoothTransformation)
+        realw = preview.width();
+        realh = preview.height()
+        # and move it to the centre of the preview space
+        newImage = QtGui.QImage(w, h, QtGui.QImage.Format_ARGB32_Premultiplied)
+        newImage.fill(QtCore.Qt.transparent)
+        painter = QtGui.QPainter(newImage)
+        painter.drawImage((w-realw) / 2 , (h-realh) / 2, preview)
+        return newImage
+
     def calculate_default(self, screen):
         log.debug(u'calculate default %s' , screen)
         self.width = screen.width()
         self.height = screen.height()
         log.debug(u'calculate default %d,%d' , self.width, self.height)
         # 90% is start of footer
-        self.footer_start = int(self.height*0.90)
+        self.footer_start = int(self.height * 0.90)

=== modified file 'openlp/core/lib/serviceitem.py'
--- openlp/core/lib/serviceitem.py	2009-06-10 15:54:46 +0000
+++ openlp/core/lib/serviceitem.py	2009-06-20 19:11:17 +0000
@@ -18,6 +18,7 @@
 Place, Suite 330, Boston, MA 02111-1307 USA
 """
 import logging
+import os
 import time
 from openlp.core.lib import buildIcon
 from PyQt4 import QtCore, QtGui
@@ -49,6 +50,8 @@
         self.frames = []
         self.raw_footer = None
         self.theme = None
+        self.service_item_path = None
+        self.service_item_type = None
         #log.debug(u'Service item created for %s ', self.shortname)
         self.service_frames = []
 
@@ -77,13 +80,18 @@
             self.frames = self.service_frames
             self.service_frames = []
         elif self.service_item_type == u'image':
+            #print "image"
+            #print self.service_frames
+            for slide in self.service_frames:
+                slide[u'image'] = self.RenderManager.resize_image(slide[u'image'])
             self.frames = self.service_frames
-            self.service_frames = []
+            #self.service_frames = []
         else:
             log.error(u'Invalid value renderer :%s' % self.service_item_type)
 
-    def add_from_image(self, frame_title, image):
+    def add_from_image(self, path,  frame_title, image):
         self.service_item_type = u'image'
+        self.service_item_path = path
         self.service_frames.append({u'title': frame_title, u'image': image})
 
     def add_from_text(self, frame_title, raw_slide):
@@ -105,14 +113,21 @@
         oos_data = []
         if self.service_item_type == u'text':
             for slide in self.service_frames:
-                oos_data.append(slide[u'raw_slide'])
-        return {u'header': oos_header, u'data': self.service_frames}
+                oos_data.append(slide)
+        elif self.service_item_type == u'image':
+            #print "sf", self.service_frames
+            for slide in self.service_frames:
+                #print "s", slide
+                oos_data.append(slide[u'title'])
+        #print "od", oos_data
+        return {u'header': oos_header, u'data': oos_data}
 
-    def set_from_oos(self, serviceitem):
-        """
-        This method takes some oostext (passed from the ServiceManager)
-        and parses it into the data actually required
-        """
+    def set_from_oos(self, serviceitem, path=None):
+        """
+        This method takes some oos list (passed from the ServiceManager)
+        and extracts the data actually required
+        """
+        #print "sfs", serviceitem
         header = serviceitem[u'serviceitem'][u'header']
         self.title = header[u'title']
         self.service_item_type = header[u'type']
@@ -120,4 +135,12 @@
         self.theme = header[u'theme']
         self.addIcon(header[u'icon'])
         self.raw_footer = header[u'footer']
-        self.service_frames = serviceitem[u'serviceitem'][u'data']
+        if self.service_item_type == u'text':
+            for slide in serviceitem[u'serviceitem'][u'data']:
+                self.service_frames.append(slide)
+        elif self.service_item_type == u'image':
+            for text_image in serviceitem[u'serviceitem'][u'data']:
+                filename = os.path.join(path, text_image)
+                #print "fn",  filename
+                real_image = QtGui.QImage(unicode(filename))
+                self.add_from_image(path, text_image, real_image)

=== modified file 'openlp/core/ui/mainwindow.py'
--- openlp/core/ui/mainwindow.py	2009-06-11 05:13:10 +0000
+++ openlp/core/ui/mainwindow.py	2009-06-20 07:08:17 +0000
@@ -64,6 +64,7 @@
         self.RenderManager = RenderManager(self.ThemeManagerContents,
             self.screenList, int(self.generalConfig.get_config(u'Monitor', 0)))
         log.info(u'Load Plugins')
+        #make the controllers available to the plugins
         self.plugin_helpers[u'preview'] = self.PreviewController
         self.plugin_helpers[u'live'] = self.LiveController
         self.plugin_helpers[u'event'] = self.EventManager
@@ -74,7 +75,7 @@
         self.plugin_manager.find_plugins(pluginpath, self.plugin_helpers,
             self.EventManager)
         # hook methods have to happen after find_plugins. Find plugins needs the
-        # controllershence the hooks have moved from setupUI() to here
+        # controllers hence the hooks have moved from setupUI() to here
 
         # Find and insert settings tabs
         log.info(u'hook settings')
@@ -378,6 +379,10 @@
         # Connect up some signals and slots
         QtCore.QObject.connect(self.FileExitItem,
             QtCore.SIGNAL(u'triggered()'), self.mainWindow.close)
+        QtCore.QObject.connect(self.ImportThemeItem,
+            QtCore.SIGNAL(u'triggered()'), self.ThemeManagerContents.onImportTheme)
+        QtCore.QObject.connect(self.ExportThemeItem,
+            QtCore.SIGNAL(u'triggered()'), self.ThemeManagerContents.onExportTheme)
         QtCore.QObject.connect(self.ViewMediaManagerItem,
             QtCore.SIGNAL(u'triggered(bool)'), self.MediaManagerDock.setVisible)
         QtCore.QObject.connect(self.ViewServiceManagerItem,

=== modified file 'openlp/core/ui/servicemanager.py'
--- openlp/core/ui/servicemanager.py	2009-06-19 18:41:38 +0000
+++ openlp/core/ui/servicemanager.py	2009-06-20 19:11:17 +0000
@@ -20,11 +20,14 @@
 import os
 import logging
 import cPickle
+import zipfile
+import shutil
 
 from PyQt4 import QtCore, QtGui
 from openlp.core.lib import PluginConfig, OpenLPToolbar, ServiceItem, Event, \
     RenderManager, EventType, EventManager, translate, buildIcon, \
     contextMenuAction, contextMenuSeparator
+from openlp.core.utils import ConfigHelper
 
 class ServiceManager(QtGui.QWidget):
     """
@@ -105,10 +108,23 @@
             QtCore.SIGNAL(u'activated(int)'), self.onThemeComboBoxSelected)
         QtCore.QObject.connect(self.ServiceManagerList,
            QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.makeLive)
+        QtCore.QObject.connect(self.ServiceManagerList,
+           QtCore.SIGNAL(u'itemCollapsed(QTreeWidgetItem*)'), self.collapsed)
+        QtCore.QObject.connect(self.ServiceManagerList,
+           QtCore.SIGNAL(u'itemExpanded(QTreeWidgetItem*)'), self.expanded)
         # Last little bits of setting up
-        self.config = PluginConfig(u'Main')
+        self.config = PluginConfig(u'ServiceManager')
+        self.servicePath = self.config.get_data_path()
         self.service_theme = self.config.get_config(u'theme service theme', u'')
 
+    def collapsed(self, item):
+        pos = item.data(0, QtCore.Qt.UserRole).toInt()[0]
+        self.serviceItems[pos -1 ][u'expanded'] = False
+
+    def expanded(self, item):
+        pos = item.data(0, QtCore.Qt.UserRole).toInt()[0]
+        self.serviceItems[pos -1 ][u'expanded'] = True
+
     def onServiceTop(self):
         """
         Move the current ServiceItem to the top of the list
@@ -185,6 +201,7 @@
             treewidgetitem.setText(0,serviceitem.title)
             treewidgetitem.setIcon(0,serviceitem.iconic_representation)
             treewidgetitem.setData(0, QtCore.Qt.UserRole, QtCore.QVariant(item[u'order']))
+            treewidgetitem.setExpanded(item[u'expanded'])
             count = 0
             for frame in serviceitem.frames:
                 treewidgetitem1 = QtGui.QTreeWidgetItem(treewidgetitem)
@@ -198,15 +215,27 @@
         Save the current service
         """
         filename = QtGui.QFileDialog.getSaveFileName(self, u'Save Order of Service',self.config.get_last_dir() )
+        filename = unicode(filename)
         if filename != u'':
             self.config.set_last_dir(filename)
-            print filename
             service = []
+            servicefile= filename + u'.ood'
+            zip = zipfile.ZipFile(unicode(filename) + u'.oos', 'w')
             for item in self.serviceItems:
                 service.append({u'serviceitem':item[u'data'].get_oos_repr()})
-            file = open(filename+u'.oos', u'wb')
+                if item[u'data'].service_item_type == u'image':
+                    for frame in item[u'data'].frames:
+                        path_from = unicode(item[u'data'].service_item_path + u'/' + frame[u'title'])
+                        zip.write(path_from)
+            file = open(servicefile, u'wb')
             cPickle.dump(service, file)
             file.close()
+            zip.write(servicefile)
+            zip.close()
+            try:
+                os.remove(servicefile)
+            except:
+                pass #if not present do not worry
 
     def onLoadService(self):
         """
@@ -214,17 +243,35 @@
         """
         filename = QtGui.QFileDialog.getOpenFileName(self, u'Open Order of Service',self.config.get_last_dir(),
             u'Services (*.oos)')
+        filename = unicode(filename)
         if filename != u'':
             self.config.set_last_dir(filename)
-            file = open(filename, u'r')
-            items = cPickle.load(file)
-            file.close()
+            zip = zipfile.ZipFile(unicode(filename))
+            filexml = None
+            themename = None
+            for file in zip.namelist():
+                names = file.split(os.path.sep)
+                file_to = os.path.join(self.servicePath, names[len(names) - 1])
+                file_data = zip.read(file)
+                f = open(file_to, u'w')
+                f.write(file_data)
+                f.close()
+                if file_to.endswith(u'ood'):
+                    p_file = file_to
+            f = open(p_file, u'r')
+            items = cPickle.load(f)
+            f.close()
             self.onNewService()
             for item in items:
+                #print item
                 serviceitem = ServiceItem()
                 serviceitem.RenderManager = self.parent.RenderManager
-                serviceitem.set_from_oos(item)
+                serviceitem.set_from_oos(item, self.servicePath )
                 self.addServiceItem(serviceitem)
+            try:
+                os.remove(p_file)
+            except:
+                pass #if not present do not worry
 
     def onThemeComboBoxSelected(self, currentIndex):
         """
@@ -239,16 +286,16 @@
             for item in tempServiceItems:
                 self.addServiceItem(item[u'data'])
 
-    def addServiceItem(self, item, expand=True):
+    def addServiceItem(self, item):
         """
         Add an item to the list
         """
-        self.serviceItems.append({u'data': item, u'order': len(self.serviceItems)+1})
+        self.serviceItems.append({u'data': item, u'order': len(self.serviceItems)+1, u'expanded':True})
         treewidgetitem = QtGui.QTreeWidgetItem(self.ServiceManagerList)
         treewidgetitem.setText(0,item.title)
         treewidgetitem.setIcon(0,item.iconic_representation)
         treewidgetitem.setData(0, QtCore.Qt.UserRole, QtCore.QVariant(len(self.serviceItems)))
-        treewidgetitem.setExpanded(expand)
+        treewidgetitem.setExpanded(True)
         item.render()
         count = 0
         for frame in item.frames:

=== modified file 'openlp/core/ui/slidecontroller.py'
--- openlp/core/ui/slidecontroller.py	2009-06-16 18:21:24 +0000
+++ openlp/core/ui/slidecontroller.py	2009-06-20 10:44:12 +0000
@@ -137,8 +137,9 @@
         self.PreviewListView.setIconSize(QtCore.QSize(250, 190))
         self.PreviewListData = SlideData()
         self.PreviewListView.isLive = self.isLive
-        #self.PreviewListView.setFlow(1)
-        #self.PreviewListView.setViewMode(1)
+        if QtCore.QT_VERSION_STR > u'4.4.0':
+            self.PreviewListView.setFlow(1)
+            self.PreviewListView.setViewMode(1)
         self.PreviewListView.setWrapping(False)
         self.PreviewListView.setModel(self.PreviewListData)
         self.PreviewListView.setSpacing(0)
@@ -321,4 +322,4 @@
         if row.isValid():
             self.PreviewListView.selectionModel().setCurrentIndex(row,
                 QtGui.QItemSelectionModel.SelectCurrent)
-            self.onSlideSelected(row)
\ No newline at end of file
+            self.onSlideSelected(row)

=== modified file 'openlp/core/ui/thememanager.py'
--- openlp/core/ui/thememanager.py	2009-06-16 18:21:24 +0000
+++ openlp/core/ui/thememanager.py	2009-06-20 19:11:17 +0000
@@ -40,7 +40,7 @@
     Root contains a list of ThemeItems
     """
     global log
-    log=logging.getLogger(u'ThemeData')
+    log = logging.getLogger(u'ThemeData')
 
     def __init__(self):
         QtCore.QAbstractListModel.__init__(self)
@@ -200,7 +200,7 @@
 
     def onImportTheme(self):
         files = QtGui.QFileDialog.getOpenFileNames(None,
-            translate(u'ThemeManager', u'Select Import File'),
+            translate(u'ThemeManager', u'Select Theme Import File'),
             self.path, u'Theme (*.theme)')
         log.info(u'New Themes %s', unicode(files))
         if len(files) > 0:
@@ -335,7 +335,7 @@
         outfile = open(theme_file, u'w')
         outfile.write(theme_xml)
         outfile.close()
-        if image_from is not None and image_from != image_to:
+        if image_from is not None and image_from is not image_to:
             shutil.copyfile(image_from,  image_to)
         self.generateAndSaveImage(self.path, name, theme_xml)
         self.themeData.clearItems()
@@ -362,4 +362,4 @@
     def getPreviewImage(self, theme):
         log.debug(u'getPreviewImage %s ', theme)
         image = os.path.join(self.path, theme + u'.png')
-        return image
\ No newline at end of file
+        return image

=== modified file 'openlp/plugins/bibles/bibleplugin.py'
--- openlp/plugins/bibles/bibleplugin.py	2009-06-16 18:21:24 +0000
+++ openlp/plugins/bibles/bibleplugin.py	2009-06-19 19:49:00 +0000
@@ -25,8 +25,6 @@
 from openlp.core.lib import Plugin, Event,  EventType,  translate
 
 from openlp.plugins.bibles.lib import BibleManager, BiblesTab, BibleMediaItem
-from openlp.plugins.bibles.lib.tables import *
-from openlp.plugins.bibles.lib.classes import *
 
 class BiblePlugin(Plugin):
     global log
@@ -71,9 +69,7 @@
         pass
 
     def onBibleNewClick(self):
-        self.bibleimportform = BibleImportForm(self.config, self.biblemanager, self)
-        self.bibleimportform.exec_()
-        pass
+        self.media_item.onBibleNewClick()
 
     def handle_event(self, event):
         """

=== modified file 'openlp/plugins/bibles/forms/bibleimportdialog.py'
--- openlp/plugins/bibles/forms/bibleimportdialog.py	2009-06-16 18:21:24 +0000
+++ openlp/plugins/bibles/forms/bibleimportdialog.py	2009-06-19 19:49:00 +0000
@@ -8,6 +8,7 @@
 # WARNING! All changes made in this file will be lost!
 
 from PyQt4 import QtCore, QtGui
+from openlp.core.lib import translate
 
 class Ui_BibleImportDialog(object):
     def setupUi(self, BibleImportDialog):

=== modified file 'openlp/plugins/bibles/lib/bibleHTTPimpl.py'
--- openlp/plugins/bibles/lib/bibleHTTPimpl.py	2009-06-16 18:21:24 +0000
+++ openlp/plugins/bibles/lib/bibleHTTPimpl.py	2009-06-20 19:11:17 +0000
@@ -44,7 +44,7 @@
         log.debug( u'get_bible_chapter %s,%s,%s,%s', version, bookid, bookname,  chapter)
         urlstring = u'http://www.biblegateway.com/passage/?book_id='+unicode(bookid)+u'&chapter'+unicode(chapter)+u'&version='+unicode(version)
         xml_string = self._get_web_text(urlstring, self.proxyurl)
-        print xml_string
+        #print xml_string
         VerseSearch = u'class='+u'"'+u'sup'+u'"'+u'>'
         verse = 1
         i= xml_string.find(u'result-text-style-normal')
@@ -97,7 +97,7 @@
         """
         log.debug(u'get_bible_chapter %s,%s,%s,%s', version, bookid, bookname,  chapter)
         bookname = bookname.replace(u' ', '')
-        urlstring = "http://bible.crosswalk.com/OnlineStudyBible/bible.cgi?word="+bookname+"+"+unicode(chapter)+"&version="+version
+        urlstring = u'http://bible.crosswalk.com/OnlineStudyBible/bible.cgi?word='+bookname+u'+'+unicode(chapter)+u'&version='+version
         xml_string = self._get_web_text(urlstring, self.proxyurl)
         #log.debug(u'Return data %s', xml_string)
         ## Strip Book Title from Heading to return it to system
@@ -115,27 +115,33 @@
 
         ## Strip Verse Data from Page and build an array
         ##
+        #log.debug(u'bible data %s', xml_string)
         i= xml_string.find(u'NavCurrentChapter')
         xml_string = xml_string[i:len(xml_string)]
         i= xml_string.find(u'<TABLE')
         xml_string = xml_string[i:len(xml_string)]
         i= xml_string.find(u'<B>')
-        xml_string = xml_string[i + 3 :len(xml_string)] #remove the <B> at the front
-        i= xml_string.find(u'<B>') # Remove the heading for the book
-        xml_string = xml_string[i + 3 :len(xml_string)] #remove the <B> at the front
+        #remove the <B> at the front
+        xml_string = xml_string[i + 3 :len(xml_string)]
+        # Remove the heading for the book
+        i= xml_string.find(u'<B>')
+        #remove the <B> at the front
+        xml_string = xml_string[i + 3 :len(xml_string)]
         versePos = xml_string.find(u'<BLOCKQUOTE>')
-        #log.debug( versePos)
+        #log.debug(u'verse pos %d',  versePos)
         bible = {}
         while versePos > 0:
-            verseText = '' # clear out string
+            verseText = u''
             versePos = xml_string.find(u'<B><I>', versePos) + 6
             i = xml_string.find(u'</I></B>', versePos)
             #log.debug( versePos, i)
             verse= xml_string[versePos:i] # Got the Chapter
             #verse = int(temp)
-            #log.debug( 'Chapter = ' + unicode(temp))
-            versePos = i + 8     # move the starting position to negining of the text
-            i = xml_string.find(u'<B><I>', versePos) # fine the start of the next verse
+            #log.debug( 'Chapter = %s', verse)
+            # move the starting position to begining of the text
+            versePos = i + 8
+            # fined the start of the next verse
+            i = xml_string.find(u'<B><I>', versePos)
             if i == -1:
                 i = xml_string.find(u'</BLOCKQUOTE>',versePos)
                 verseText = xml_string[versePos: i]

=== modified file 'openlp/plugins/bibles/lib/common.py'
--- openlp/plugins/bibles/lib/common.py	2009-06-16 18:21:24 +0000
+++ openlp/plugins/bibles/lib/common.py	2009-06-20 19:11:17 +0000
@@ -53,12 +53,12 @@
             http_support = urllib2.HTTPHandler()
             opener= urllib2.build_opener(proxy_support, http_support)
             urllib2.install_opener(opener)
-        xml_string = ""
+        xml_string = u''
         req = urllib2.Request(urlstring)
         req.add_header(u'User-Agent', 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)')
         try:
             handle = urllib2.urlopen(req)
-            xml_string = handle.read()
+            xml_string = unicode(handle.read())
         except IOError, e:
             if hasattr(e, u'reason'):
                 log.error(u'Reason : ')
@@ -97,9 +97,9 @@
         text= text.replace(u'</P>', u'')
         text= text.replace(u'<BR>', u'')
         text= text.replace(u'<BR />', u'')
-        text= text.replace(chr(189), u'1/2')
-        text= text.replace(u'&quot;", u''')
-        text= text.replace(u'&apos;", u''')
+        #text= text.replace(chr(189), u'1/2');print "l"
+        text= text.replace(u'&quot;', "'")
+        text= text.replace(u'&apos;', "'")
 
         i = text.find(u'<')
         while i > -1 :

=== modified file 'openlp/plugins/bibles/lib/manager.py'
--- openlp/plugins/bibles/lib/manager.py	2009-06-16 18:21:24 +0000
+++ openlp/plugins/bibles/lib/manager.py	2009-06-20 19:11:17 +0000
@@ -239,17 +239,19 @@
         text  = []
         log.debug(u'get_verse_text %s,%s,%s,%s,%s,%s',  bible, bookname,  schapter, echapter, sverse, everse)
         if not self.bible_http_cache [bible] == None:
-            book= self.bible_db_cache[bible].get_bible_book(bookname) # check to see if book/chapter exists
+            # check to see if book/chapter exists
+            book= self.bible_db_cache[bible].get_bible_book(bookname)
             if book == None:
                 log.debug(u'get_verse_text : new book')
                 for chapter in range(schapter, echapter+1):
                     search_results = self.bible_http_cache [bible].get_bible_chapter(bible, 0, bookname, chapter)
-                    if search_results.has_verselist() :
+                    if search_results.has_verse_list() :
                         ## We have found a book of the bible lets check to see if it was there.
                         ## By reusing the returned book name we get a correct book.
                         ## For example it is possible to request ac and get Acts back.
                         bookname = search_results.get_book()
-                        book= self.bible_db_cache[bible].get_bible_book(bookname) # check to see if book/chapter exists
+                        # check to see if book/chapter exists
+                        book= self.bible_db_cache[bible].get_bible_book(bookname)
                         if book == None:
                             ## Then create book, chapter and text
                             book = self.bible_db_cache[bible].create_book(bookname, \

=== modified file 'openlp/plugins/images/__init__.py'
--- openlp/plugins/images/__init__.py	2009-05-11 05:09:43 +0000
+++ openlp/plugins/images/__init__.py	2009-06-20 10:44:12 +0000
@@ -3,7 +3,7 @@
 """
 OpenLP - Open Source Lyrics Projection
 Copyright (c) 2008 - 2009 Raoul Snyman
-Portions copyright (c) 2008 Martin Thompson, Tim Bentley,
+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
@@ -17,7 +17,3 @@
 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
 Place, Suite 330, Boston, MA 02111-1307 USA
 """
-
-#from imageplugin import ImagePlugin
-#from imageserviceitem import ImageServiceItem
-

=== modified file 'openlp/plugins/images/imageplugin.py'
--- openlp/plugins/images/imageplugin.py	2009-05-21 16:07:01 +0000
+++ openlp/plugins/images/imageplugin.py	2009-06-20 10:44:12 +0000
@@ -3,7 +3,7 @@
 """
 OpenLP - Open Source Lyrics Projection
 Copyright (c) 2008 Raoul Snyman
-Portions copyright (c) 2008 Martin Thompson, Tim Bentley,
+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
@@ -22,7 +22,7 @@
 from PyQt4 import QtCore, QtGui
 
 from openlp.core.lib import Plugin, Event,  EventType
-from openlp.plugins.images.lib import ImageMediaItem, ImageServiceItem
+from openlp.plugins.images.lib import ImageMediaItem
 
 class ImagePlugin(Plugin):
     global log
@@ -38,9 +38,6 @@
         self.icon.addPixmap(QtGui.QPixmap(u':/media/media_image.png'),
             QtGui.QIcon.Normal, QtGui.QIcon.Off)
 
-        self.preview_service_item = ImageServiceItem(self.preview_controller)
-        self.live_service_item = ImageServiceItem(self.live_controller)
-
     def get_media_manager_item(self):
         # Create the MediaManagerItem object
         self.media_item = ImageMediaItem(self, self.icon, u'Images')
@@ -63,5 +60,3 @@
         if event.event_type == EventType.LiveShow and event.payload == 'Image':
             log.debug(u'Load Live Show Item received')
             self.media_item.onImageLiveClick()
-
-

=== modified file 'openlp/plugins/images/lib/__init__.py'
--- openlp/plugins/images/lib/__init__.py	2009-03-24 06:07:03 +0000
+++ openlp/plugins/images/lib/__init__.py	2009-06-20 10:44:12 +0000
@@ -3,7 +3,7 @@
 """
 OpenLP - Open Source Lyrics Projection
 Copyright (c) 2008 - 2009 Raoul Snyman
-Portions copyright (c) 2008 Martin Thompson, Tim Bentley,
+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
@@ -18,5 +18,4 @@
 Place, Suite 330, Boston, MA 02111-1307 USA
 """
 from listwithpreviews import ListWithPreviews
-from imageserviceitem import ImageServiceItem
 from mediaitem import ImageMediaItem

=== modified file 'openlp/plugins/images/lib/listwithpreviews.py'
--- openlp/plugins/images/lib/listwithpreviews.py	2009-06-19 18:41:38 +0000
+++ openlp/plugins/images/lib/listwithpreviews.py	2009-06-20 10:44:12 +0000
@@ -5,7 +5,7 @@
 Copyright (c) 2008 Raoul Snyman
 Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley
 
-This program is free software; you can rediunicodeibute it and/or modify it under
+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.
 
@@ -34,34 +34,35 @@
         # will be a list of (full filename, QPixmap, shortname) tuples
         self.items = []
         self.rowheight = 50
-        self.maximagewidth = self.rowheight*16/9.0;
+        self.maximagewidth = self.rowheight * 16 / 9.0;
 
     def rowCount(self, parent):
         return len(self.items)
 
     def insertRow(self, row, filename):
-        self.beginInsertRows(QtCore.QModelIndex(),row,row)
+        self.beginInsertRows(QtCore.QModelIndex(), row, row)
         #log.info(u'insert row %d:%s' % (row,filename))
         # get short filename to display next to image
-        (prefix, shortfilename) = os.path.split(unicode(filename))
+        filename = unicode(filename)
+        (prefix, shortfilename) = os.path.split(filename)
         #log.info(u'shortfilename=%s' % (shortfilename))
         # create a preview image
         if os.path.exists(filename):
-            preview = QtGui.QPixmap(unicode(filename))
+            preview = QtGui.QImage(filename)
             w = self.maximagewidth;
             h = self.rowheight
             preview = preview.scaled(w, h, QtCore.Qt.KeepAspectRatio, QtCore.Qt.SmoothTransformation)
             realw = preview.width();
             realh = preview.height()
             # and move it to the centre of the preview space
-            p = QtGui.QPixmap(w,h)
+            p = QtGui.QImage(w, h, QtGui.QImage.Format_ARGB32_Premultiplied)
             p.fill(QtCore.Qt.transparent)
             painter = QtGui.QPainter(p)
-            painter.drawPixmap((w-realw)/2,(h-realh)/2,preview)
+            painter.drawImage((w-realw) / 2 , (h-realh) / 2, preview)
         else:
             w = self.maximagewidth;
             h = self.rowheight
-            p = QtGui.QPixmap(w,h)
+            p = QtGui.QImage(w, h, QtGui.QImage.Format_ARGB32_Premultiplied)
             p.fill(QtCore.Qt.transparent)
         # finally create the row
         self.items.insert(row, (filename, p, shortfilename))

=== modified file 'openlp/plugins/images/lib/mediaitem.py'
--- openlp/plugins/images/lib/mediaitem.py	2009-06-19 18:41:38 +0000
+++ openlp/plugins/images/lib/mediaitem.py	2009-06-20 10:44:12 +0000
@@ -51,7 +51,7 @@
     This is the custom media manager item for images.
     """
     global log
-    log=logging.getLogger(u'ImageMediaItem')
+    log = logging.getLogger(u'ImageMediaItem')
     log.info(u'Image Media Item loaded')
 
     def __init__(self, parent, icon, title):
@@ -95,7 +95,7 @@
         self.ImageListView.setModel(self.ImageListData)
         self.ImageListView.setGeometry(QtCore.QRect(10, 100, 256, 591))
         self.ImageListView.setSpacing(1)
-        self.ImageListView.setSelectionMode(QtGui.QAbstractItemView.MultiSelection)
+        self.ImageListView.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection)
         self.ImageListView.setAlternatingRowColors(True)
         self.ImageListView.setDragEnabled(True)
         self.ImageListView.setObjectName(u'ImageListView')
@@ -114,6 +114,8 @@
             self.ImageListView, ':/system/system_add.png',
             translate(u'ImageMediaItem', u'&Add to Service'),
             self.onImageAddClick))
+        QtCore.QObject.connect(self.ImageListView,
+           QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.onImagePreviewClick)
 
     def initialise(self):
         self.loadImageList(self.parent.config.load_list(u'images'))
@@ -143,12 +145,12 @@
 
     def generateSlideData(self, service_item):
         indexes = self.ImageListView.selectedIndexes()
-        service_item.title = u'Images'
+        service_item.title = u'Image(s)'
         for index in indexes:
             filename = self.ImageListData.getFilename(index)
-            frame = QtGui.QPixmap(unicode(filename))
-            (path, name) =os.path.split(filename)
-            service_item.add_from_image(name, frame)
+            frame = QtGui.QImage(unicode(filename))
+            (path, name) = os.path.split(filename)
+            service_item.add_from_image(path,  name, frame)
 
     def onImagePreviewClick(self):
         log.debug(u'Image Preview Requested')


Follow ups