示例#1
0
 def load_themes(self):
     """
     Loads the theme lists and triggers updates across the whole system using direct calls or core functions and
     events for the plugins.
     The plugins will call back in to get the real list if they want it.
     """
     self.theme_list = []
     self.theme_list_widget.clear()
     files = AppLocation.get_files(self.settings_section, '.png')
     # Sort the themes by its name considering language specific
     files.sort(key=lambda file_name: get_locale_key(str(file_name)))
     # now process the file list of png files
     for name in files:
         # check to see file is in theme root directory
         theme = os.path.join(self.path, name)
         if os.path.exists(theme):
             text_name = os.path.splitext(name)[0]
             if text_name == self.global_theme:
                 name = translate('OpenLP.ThemeManager',
                                  '%s (default)') % text_name
             else:
                 name = text_name
             thumb = os.path.join(self.thumb_path, '%s.png' % text_name)
             item_name = QtWidgets.QListWidgetItem(name)
             if validate_thumb(theme, thumb):
                 icon = build_icon(thumb)
             else:
                 icon = create_thumb(theme, thumb)
             item_name.setIcon(icon)
             item_name.setData(QtCore.Qt.UserRole, text_name)
             self.theme_list_widget.addItem(item_name)
             self.theme_list.append(text_name)
     self._push_themes()
示例#2
0
 def load_list(self, media, target_group=None):
     # Sort the media by its filename considering language specific characters.
     media.sort(key=lambda filename: get_locale_key(os.path.split(str(filename))[1]))
     for track in media:
         track_info = QtCore.QFileInfo(track)
         if not os.path.exists(track):
             filename = os.path.split(str(track))[1]
             item_name = QtGui.QListWidgetItem(filename)
             item_name.setIcon(ERROR_ICON)
             item_name.setData(QtCore.Qt.UserRole, track)
         elif track_info.isFile():
             filename = os.path.split(str(track))[1]
             item_name = QtGui.QListWidgetItem(filename)
             if '*.%s' % (filename.split('.')[-1].lower()) in self.media_controller.audio_extensions_list:
                 item_name.setIcon(AUDIO_ICON)
             else:
                 item_name.setIcon(VIDEO_ICON)
             item_name.setData(QtCore.Qt.UserRole, track)
         else:
             filename = os.path.split(str(track))[1]
             item_name = QtGui.QListWidgetItem(filename)
             item_name.setIcon(build_icon(DVD_ICON))
             item_name.setData(QtCore.Qt.UserRole, track)
         item_name.setToolTip(track)
         self.list_view.addItem(item_name)
示例#3
0
 def load_themes(self):
     """
     Loads the theme lists and triggers updates across the whole system using direct calls or core functions and
     events for the plugins.
     The plugins will call back in to get the real list if they want it.
     """
     self.theme_list = []
     self.theme_list_widget.clear()
     files = AppLocation.get_files(self.settings_section, '.png')
     # Sort the themes by its name considering language specific
     files.sort(key=lambda file_name: get_locale_key(str(file_name)))
     # now process the file list of png files
     for name in files:
         # check to see file is in theme root directory
         theme = os.path.join(self.path, name)
         if os.path.exists(theme):
             text_name = os.path.splitext(name)[0]
             if text_name == self.global_theme:
                 name = translate('OpenLP.ThemeManager', '%s (default)') % text_name
             else:
                 name = text_name
             thumb = os.path.join(self.thumb_path, '%s.png' % text_name)
             item_name = QtGui.QListWidgetItem(name)
             if validate_thumb(theme, thumb):
                 icon = build_icon(thumb)
             else:
                 icon = create_thumb(theme, thumb)
             item_name.setIcon(icon)
             item_name.setData(QtCore.Qt.UserRole, text_name)
             self.theme_list_widget.addItem(item_name)
             self.theme_list.append(text_name)
     self._push_themes()
示例#4
0
    def dnd_move_internal(self, target):
        """
        Handle drag-and-drop moving of images within the media manager

        :param target: This contains the QTreeWidget that is the target of the DnD action
        """
        items_to_move = self.list_view.selectedItems()
        # Determine group to move images to
        target_group = target
        if target_group is not None and isinstance(
                target_group.data(0, QtCore.Qt.UserRole), ImageFilenames):
            target_group = target.parent()
        # Move to toplevel
        if target_group is None:
            target_group = self.list_view.invisibleRootItem()
            target_group.setData(0, QtCore.Qt.UserRole, ImageGroups())
            target_group.data(0, QtCore.Qt.UserRole).id = 0
        # Move images in the treeview
        items_to_save = []
        for item in items_to_move:
            if isinstance(item.data(0, QtCore.Qt.UserRole), ImageFilenames):
                if isinstance(item.parent(), QtWidgets.QTreeWidgetItem):
                    item.parent().removeChild(item)
                else:
                    self.list_view.invisibleRootItem().removeChild(item)
                target_group.addChild(item)
                item.setSelected(True)
                item_data = item.data(0, QtCore.Qt.UserRole)
                item_data.group_id = target_group.data(0,
                                                       QtCore.Qt.UserRole).id
                items_to_save.append(item_data)
        target_group.setExpanded(True)
        # Update the group ID's of the images in the database
        self.manager.save_objects(items_to_save)
        # Sort the target group
        group_items = []
        image_items = []
        for item in target_group.takeChildren():
            if isinstance(item.data(0, QtCore.Qt.UserRole), ImageGroups):
                group_items.append(item)
            if isinstance(item.data(0, QtCore.Qt.UserRole), ImageFilenames):
                image_items.append(item)
        group_items.sort(key=lambda item: get_locale_key(item.text(0)))
        target_group.addChildren(group_items)
        image_items.sort(key=lambda item: get_locale_key(item.text(0)))
        target_group.addChildren(image_items)
示例#5
0
    def dnd_move_internal(self, target):
        """
        Handle drag-and-drop moving of images within the media manager

        ``target``
            This contains the QTreeWidget that is the target of the DnD action
        """
        items_to_move = self.list_view.selectedItems()
        # Determine group to move images to
        target_group = target
        if target_group is not None and isinstance(target_group.data(0, QtCore.Qt.UserRole), ImageFilenames):
            target_group = target.parent()
        # Move to toplevel
        if target_group is None:
            target_group = self.list_view.invisibleRootItem()
            target_group.setData(0, QtCore.Qt.UserRole, ImageGroups())
            target_group.data(0, QtCore.Qt.UserRole).id = 0
        # Move images in the treeview
        items_to_save = []
        for item in items_to_move:
            if isinstance(item.data(0, QtCore.Qt.UserRole), ImageFilenames):
                if isinstance(item.parent(), QtGui.QTreeWidgetItem):
                    item.parent().removeChild(item)
                else:
                    self.list_view.invisibleRootItem().removeChild(item)
                target_group.addChild(item)
                item.setSelected(True)
                item_data = item.data(0, QtCore.Qt.UserRole)
                item_data.group_id = target_group.data(0, QtCore.Qt.UserRole).id
                items_to_save.append(item_data)
        target_group.setExpanded(True)
        # Update the group ID's of the images in the database
        self.manager.save_objects(items_to_save)
        # Sort the target group
        group_items = []
        image_items = []
        for item in target_group.takeChildren():
            if isinstance(item.data(0, QtCore.Qt.UserRole), ImageGroups):
                group_items.append(item)
            if isinstance(item.data(0, QtCore.Qt.UserRole), ImageFilenames):
                image_items.append(item)
        group_items.sort(key=lambda item: get_locale_key(item.text(0)))
        target_group.addChildren(group_items)
        image_items.sort(key=lambda item: get_locale_key(item.text(0)))
        target_group.addChildren(image_items)
示例#6
0
 def get_list(self, type=MediaType.Audio):
     media = Settings().value(self.settings_section + '/media files')
     media.sort(key=lambda filename: get_locale_key(os.path.split(str(filename))[1]))
     extension = []
     if type == MediaType.Audio:
         extension = self.media_controller.audio_extensions_list
     else:
         extension = self.media_controller.video_extensions_list
     extension = [x[1:] for x in extension]
     media = [x for x in media if os.path.splitext(x)[1] in extension]
     return media
示例#7
0
    def load_full_list(self, images, initial_load=False, open_group=None):
        """
        Replace the list of images and groups in the interface.

        ``images``
            A List of ImageFilenames objects that will be used to reload the mediamanager list.

        ``initial_load``
            When set to False, the busy cursor and progressbar will be shown while loading images.

        ``open_group``
            ImageGroups object of the group that must be expanded after reloading the list in the interface.
        """
        if not initial_load:
            self.application.set_busy_cursor()
            self.main_window.display_progress_bar(len(images))
        self.list_view.clear()
        # Load the list of groups and add them to the treeView.
        group_items = {}
        self.add_sub_groups(group_items, parent_group_id=0)
        if open_group is not None:
            self.expand_group(open_group.id)
        # Sort the images by its filename considering language specific.
        # characters.
        images.sort(key=lambda image_object: get_locale_key(os.path.split(str(image_object.filename))[1]))
        for imageFile in images:
            log.debug('Loading image: %s', imageFile.filename)
            filename = os.path.split(imageFile.filename)[1]
            thumb = os.path.join(self.servicePath, filename)
            if not os.path.exists(imageFile.filename):
                icon = build_icon(':/general/general_delete.png')
            else:
                if validate_thumb(imageFile.filename, thumb):
                    icon = build_icon(thumb)
                else:
                    icon = create_thumb(imageFile.filename, thumb)
            item_name = QtGui.QTreeWidgetItem(filename)
            item_name.setText(0, filename)
            item_name.setIcon(0, icon)
            item_name.setToolTip(0, imageFile.filename)
            item_name.setData(0, QtCore.Qt.UserRole, imageFile)
            if imageFile.group_id == 0:
                self.list_view.addTopLevelItem(item_name)
            else:
                group_items[imageFile.group_id].addChild(item_name)
            if not initial_load:
                self.main_window.increment_progress_bar()
        if not initial_load:
            self.main_window.finished_progress_bar()
        self.application.set_normal_cursor()
示例#8
0
    def get_list(self, type=MediaType.Audio):
        """
        Get the list of media, optional select media type.

        :param type: Type to get, defaults to audio.
        :return: The media list
        """
        media = Settings().value(self.settings_section + '/media files')
        media.sort(key=lambda filename: get_locale_key(os.path.split(str(filename))[1]))
        if type == MediaType.Audio:
            extension = self.media_controller.audio_extensions_list
        else:
            extension = self.media_controller.video_extensions_list
        extension = [x[1:] for x in extension]
        media = [x for x in media if os.path.splitext(x)[1] in extension]
        return media
示例#9
0
    def load_full_list(self, images, initial_load=False, open_group=None):
        """
        Replace the list of images and groups in the interface.

        :param images: A List of Image Filenames objects that will be used to reload the mediamanager list.
        :param initial_load: When set to False, the busy cursor and progressbar will be shown while loading images.
        :param open_group: ImageGroups object of the group that must be expanded after reloading the list in the
            interface.
        """
        if not initial_load:
            self.application.set_busy_cursor()
            self.main_window.display_progress_bar(len(images))
        self.list_view.clear()
        # Load the list of groups and add them to the treeView.
        group_items = {}
        self.add_sub_groups(group_items, parent_group_id=0)
        if open_group is not None:
            self.expand_group(open_group.id)
        # Sort the images by its filename considering language specific.
        # characters.
        images.sort(key=lambda image_object: get_locale_key(
            os.path.split(str(image_object.filename))[1]))
        for image_file in images:
            log.debug('Loading image: %s', image_file.filename)
            filename = os.path.split(image_file.filename)[1]
            thumb = self.generate_thumbnail_path(image_file)
            if not os.path.exists(image_file.filename):
                icon = build_icon(':/general/general_delete.png')
            else:
                if validate_thumb(image_file.filename, thumb):
                    icon = build_icon(thumb)
                else:
                    icon = create_thumb(image_file.filename, thumb)
            item_name = QtWidgets.QTreeWidgetItem([filename])
            item_name.setText(0, filename)
            item_name.setIcon(0, icon)
            item_name.setToolTip(0, image_file.filename)
            item_name.setData(0, QtCore.Qt.UserRole, image_file)
            if image_file.group_id == 0:
                self.list_view.addTopLevelItem(item_name)
            else:
                group_items[image_file.group_id].addChild(item_name)
            if not initial_load:
                self.main_window.increment_progress_bar()
        if not initial_load:
            self.main_window.finished_progress_bar()
        self.application.set_normal_cursor()
示例#10
0
    def get_list(self, type=MediaType.Audio):
        """
        Get the list of media, optional select media type.

        :param type: Type to get, defaults to audio.
        :return: The media list
        """
        media = Settings().value(self.settings_section + '/media files')
        media.sort(key=lambda filename: get_locale_key(
            os.path.split(str(filename))[1]))
        if type == MediaType.Audio:
            extension = self.media_controller.audio_extensions_list
        else:
            extension = self.media_controller.video_extensions_list
        extension = [x[1:] for x in extension]
        media = [x for x in media if os.path.splitext(x)[1] in extension]
        return media
示例#11
0
    def fill_groups_combobox(self, combobox, parent_group_id=0, prefix=''):
        """
        Recursively add groups to the combobox in the 'Add group' dialog.

        :param combobox: The QComboBox to add the options to.
        :param parent_group_id: The ID of the group that will be added.
        :param prefix: A string containing the prefix that will be added in front of the groupname for each level of
        the tree.
        """
        if parent_group_id == 0:
            combobox.clear()
            combobox.top_level_group_added = False
        image_groups = self.manager.get_all_objects(ImageGroups, ImageGroups.parent_id == parent_group_id)
        image_groups.sort(key=lambda group_object: get_locale_key(group_object.group_name))
        for image_group in image_groups:
            combobox.addItem(prefix + image_group.group_name, image_group.id)
            self.fill_groups_combobox(combobox, image_group.id, prefix + '   ')
示例#12
0
    def load_list(self, media, target_group=None):
        """
        Load the media list

        :param media: The media
        :param target_group:
        """
        media.sort(key=lambda file_name: get_locale_key(
            os.path.split(str(file_name))[1]))
        for track in media:
            track_info = QtCore.QFileInfo(track)
            item_name = None
            if track.startswith('optical:'):
                # Handle optical based item
                (file_name, title, audio_track, subtitle_track, start, end,
                 clip_name) = parse_optical_path(track)
                item_name = QtGui.QListWidgetItem(clip_name)
                item_name.setIcon(OPTICAL_ICON)
                item_name.setData(QtCore.Qt.UserRole, track)
                item_name.setToolTip('%s@%s-%s' %
                                     (file_name, format_milliseconds(start),
                                      format_milliseconds(end)))
            elif not os.path.exists(track):
                # File doesn't exist, mark as error.
                file_name = os.path.split(str(track))[1]
                item_name = QtGui.QListWidgetItem(file_name)
                item_name.setIcon(ERROR_ICON)
                item_name.setData(QtCore.Qt.UserRole, track)
                item_name.setToolTip(track)
            elif track_info.isFile():
                # Normal media file handling.
                file_name = os.path.split(str(track))[1]
                item_name = QtGui.QListWidgetItem(file_name)
                if '*.%s' % (file_name.split('.')[-1].lower()
                             ) in self.media_controller.audio_extensions_list:
                    item_name.setIcon(AUDIO_ICON)
                else:
                    item_name.setIcon(VIDEO_ICON)
                item_name.setData(QtCore.Qt.UserRole, track)
                item_name.setToolTip(track)
            if item_name:
                self.list_view.addItem(item_name)
示例#13
0
    def add_sub_groups(self, group_list, parent_group_id):
        """
        Recursively add subgroups to the given parent group in a QTreeWidget.

        :param group_list: The List object that contains all QTreeWidgetItems.
        :param parent_group_id: The ID of the group that will be added recursively.
        """
        image_groups = self.manager.get_all_objects(ImageGroups, ImageGroups.parent_id == parent_group_id)
        image_groups.sort(key=lambda group_object: get_locale_key(group_object.group_name))
        folder_icon = build_icon(':/images/image_group.png')
        for image_group in image_groups:
            group = QtGui.QTreeWidgetItem()
            group.setText(0, image_group.group_name)
            group.setData(0, QtCore.Qt.UserRole, image_group)
            group.setIcon(0, folder_icon)
            if parent_group_id == 0:
                self.list_view.addTopLevelItem(group)
            else:
                group_list[parent_group_id].addChild(group)
            group_list[image_group.id] = group
            self.add_sub_groups(group_list, image_group.id)
示例#14
0
 def load_loops(self):
     """
     Loads all loops into the plugin
     """
     self.loop_list = []
     self.loop_list_widget.clear()
     files = AppLocation.get_files(self.settings_section)
     # Sort the loops by name, language specific
     files.sort(key=lambda file_name: get_locale_key(str(file_name)))
     # now process the file list of loop
     for name in files:
         if os.path.isfile(os.path.join(self.path, name)):
             # check to see loop has corresponding thumbnail
             loop_thumb = os.path.join(self.thumb_path, os.path.splitext(name)[0] + '.jpg')
             if os.path.exists(loop_thumb) == False:
                 self.create_loop_thumbnail(name)
             loop_name = os.path.splitext(name)[0]
             item_name = QtGui.QListWidgetItem(loop_name)
             icon = build_icon(loop_thumb)
             item_name.setIcon(icon)
             item_name.setData(QtCore.Qt.UserRole, name)
             self.loop_list_widget.addItem(item_name)
             self.loop_list.append(loop_name)
示例#15
0
 def load_loops(self):
     """
     Loads all loops into the plugin
     """
     self.loop_list = []
     self.loop_list_widget.clear()
     files = AppLocation.get_files(self.settings_section)
     # Sort the loops by name, language specific
     files.sort(key=lambda file_name: get_locale_key(str(file_name)))
     # now process the file list of loop
     for name in files:
         if os.path.isfile(os.path.join(self.path, name)):
             # check to see loop has corresponding thumbnail
             loop_thumb = os.path.join(self.thumb_path, os.path.splitext(name)[0] + '.jpg')
             if os.path.exists(loop_thumb) == False:
                 self.create_loop_thumbnail(name)
             loop_name = os.path.splitext(name)[0]
             item_name = QtGui.QListWidgetItem(loop_name)
             icon = build_icon(loop_thumb)
             item_name.setIcon(icon)
             item_name.setData(QtCore.Qt.UserRole, name)
             self.loop_list_widget.addItem(item_name)
             self.loop_list.append(loop_name)
示例#16
0
    def load_list(self, media, target_group=None):
        """
        Load the media list

        :param media: The media
        :param target_group:
        """
        media.sort(key=lambda file_name: get_locale_key(os.path.split(str(file_name))[1]))
        for track in media:
            track_info = QtCore.QFileInfo(track)
            item_name = None
            if track.startswith('optical:'):
                # Handle optical based item
                (file_name, title, audio_track, subtitle_track, start, end, clip_name) = parse_optical_path(track)
                item_name = QtGui.QListWidgetItem(clip_name)
                item_name.setIcon(OPTICAL_ICON)
                item_name.setData(QtCore.Qt.UserRole, track)
                item_name.setToolTip('%s@%s-%s' % (file_name, format_milliseconds(start), format_milliseconds(end)))
            elif not os.path.exists(track):
                # File doesn't exist, mark as error.
                file_name = os.path.split(str(track))[1]
                item_name = QtGui.QListWidgetItem(file_name)
                item_name.setIcon(ERROR_ICON)
                item_name.setData(QtCore.Qt.UserRole, track)
                item_name.setToolTip(track)
            elif track_info.isFile():
                # Normal media file handling.
                file_name = os.path.split(str(track))[1]
                item_name = QtGui.QListWidgetItem(file_name)
                if '*.%s' % (file_name.split('.')[-1].lower()) in self.media_controller.audio_extensions_list:
                    item_name.setIcon(AUDIO_ICON)
                else:
                    item_name.setIcon(VIDEO_ICON)
                item_name.setData(QtCore.Qt.UserRole, track)
                item_name.setToolTip(track)
            if item_name:
                self.list_view.addItem(item_name)
示例#17
0
文件: db.py 项目: jkunle/paul
 def __eq__(self, other):
     return get_locale_key(self.title) == get_locale_key(other.title)
示例#18
0
文件: db.py 项目: jkunle/paul
 def __lt__(self, other):
     return get_locale_key(self.title) < get_locale_key(other.title)
示例#19
0
 def __lt__(self, other):
     return get_locale_key(self.title) < get_locale_key(other.title)
示例#20
0
 def load_list(self, files, target_group=None, initial_load=False):
     """
     Add presentations into the media manager. This is called both on initial load of the plugin to populate with
     existing files, and when the user adds new files via the media manager.
     """
     current_list = self.get_file_list()
     titles = [os.path.split(file)[1] for file in current_list]
     self.application.set_busy_cursor()
     if not initial_load:
         self.main_window.display_progress_bar(len(files))
     # Sort the presentations by its filename considering language specific characters.
     files.sort(key=lambda filename: get_locale_key(
         os.path.split(str(filename))[1]))
     for file in files:
         if not initial_load:
             self.main_window.increment_progress_bar()
         if current_list.count(file) > 0:
             continue
         filename = os.path.split(file)[1]
         if not os.path.exists(file):
             item_name = QtWidgets.QListWidgetItem(filename)
             item_name.setIcon(build_icon(ERROR_IMAGE))
             item_name.setData(QtCore.Qt.UserRole, file)
             item_name.setToolTip(file)
             self.list_view.addItem(item_name)
         else:
             if titles.count(filename) > 0:
                 if not initial_load:
                     critical_error_message_box(
                         translate('PresentationPlugin.MediaItem',
                                   'File Exists'),
                         translate(
                             'PresentationPlugin.MediaItem',
                             'A presentation with that filename already exists.'
                         ))
                 continue
             controller_name = self.find_controller_by_type(filename)
             if controller_name:
                 controller = self.controllers[controller_name]
                 doc = controller.add_document(file)
                 thumb = os.path.join(doc.get_thumbnail_folder(),
                                      'icon.png')
                 preview = doc.get_thumbnail_path(1, True)
                 if not preview and not initial_load:
                     doc.load_presentation()
                     preview = doc.get_thumbnail_path(1, True)
                 doc.close_presentation()
                 if not (preview and os.path.exists(preview)):
                     icon = build_icon(':/general/general_delete.png')
                 else:
                     if validate_thumb(preview, thumb):
                         icon = build_icon(thumb)
                     else:
                         icon = create_thumb(preview, thumb)
             else:
                 if initial_load:
                     icon = build_icon(':/general/general_delete.png')
                 else:
                     critical_error_message_box(
                         UiStrings().UnsupportedFile,
                         translate(
                             'PresentationPlugin.MediaItem',
                             'This type of presentation is not supported.'))
                     continue
             item_name = QtWidgets.QListWidgetItem(filename)
             item_name.setData(QtCore.Qt.UserRole, file)
             item_name.setIcon(icon)
             item_name.setToolTip(file)
             self.list_view.addItem(item_name)
     if not initial_load:
         self.main_window.finished_progress_bar()
     self.application.set_normal_cursor()
示例#21
0
 def __eq__(self, other):
     return get_locale_key(self.title) == get_locale_key(other.title)
示例#22
0
 def load_list(self, files, target_group=None, initial_load=False):
     """
     Add presentations into the media manager. This is called both on initial load of the plugin to populate with
     existing files, and when the user adds new files via the media manager.
     """
     current_list = self.get_file_list()
     titles = [os.path.split(file)[1] for file in current_list]
     self.application.set_busy_cursor()
     if not initial_load:
         self.main_window.display_progress_bar(len(files))
     # Sort the presentations by its filename considering language specific characters.
     files.sort(key=lambda filename: get_locale_key(os.path.split(str(filename))[1]))
     for file in files:
         if not initial_load:
             self.main_window.increment_progress_bar()
         if current_list.count(file) > 0:
             continue
         filename = os.path.split(str(file))[1]
         if not os.path.exists(file):
             item_name = QtGui.QListWidgetItem(filename)
             item_name.setIcon(build_icon(ERROR_IMAGE))
             item_name.setData(QtCore.Qt.UserRole, file)
             item_name.setToolTip(file)
             self.list_view.addItem(item_name)
         else:
             if titles.count(filename) > 0:
                 if not initial_load:
                     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(str(file))
                 thumb = os.path.join(doc.get_thumbnail_folder(), 'icon.png')
                 preview = doc.get_thumbnail_path(1, True)
                 if not preview and not initial_load:
                     doc.load_presentation()
                     preview = doc.get_thumbnail_path(1, True)
                 doc.close_presentation()
                 if not (preview and os.path.exists(preview)):
                     icon = build_icon(':/general/general_delete.png')
                 else:
                     if validate_thumb(preview, thumb):
                         icon = build_icon(thumb)
                     else:
                         icon = create_thumb(preview, thumb)
             else:
                 if initial_load:
                     icon = build_icon(':/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, file)
             item_name.setIcon(icon)
             item_name.setToolTip(file)
             self.list_view.addItem(item_name)
     if not initial_load:
         self.main_window.finished_progress_bar()
     self.application.set_normal_cursor()