← Back to team overview

openlp-core team mailing list archive

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

 

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

Requested reviews:
  OpenLP Core (openlp-core)
Related bugs:
  Bug #774853 in OpenLP: "Color formatting tag displays incorrect color"
  https://bugs.launchpad.net/openlp/+bug/774853

For more details, see:
https://code.launchpad.net/~trb143/openlp/b1/+merge/59646

For review only but to should my direction.
-- 
https://code.launchpad.net/~trb143/openlp/b1/+merge/59646
Your team OpenLP Core is requested to review the proposed merge of lp:~trb143/openlp/b1 into lp:openlp.
=== modified file 'openlp/core/lib/__init__.py'
--- openlp/core/lib/__init__.py	2011-05-01 15:15:08 +0000
+++ openlp/core/lib/__init__.py	2011-05-02 08:31:01 +0000
@@ -169,8 +169,7 @@
 
 def image_to_byte(image):
     """
-    Resize an image to fit on the current screen for the web and returns
-    it as a byte stream.
+    Convert an Image to a Base64 array.
 
     ``image``
         The image to converted.
@@ -273,6 +272,20 @@
     except IOError:
         pass
 
+def generate_hash_for_file(full_path, filename):
+    """
+    Convert a file path into a hash with correct file type
+
+    ``full_path``
+        Path to the file including the file name
+
+    ``filename``
+        The name of the file.
+    """
+    file_type = os.path.splitext(filename)[1]
+    hash_name = unicode(abs(hash(unicode(full_path))))
+    return u'%s%s' %(hash_name, file_type)
+
 from listwidgetwithdnd import ListWidgetWithDnD
 from displaytags import DisplayTags
 from eventreceiver import Receiver

=== modified file 'openlp/plugins/images/lib/mediaitem.py'
--- openlp/plugins/images/lib/mediaitem.py	2011-04-30 17:36:13 +0000
+++ openlp/plugins/images/lib/mediaitem.py	2011-05-02 08:31:01 +0000
@@ -31,7 +31,7 @@
 
 from openlp.core.lib import MediaManagerItem, build_icon, ItemCapabilities, \
     SettingsManager, translate, check_item_selected, check_directory_exists, \
-    Receiver
+    Receiver, generate_hash_for_file
 from openlp.core.lib.ui import UiStrings, critical_error_message_box
 from openlp.core.utils import AppLocation, delete_file, get_images_filter
 
@@ -109,22 +109,23 @@
 
     def loadList(self, list, initialLoad=False):
         if not initialLoad:
-            self.parent.formparent.displayProgressBar(len(list))
-        for imageFile in list:
+            self.parent.formparent.displayProgressBar(len(file_list))
+        for image_file in file_list:
             if not initialLoad:
                 self.parent.formparent.incrementProgressBar()
-            filename = os.path.split(unicode(imageFile))[1]
-            thumb = os.path.join(self.servicePath, filename)
+            filename = os.path.split(unicode(image_file))[1]
+            thumb_file = generate_hash_for_file(image_file, filename)
+            thumb = os.path.join(self.servicePath, thumb_file)
             if os.path.exists(thumb):
-                if self.validate(imageFile, thumb):
+                if self.validate(image_file, thumb):
                     icon = build_icon(thumb)
                 else:
                     icon = build_icon(u':/general/general_delete.png')
             else:
-                icon = self.iconFromFile(imageFile, thumb)
+                icon = self.iconFromFile(image_file, thumb)
             item_name = QtGui.QListWidgetItem(filename)
             item_name.setIcon(icon)
-            item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(imageFile))
+            item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(image_file))
             self.listView.addItem(item_name)
         if not initialLoad:
             self.parent.formparent.finishedProgressBar()


Follow ups