Moved conversion code. Doesn't work yet.

This commit is contained in:
Arjan Schrijver 2013-03-03 18:24:32 +01:00
parent c02098faa8
commit 97184a9ea1
5 changed files with 90 additions and 11 deletions

View File

@ -35,6 +35,7 @@ from PyQt4 import QtCore
from openlp.core.lib import Settings, Registry, UiStrings
from openlp.core.utils import get_application_version
from openlp.plugins.images.converter import ImagesListSaver
log = logging.getLogger(__name__)
@ -303,8 +304,10 @@ class Plugin(QtCore.QObject):
if self.mediaItemClass is not None:
loaded_list = Settings().get_files_from_config(self)
# Now save the list to the config using our Settings class.
Settings().setValue(u'%s/%s files' % (self.settingsSection, self.name), loaded_list)
# FIXME: make sure we do not do this for the images plugin.
if self.name == u'images':
ImagesListSaver.save_converted_images_list(loaded_list)
else:
Settings().setValue(u'%s/%s files' % (self.settingsSection, self.name), loaded_list)
def usesTheme(self, theme):
"""

View File

@ -51,6 +51,7 @@ from openlp.core.utils import AppLocation, LanguageManager, add_actions, get_app
get_filesystem_encoding
from openlp.core.utils.actions import ActionList, CategoryOrder
from openlp.core.ui.firsttimeform import FirstTimeForm
from openlp.plugins.images.converter import ImagesListSaver
log = logging.getLogger(__name__)
@ -851,8 +852,9 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
import_settings = Settings(temp_config, Settings.IniFormat)
# Remove/rename old settings to prepare the import.
import_settings.remove_obsolete_settings()
# FIXME: Convert image files
#settings.get_files_from_config()
# Convert image files
loaded_list = import_settings.get_files_from_config(ImagePlugin)
ImagesListSaver.save_converted_images_list(loaded_list)
# Lets do a basic sanity check. If it contains this string we can assume it was created by OpenLP and so we'll
# load what we can from it, and just silently ignore anything we don't recognise.
if import_settings.value(u'SettingsImport/type') != u'OpenLP_settings_export':

View File

@ -0,0 +1,30 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
# --------------------------------------------------------------------------- #
# Copyright (c) 2008-2013 Raoul Snyman #
# Portions copyright (c) 2008-2013 Tim Bentley, Gerald Britton, Jonathan #
# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, #
# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. #
# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, #
# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, #
# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, #
# Frode Woldsund, Martin Zibricky, Patrick Zimmermann #
# --------------------------------------------------------------------------- #
# 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. #
# #
# This program is distributed in the hope that it will be useful, but WITHOUT #
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
# more details. #
# #
# You should have received a copy of the GNU General Public License along #
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
from imageslistsaver import ImagesListSaver

View File

@ -0,0 +1,51 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
# --------------------------------------------------------------------------- #
# Copyright (c) 2008-2013 Raoul Snyman #
# Portions copyright (c) 2008-2013 Tim Bentley, Gerald Britton, Jonathan #
# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, #
# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. #
# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, #
# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, #
# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, #
# Frode Woldsund, Martin Zibricky, Patrick Zimmermann #
# --------------------------------------------------------------------------- #
# 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. #
# #
# This program is distributed in the hope that it will be useful, but WITHOUT #
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
# more details. #
# #
# You should have received a copy of the GNU General Public License along #
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
import logging
from openlp.plugins.images.lib.db import ImageFilenames
log = logging.getLogger(__name__)
class ImagesListSaver(object):
"""
This class is used to save a list of images into the database.
"""
@staticmethod
def save_converted_images_list(images_list):
"""
Save the list of images into the database.
"""
for filename in images_list:
log.debug(u'Adding new image: %s', filename)
imageFile = ImageFilenames()
imageFile.group_id = 0
imageFile.filename = unicode(filename)
self.manager.save_object(imageFile)

View File

@ -90,13 +90,6 @@ class ImageMediaItem(MediaManagerItem):
self.listView.allow_internal_dnd = True
self.servicePath = os.path.join(AppLocation.get_section_data_path(self.settingsSection), u'thumbnails')
check_directory_exists(self.servicePath)
# Import old images list
files_from_config = Settings().get_files_from_config(self.plugin)
for old_file in files_from_config:
imagefilename = ImageFilenames()
imagefilename.group_id = 0
imagefilename.filename = old_file
self.manager.save_object(imagefilename)
# Load images from the database
self.loadFullList(
self.manager.get_all_objects(ImageFilenames, order_by_ref=ImageFilenames.filename), initial_load=True)