← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~trb143/openlp/bug-1071893 into lp:openlp

 

Tim Bentley has proposed merging lp:~trb143/openlp/bug-1071893 into lp:openlp.

Requested reviews:
  OpenLP Core (openlp-core)
Related bugs:
  Bug #1071893 in OpenLP: "Media  and Presentation media managers do not show red crosses against missing files"
  https://bugs.launchpad.net/openlp/+bug/1071893

For more details, see:
https://code.launchpad.net/~trb143/openlp/bug-1071893/+merge/132838

Check the media files exist on load and set the icon correctly

-- 
https://code.launchpad.net/~trb143/openlp/bug-1071893/+merge/132838
Your team OpenLP Core is requested to review the proposed merge of lp:~trb143/openlp/bug-1071893 into lp:openlp.
=== modified file 'openlp/plugins/media/lib/mediaitem.py'
--- openlp/plugins/media/lib/mediaitem.py	2012-10-21 14:07:57 +0000
+++ openlp/plugins/media/lib/mediaitem.py	2012-11-05 06:09:21 +0000
@@ -47,6 +47,7 @@
 VIDEO = QtGui.QImage(u':/media/media_video.png')
 AUDIO = QtGui.QImage(u':/media/media_audio.png')
 DVD_ICON = QtGui.QImage(u':/media/media_video.png')
+ERROR = QtGui.QImage(u':/general/general_delete.png')
 
 class MediaMediaItem(MediaManagerItem):
     """
@@ -292,7 +293,12 @@
             key=lambda filename: os.path.split(unicode(filename))[1])
         for track in media:
             track_info = QtCore.QFileInfo(track)
-            if track_info.isFile():
+            if not os.path.exists(track):
+                filename = os.path.split(unicode(track))[1]
+                item_name = QtGui.QListWidgetItem(filename)
+                item_name.setIcon(build_icon(ERROR))
+                item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(track))
+            elif track_info.isFile():
                 filename = os.path.split(unicode(track))[1]
                 item_name = QtGui.QListWidgetItem(filename)
                 item_name.setIcon(build_icon(VIDEO))

=== modified file 'openlp/plugins/presentations/lib/mediaitem.py'
--- openlp/plugins/presentations/lib/mediaitem.py	2012-10-21 14:07:57 +0000
+++ openlp/plugins/presentations/lib/mediaitem.py	2012-11-05 06:09:21 +0000
@@ -43,6 +43,8 @@
 
 log = logging.getLogger(__name__)
 
+ERROR = QtGui.QImage(u':/general/general_delete.png')
+
 class PresentationMediaItem(MediaManagerItem):
     """
     This is the Presentation media manager item for Presentation Items.
@@ -180,44 +182,53 @@
             if currlist.count(file) > 0:
                 continue
             filename = os.path.split(unicode(file))[1]
-            if titles.count(filename) > 0:
-                if not initialLoad:
-                    critical_error_message_box(
-                        translate('PresentationPlugin.MediaItem',
-                        'File Exists'),
-                        translate('PresentationPlugin.MediaItem',
-                        'A presentation with that filename already exists.'))
-                continue
-            controller_name = self.findControllerByType(filename)
-            if controller_name:
-                controller = self.controllers[controller_name]
-                doc = controller.add_document(unicode(file))
-                thumb = os.path.join(doc.get_thumbnail_folder(), u'icon.png')
-                preview = doc.get_thumbnail_path(1, True)
-                if not preview and not initialLoad:
-                    doc.load_presentation()
+            if not os.path.exists(file):
+                item_name = QtGui.QListWidgetItem(filename)
+                item_name.setIcon(build_icon(ERROR))
+                item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(file))
+                item_name.setToolTip(file)
+                self.listView.addItem(item_name)
+            else:
+                if titles.count(filename) > 0:
+                    if not initialLoad:
+                        critical_error_message_box(
+                            translate('PresentationPlugin.MediaItem',
+                            'File Exists'),
+                            translate('PresentationPlugin.MediaItem',
+                            'A presentation with that filename already exists.')
+                            )
+                    continue
+                controller_name = self.findControllerByType(filename)
+                if controller_name:
+                    controller = self.controllers[controller_name]
+                    doc = controller.add_document(unicode(file))
+                    thumb = os.path.join(doc.get_thumbnail_folder(),
+                        u'icon.png')
                     preview = doc.get_thumbnail_path(1, True)
-                doc.close_presentation()
-                if not (preview and os.path.exists(preview)):
-                    icon = build_icon(u':/general/general_delete.png')
-                else:
-                    if validate_thumb(preview, thumb):
-                        icon = build_icon(thumb)
-                    else:
-                        icon = create_thumb(preview, thumb)
-            else:
-                if initialLoad:
-                    icon = build_icon(u':/general/general_delete.png')
-                else:
-                    critical_error_message_box(UiStrings().UnsupportedFile,
-                        translate('PresentationPlugin.MediaItem',
-                        'This type of presentation is not supported.'))
-                    continue
-            item_name = QtGui.QListWidgetItem(filename)
-            item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(file))
-            item_name.setIcon(icon)
-            item_name.setToolTip(file)
-            self.listView.addItem(item_name)
+                    if not preview and not initialLoad:
+                        doc.load_presentation()
+                        preview = doc.get_thumbnail_path(1, True)
+                    doc.close_presentation()
+                    if not (preview and os.path.exists(preview)):
+                        icon = build_icon(u':/general/general_delete.png')
+                    else:
+                        if validate_thumb(preview, thumb):
+                            icon = build_icon(thumb)
+                        else:
+                            icon = create_thumb(preview, thumb)
+                else:
+                    if initialLoad:
+                        icon = build_icon(u':/general/general_delete.png')
+                    else:
+                        critical_error_message_box(UiStrings().UnsupportedFile,
+                            translate('PresentationPlugin.MediaItem',
+                            'This type of presentation is not supported.'))
+                        continue
+                item_name = QtGui.QListWidgetItem(filename)
+                item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(file))
+                item_name.setIcon(icon)
+                item_name.setToolTip(file)
+                self.listView.addItem(item_name)
         Receiver.send_message(u'cursor_normal')
         if not initialLoad:
             self.plugin.formParent.finishedProgressBar()


Follow ups