From 8b79abdfe6981fbfbd97c55f80c7878b357a3bfc Mon Sep 17 00:00:00 2001 From: Jonathan Corwin Date: Sun, 22 Aug 2010 23:36:11 +0100 Subject: [PATCH 01/25] sof wizard --- openlp/plugins/songs/lib/oooimport.py | 26 +++++++++++++++++++++----- openlp/plugins/songs/lib/sofimport.py | 24 ++++++++++++++++++------ 2 files changed, 39 insertions(+), 11 deletions(-) diff --git a/openlp/plugins/songs/lib/oooimport.py b/openlp/plugins/songs/lib/oooimport.py index 76b4b6c0d..7bc602f99 100644 --- a/openlp/plugins/songs/lib/oooimport.py +++ b/openlp/plugins/songs/lib/oooimport.py @@ -28,6 +28,7 @@ import os from PyQt4 import QtCore +from openlp.core.lib import Receiver from songimport import SongImport if os.name == u'nt': @@ -43,23 +44,30 @@ else: except ImportError: pass -class OooImport(object): +class OooImport(SongImport): """ Import songs from Impress/Powerpoint docs using Impress """ - def __init__(self, songmanager): + def __init__(self, master_manager, **kwargs): """ Initialise the class. Requires a songmanager class which is passed to SongImport for writing song to disk """ self.song = None - self.manager = songmanager + self.master_manager = master_manager self.document = None self.process_started = False + self.filenames = kwargs[u'filenames'] + QtCore.QObject.connect(Receiver.get_receiver(), + QtCore.SIGNAL(u'openlp_stop_song_import'), self.stop_import) - def import_docs(self, filenames): + def do_import(self): + self.abort = False self.start_ooo() - for filename in filenames: + for filename in self.filenames: + if self.abort: + self.wizard.incrementProgressBar(u'Import cancelled') + return filename = unicode(filename) if os.path.isfile(filename): self.open_ooo_file(filename) @@ -73,6 +81,9 @@ class OooImport(object): self.close_ooo_file() self.close_ooo() + def stop_import(self): + self.abort = True + def start_ooo(self): """ Start OpenOffice.org process @@ -135,6 +146,8 @@ class OooImport(object): "com.sun.star.presentation.PresentationDocument") and not \ self.document.supportsService("com.sun.star.text.TextDocument"): self.close_ooo_file() + else: + self.wizard.incrementProgressBar(u'Processing file ' + filepath) except: pass return @@ -161,6 +174,9 @@ class OooImport(object): slides = doc.getDrawPages() text = u'' for slide_no in range(slides.getCount()): + if self.abort: + self.wizard.incrementProgressBar(u'Import cancelled') + return slide = slides.getByIndex(slide_no) slidetext = u'' for idx in range(slide.getCount()): diff --git a/openlp/plugins/songs/lib/sofimport.py b/openlp/plugins/songs/lib/sofimport.py index 54cfd07ac..b2374d672 100644 --- a/openlp/plugins/songs/lib/sofimport.py +++ b/openlp/plugins/songs/lib/sofimport.py @@ -68,18 +68,26 @@ class SofImport(OooImport): It attempts to detect italiced verses, and treats these as choruses in the verse ordering. Again not perfect, but a start. """ - def __init__(self, songmanager): + def __init__(self, master_manager, **kwargs): """ Initialise the class. Requires a songmanager class which is passed to SongImport for writing song to disk """ - OooImport.__init__(self, songmanager) + OooImport.__init__(self,master_manager, **kwargs) - def import_sof(self, filename): + def do_import(self): + self.abort = False self.start_ooo() - self.open_ooo_file(filename) - self.process_sof_file() - self.close_ooo_file() + for filename in self.filenames: + if self.abort: + self.wizard.incrementProgressBar(u'Import cancelled') + return + filename = unicode(filename) + if os.path.isfile(filename): + self.open_ooo_file(filename) + if self.document: + self.process_sof_file() + self.close_ooo_file() self.close_ooo() def process_sof_file(self): @@ -90,6 +98,9 @@ class SofImport(OooImport): self.new_song() paragraphs = self.document.getText().createEnumeration() while paragraphs.hasMoreElements(): + if self.abort: + self.wizard.incrementProgressBar(u'Import cancelled') + return paragraph = paragraphs.nextElement() if paragraph.supportsService("com.sun.star.text.Paragraph"): self.process_paragraph(paragraph) @@ -244,6 +255,7 @@ class SofImport(OooImport): if title.endswith(u','): title = title[:-1] self.song.title = title + self.wizard.incrementProgressBar(u'Processing song ' + title) def add_author(self, text): """ From 0066edecbb091ce181d98cd320777b06d44be47c Mon Sep 17 00:00:00 2001 From: Jonathan Corwin Date: Tue, 24 Aug 2010 13:50:26 +0100 Subject: [PATCH 02/25] Remove comments --- openlp/plugins/songs/lib/oooimport.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/openlp/plugins/songs/lib/oooimport.py b/openlp/plugins/songs/lib/oooimport.py index da4bd6f3e..d07d50271 100644 --- a/openlp/plugins/songs/lib/oooimport.py +++ b/openlp/plugins/songs/lib/oooimport.py @@ -65,9 +65,6 @@ class OooImport(SongImport): def do_import(self): self.abort = False self.start_ooo() - # Note this doesn't work, because kwargs[u'filenames'] doesn't appear - # to be anything sensible like an array of strings. No idea what it is - # though, I'm meant to guess for filename in self.filenames: if self.abort: self.wizard.incrementProgressBar(u'Import cancelled') From dfe8bbae9c9b018c30479659c2f294fe9a4c627f Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Thu, 26 Aug 2010 22:52:54 +0200 Subject: [PATCH 03/25] Some minor syntactic sugar. --- openlp/plugins/songs/lib/olpimport.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/openlp/plugins/songs/lib/olpimport.py b/openlp/plugins/songs/lib/olpimport.py index a4c15718e..63f99dc7b 100644 --- a/openlp/plugins/songs/lib/olpimport.py +++ b/openlp/plugins/songs/lib/olpimport.py @@ -75,18 +75,18 @@ class OpenLPSongImport(SongImport): The :class:`OpenLPSongImport` class provides OpenLP with the ability to import song databases from other installations of OpenLP. """ - def __init__(self, master_manager, **kwargs): + def __init__(self, manager, **kwargs): """ Initialise the import. - ``master_manager`` + ``manager`` The song manager for the running OpenLP installation. ``source_db`` The database providing the data to import. """ - SongImport.__init__(self, master_manager) - self.master_manager = master_manager + SongImport.__init__(self, manager) + #self.master_manager = master_manager self.import_source = u'sqlite:///%s' % kwargs[u'filename'] log.debug(self.import_source) self.source_session = None @@ -167,7 +167,7 @@ class OpenLPSongImport(SongImport): new_song.ccli_number = song.ccli_number if song.authors: for author in song.authors: - existing_author = self.master_manager.get_object_filtered( + existing_author = self.manager.get_object_filtered( Author, Author.display_name == author.display_name) if existing_author: new_song.authors.append(existing_author) @@ -177,7 +177,7 @@ class OpenLPSongImport(SongImport): last_name=author.last_name, display_name=author.display_name)) else: - au = self.master_manager.get_object_filtered(Author, + au = self.manager.get_object_filtered(Author, Author.display_name == u'Author Unknown') if au: new_song.authors.append(au) @@ -185,7 +185,7 @@ class OpenLPSongImport(SongImport): new_song.authors.append(Author.populate( display_name=u'Author Unknown')) if song.book: - existing_song_book = self.master_manager.get_object_filtered( + existing_song_book = self.manager.get_object_filtered( Book, Book.name == song.book.name) if existing_song_book: new_song.book = existing_song_book @@ -194,7 +194,7 @@ class OpenLPSongImport(SongImport): publisher=song.book.publisher) if song.topics: for topic in song.topics: - existing_topic = self.master_manager.get_object_filtered( + existing_topic = self.manager.get_object_filtered( Topic, Topic.name == topic.name) if existing_topic: new_song.topics.append(existing_topic) @@ -204,12 +204,12 @@ class OpenLPSongImport(SongImport): # if song.media_files: # for media_file in song.media_files: # existing_media_file = \ -# self.master_manager.get_object_filtered(MediaFile, +# self.manager.get_object_filtered(MediaFile, # MediaFile.file_name == media_file.file_name) # if existing_media_file: # new_song.media_files.append(existing_media_file) # else: # new_song.media_files.append(MediaFile.populate( # file_name=media_file.file_name)) - self.master_manager.save_object(new_song) + self.manager.save_object(new_song) engine.dispose() From 3d60cc894de45caa7c037f4bfc0fc19cd2fea0be Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Thu, 26 Aug 2010 22:53:24 +0200 Subject: [PATCH 04/25] Added the initial openlp.org 1.x importer. --- openlp/plugins/songs/lib/olp1import.py | 131 +++++++++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 openlp/plugins/songs/lib/olp1import.py diff --git a/openlp/plugins/songs/lib/olp1import.py b/openlp/plugins/songs/lib/olp1import.py new file mode 100644 index 000000000..1625bfff2 --- /dev/null +++ b/openlp/plugins/songs/lib/olp1import.py @@ -0,0 +1,131 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2010 Raoul Snyman # +# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael # +# Gorven, Scott Guerrieri, Meinert Jordan, Andreas Preikschat, Christian # +# Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon Tibble, # +# Carsten Tinggaard, Frode Woldsund # +# --------------------------------------------------------------------------- # +# 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 # +############################################################################### +""" +The :mod:`olp1import` module provides the functionality for importing +openlp.org 1.x song databases into the current installation database. +""" +import logging +import sqlite + +#from openlp.core.lib.db import BaseModel +from openlp.plugins.songs.lib.db import Author, Book, Song, Topic #, MediaFile +from songimport import SongImport + +log = logging.getLogger(__name__) + +class OpenLP1SongImport(SongImport): + """ + The :class:`OpenLP1SongImport` class provides OpenLP with the ability to + import song databases from installations of openlp.org 1.x. + """ + def __init__(self, manager, **kwargs): + """ + Initialise the import. + + ``manager`` + The song manager for the running OpenLP installation. + + ``filename`` + The database providing the data to import. + """ + SongImport.__init__(self, manager) + self.manager = manager + self.import_source = kwargs[u'filename'] + + def do_import(self): + """ + Run the import for an openlp.org 1.x song database. + """ + connection = sqlite.connect(self.import_source) + cursor = connection.cursor() + +# for song in source_songs: +# new_song = Song() +# new_song.title = song.title +# if has_media_files: +# new_song.alternate_title = song.alternate_title +# else: +# old_titles = song.search_title.split(u'@') +# if len(old_titles) > 1: +# new_song.alternate_title = old_titles[1] +# else: +# new_song.alternate_title = u'' +# new_song.search_title = song.search_title +# new_song.song_number = song.song_number +# new_song.lyrics = song.lyrics +# new_song.search_lyrics = song.search_lyrics +# new_song.verse_order = song.verse_order +# new_song.copyright = song.copyright +# new_song.comments = song.comments +# new_song.theme_name = song.theme_name +# new_song.ccli_number = song.ccli_number +# if song.authors: +# for author in song.authors: +# existing_author = self.master_manager.get_object_filtered( +# Author, Author.display_name == author.display_name) +# if existing_author: +# new_song.authors.append(existing_author) +# else: +# new_song.authors.append(Author.populate( +# first_name=author.first_name, +# last_name=author.last_name, +# display_name=author.display_name)) +# else: +# au = self.master_manager.get_object_filtered(Author, +# Author.display_name == u'Author Unknown') +# if au: +# new_song.authors.append(au) +# else: +# new_song.authors.append(Author.populate( +# display_name=u'Author Unknown')) +# if song.book: +# existing_song_book = self.master_manager.get_object_filtered( +# Book, Book.name == song.book.name) +# if existing_song_book: +# new_song.book = existing_song_book +# else: +# new_song.book = Book.populate(name=song.book.name, +# publisher=song.book.publisher) +# if song.topics: +# for topic in song.topics: +# existing_topic = self.master_manager.get_object_filtered( +# Topic, Topic.name == topic.name) +# if existing_topic: +# new_song.topics.append(existing_topic) +# else: +# new_song.topics.append(Topic.populate(name=topic.name)) +## if has_media_files: +## if song.media_files: +## for media_file in song.media_files: +## existing_media_file = \ +## self.master_manager.get_object_filtered(MediaFile, +## MediaFile.file_name == media_file.file_name) +## if existing_media_file: +## new_song.media_files.append(existing_media_file) +## else: +## new_song.media_files.append(MediaFile.populate( +## file_name=media_file.file_name)) +# self.master_manager.save_object(new_song) From f717dc10d4a0e29f20e5d9e40f87d69578d87b4e Mon Sep 17 00:00:00 2001 From: Jonathan Corwin Date: Thu, 26 Aug 2010 23:08:09 +0100 Subject: [PATCH 05/25] Bring up to date --- openlp/plugins/songs/lib/oooimport.py | 11 ++++++----- openlp/plugins/songs/lib/sofimport.py | 6 +++--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/openlp/plugins/songs/lib/oooimport.py b/openlp/plugins/songs/lib/oooimport.py index 6c9141157..9a3be2843 100644 --- a/openlp/plugins/songs/lib/oooimport.py +++ b/openlp/plugins/songs/lib/oooimport.py @@ -59,16 +59,16 @@ class OooImport(SongImport): self.document = None self.process_started = False self.filenames = kwargs[u'filenames'] - self.import_wizard.importProgressBar.setMaximum(0) QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'openlp_stop_song_import'), self.stop_import) + QtCore.SIGNAL(u'song_stop_import'), self.stop_import) def do_import(self): self.abort = False + self.import_wizard.importProgressBar.setMaximum(0) self.start_ooo() for filename in self.filenames: if self.abort: - self.import_wizard.incrementProgressBar(u'Import cancelled') + self.import_wizard.incrementProgressBar(u'Import cancelled', 0) return filename = unicode(filename) if os.path.isfile(filename): @@ -149,7 +149,8 @@ class OooImport(SongImport): self.document.supportsService("com.sun.star.text.TextDocument"): self.close_ooo_file() else: - self.import_wizard.incrementProgressBar(u'Processing file ' + filepath) + self.import_wizard.incrementProgressBar( + u'Processing file ' + filepath, 0) except: pass return @@ -177,7 +178,7 @@ class OooImport(SongImport): text = u'' for slide_no in range(slides.getCount()): if self.abort: - self.import_wizard.incrementProgressBar(u'Import cancelled') + self.import_wizard.incrementProgressBar(u'Import cancelled', 0) return slide = slides.getByIndex(slide_no) slidetext = u'' diff --git a/openlp/plugins/songs/lib/sofimport.py b/openlp/plugins/songs/lib/sofimport.py index af968fafe..0d7c085de 100644 --- a/openlp/plugins/songs/lib/sofimport.py +++ b/openlp/plugins/songs/lib/sofimport.py @@ -80,7 +80,7 @@ class SofImport(OooImport): self.start_ooo() for filename in self.filenames: if self.abort: - self.import_wizard.incrementProgressBar(u'Import cancelled') + self.import_wizard.incrementProgressBar(u'Import cancelled', 0) return filename = unicode(filename) if os.path.isfile(filename): @@ -99,7 +99,7 @@ class SofImport(OooImport): paragraphs = self.document.getText().createEnumeration() while paragraphs.hasMoreElements(): if self.abort: - self.import_wizard.incrementProgressBar(u'Import cancelled') + self.import_wizard.incrementProgressBar(u'Import cancelled', 0) return paragraph = paragraphs.nextElement() if paragraph.supportsService("com.sun.star.text.Paragraph"): @@ -255,7 +255,7 @@ class SofImport(OooImport): if title.endswith(u','): title = title[:-1] self.song.title = title - self.import_wizard.incrementProgressBar(u'Processing song ' + title) + self.import_wizard.incrementProgressBar(u'Processing song ' + title, 0) def add_author(self, text): """ From 59d2e2dab644d33eba211f441c7da94d03979836 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Sun, 29 Aug 2010 01:09:05 +0200 Subject: [PATCH 06/25] Fixed up the OpenSong importer. --- openlp/plugins/songs/lib/opensongimport.py | 194 ++++++++++++--------- openlp/plugins/songs/lib/songimport.py | 2 +- 2 files changed, 110 insertions(+), 86 deletions(-) diff --git a/openlp/plugins/songs/lib/opensongimport.py b/openlp/plugins/songs/lib/opensongimport.py index e1d683000..ccf8479bf 100644 --- a/openlp/plugins/songs/lib/opensongimport.py +++ b/openlp/plugins/songs/lib/opensongimport.py @@ -36,119 +36,148 @@ log = logging.getLogger(__name__) class OpenSongImportError(Exception): pass -class OpenSongImport(object): +class OpenSongImport(SongImport): """ - Import songs exported from OpenSong - the format is described loosly here: - http://www.opensong.org/d/manual/song_file_format_specification + Import songs exported from OpenSong - However, it doesn't describe the section, so here's an attempt: + The format is described loosly on the `OpenSong File Format Specification + `_ page on + the OpenSong web site. However, it doesn't describe the section, + so here's an attempt: - Verses can be expressed in one of 2 ways: - - [v1]List of words - Another Line + Verses can be expressed in one of 2 ways, either in complete verses, or by + line grouping, i.e. grouping all line 1's of a verse together, all line 2's + of a verse together, and so on. - [v2]Some words for the 2nd verse - etc... - + An example of complete verses:: - The 'v' can be left out - it is implied - or: - - [V] - 1List of words - 2Some words for the 2nd Verse + + [v1] + List of words + Another Line - 1Another Line - 2etc... - + [v2] + Some words for the 2nd verse + etc... + - Either or both forms can be used in one song. The Number does not - necessarily appear at the start of the line + The 'v' in the verse specifiers above can be left out, it is implied. + + An example of line grouping:: + + + [V] + 1List of words + 2Some words for the 2nd Verse + + 1Another Line + 2etc... + + + Either or both forms can be used in one song. The number does not + necessarily appear at the start of the line. Additionally, the [v1] labels + can have either upper or lower case Vs. - The [v1] labels can have either upper or lower case Vs Other labels can be used also: - C - Chorus - B - Bridge - Guitar chords can be provided 'above' the lyrics (the line is - preceeded by a'.') and _s can be used to signify long-drawn-out - words: + C + Chorus - . A7 Bm - 1 Some____ Words + B + Bridge - Chords and _s are removed by this importer. + All verses are imported and tagged appropriately. - The verses etc. are imported and tagged appropriately. + Guitar chords can be provided "above" the lyrics (the line is preceeded by + a period "."), and one or more "_" can be used to signify long-drawn-out + words. Chords and "_" are removed by this importer. For example:: - The tag is used to populate the OpenLP verse - display order field. The Author and Copyright tags are also - imported to the appropriate places. + . A7 Bm + 1 Some____ Words + + The tag is used to populate the OpenLP verse display order + field. The Author and Copyright tags are also imported to the appropriate + places. """ - def __init__(self, songmanager): + def __init__(self, manager, **kwargs): """ - Initialise the class. Requires a songmanager class which - is passed to SongImport for writing song to disk + Initialise the class. """ - self.songmanager = songmanager + SongImport.__init__(self, manager) + self.filenames = kwargs[u'filenames'] self.song = None + self.commit = True - def do_import(self, filename, commit=True): + def do_import(self): """ - Import either a single opensong file, or a zipfile - containing multiple opensong files If the commit parameter is - set False, the import will not be committed to the database - (useful for test scripts) + Import either a single opensong file, or a zipfile containing multiple + opensong files. If `self.commit` is set False, the import will not be + committed to the database (useful for test scripts). """ - ext = os.path.splitext(filename)[1] - if ext.lower() == ".zip": - log.info('Zipfile found %s', filename) - z = ZipFile(filename, u'r') - for song in z.infolist(): - parts = os.path.split(song.filename) - if parts[-1] == u'': - #No final part => directory - continue - songfile = z.open(song) - self.do_import_file(songfile) - if commit: + success = False + self.import_wizard.importProgressBar.setMaximum(len(self.filenames)) + for filename in self.filenames: + if self.stop_import_flag: + break + ext = os.path.splitext(filename)[1] + if ext.lower() == u'.zip': + log.debug(u'Zipfile found %s', filename) + z = ZipFile(filename, u'r') + for song in z.infolist(): + if self.stop_import_flag: + break + parts = os.path.split(song.filename) + if parts[-1] == u'': + #No final part => directory + continue + self.import_wizard.incrementProgressBar(u'Importing %s...' \ + % parts[-1]) + songfile = z.open(song) + self.do_import_file(songfile) + if self.commit: + self.finish() + if self.stop_import_flag: + break + else: + log.info('Direct import %s', filename) + self.import_wizard.incrementProgressBar(u'Importing %s...' \ + % os.path.split(filename)[-1]) + file = open(filename) + self.do_import_file(file) + if self.commit: self.finish() - else: - log.info('Direct import %s', filename) - file = open(filename) - self.do_import_file(file) - if commit: - self.finish() + if not self.commit: + self.finish() + - def do_import_file(self, file): """ Process the OpenSong file - pass in a file-like object, not a filename - """ - self.song_import = SongImport(self.songmanager) + """ tree = objectify.parse(file) root = tree.getroot() fields = dir(root) - decode = {u'copyright':self.song_import.add_copyright, - u'ccli':u'ccli_number', - u'author':self.song_import.parse_author, - u'title':u'title', - u'aka':u'alternate_title', - u'hymn_number':u'song_number'} + decode = { + u'copyright': self.add_copyright, + u'ccli': u'ccli_number', + u'author': self.parse_author, + u'title': u'title', + u'aka': u'alternate_title', + u'hymn_number': u'song_number' + } for (attr, fn_or_string) in decode.items(): if attr in fields: ustring = unicode(root.__getattr__(attr)) if type(fn_or_string) == type(u''): - self.song_import.__setattr__(fn_or_string, ustring) + self.__setattr__(fn_or_string, ustring) else: fn_or_string(ustring) - if u'theme' in fields: - self.song_import.topics.append(unicode(root.theme)) - if u'alttheme' in fields: - self.song_import.topics.append(unicode(root.alttheme)) + if u'theme' in fields and unicode(root.theme) not in self.topics: + self.topics.append(unicode(root.theme)) + if u'alttheme' in fields and unicode(root.alttheme) not in self.topics: + self.topics.append(unicode(root.alttheme)) # data storage while importing verses = {} lyrics = unicode(root.lyrics) @@ -158,6 +187,7 @@ class OpenSongImport(object): # in the absence of any other indication, verses are the default, # erm, versetype! versetype = u'V' + versenum = None for thisline in lyrics.split(u'\n'): # remove comments semicolon = thisline.find(u';') @@ -170,7 +200,6 @@ class OpenSongImport(object): if thisline[0] == u'.' or thisline.startswith(u'---') \ or thisline.startswith(u'-!!'): continue - # verse/chorus/etc. marker if thisline[0] == u'[': versetype = thisline[1].upper() @@ -186,7 +215,6 @@ class OpenSongImport(object): versenum = u'1' continue words = None - # number at start of line.. it's verse number if thisline[0].isdigit(): versenum = thisline[0] @@ -207,7 +235,7 @@ class OpenSongImport(object): our_verse_order.append(versetag) if words: # Tidy text and remove the ____s from extended words - words = self.song_import.tidy_text(words) + words = self.tidy_text(words) words = words.replace('_', '') verses[versetype][versenum].append(words) # done parsing @@ -220,7 +248,7 @@ class OpenSongImport(object): for num in versenums: versetag = u'%s%s' % (versetype, num) lines = u'\n'.join(verses[versetype][num]) - self.song_import.verses.append([versetag, lines]) + self.verses.append([versetag, lines]) # Keep track of what we have for error checking later versetags[versetag] = 1 # now figure out the presentation order @@ -236,8 +264,4 @@ class OpenSongImport(object): if not versetags.has_key(tag): log.warn(u'Got order %s but not in versetags, skipping', tag) else: - self.song_import.verse_order_list.append(tag) - - def finish(self): - """ Separate function, allows test suite to not pollute database""" - self.song_import.finish() + self.verse_order_list.append(tag) diff --git a/openlp/plugins/songs/lib/songimport.py b/openlp/plugins/songs/lib/songimport.py index 2ffb0beda..0bfebba47 100644 --- a/openlp/plugins/songs/lib/songimport.py +++ b/openlp/plugins/songs/lib/songimport.py @@ -236,7 +236,7 @@ class SongImport(QtCore.QObject): """ All fields have been set to this song. Write it away """ - if len(self.authors) == 0: + if not self.authors: self.authors.append(u'Author unknown') self.commit_song() From 2d9b39986a513e651e144ca50b726f26bf9dd0bc Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Sun, 29 Aug 2010 22:05:36 +0200 Subject: [PATCH 07/25] Some more fixes for the OpenSong import. --- openlp/plugins/songs/lib/opensongimport.py | 21 +++++++++++++++------ openlp/plugins/songs/lib/songimport.py | 3 +-- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/openlp/plugins/songs/lib/opensongimport.py b/openlp/plugins/songs/lib/opensongimport.py index ccf8479bf..d51ff5b49 100644 --- a/openlp/plugins/songs/lib/opensongimport.py +++ b/openlp/plugins/songs/lib/opensongimport.py @@ -28,6 +28,7 @@ import logging import os from zipfile import ZipFile from lxml import objectify +from lxml.etree import Error, LxmlError from openlp.plugins.songs.lib.songimport import SongImport @@ -156,7 +157,12 @@ class OpenSongImport(SongImport): Process the OpenSong file - pass in a file-like object, not a filename """ - tree = objectify.parse(file) + self.authors = [] + try: + tree = objectify.parse(file) + except Error, LxmlError: + log.exception(u'Error parsing XML') + return root = tree.getroot() fields = dir(root) decode = { @@ -167,11 +173,11 @@ class OpenSongImport(SongImport): u'aka': u'alternate_title', u'hymn_number': u'song_number' } - for (attr, fn_or_string) in decode.items(): + for attr, fn_or_string in decode.items(): if attr in fields: ustring = unicode(root.__getattr__(attr)) - if type(fn_or_string) == type(u''): - self.__setattr__(fn_or_string, ustring) + if isinstance(fn_or_string, basestring): + setattr(self, fn_or_string, ustring) else: fn_or_string(ustring) if u'theme' in fields and unicode(root.theme) not in self.topics: @@ -252,12 +258,15 @@ class OpenSongImport(SongImport): # Keep track of what we have for error checking later versetags[versetag] = 1 # now figure out the presentation order + order = [] if u'presentation' in fields and root.presentation != u'': order = unicode(root.presentation) order = order.split() else: - assert len(our_verse_order)>0 - order = our_verse_order + if len(our_verse_order) > 0: + order = our_verse_order + else: + log.warn(u'No verse order available for %s, skipping.', self.title) for tag in order: if len(tag) == 1: tag = tag + u'1' # Assume it's no.1 if it's not there diff --git a/openlp/plugins/songs/lib/songimport.py b/openlp/plugins/songs/lib/songimport.py index 0bfebba47..5889a3774 100644 --- a/openlp/plugins/songs/lib/songimport.py +++ b/openlp/plugins/songs/lib/songimport.py @@ -158,8 +158,7 @@ class SongImport(QtCore.QObject): def parse_author(self, text): """ Add the author. OpenLP stores them individually so split by 'and', '&' - and comma. - However need to check for 'Mr and Mrs Smith' and turn it to + and comma. However need to check for 'Mr and Mrs Smith' and turn it to 'Mr Smith' and 'Mrs Smith'. """ for author in text.split(u','): From 163bf9d2f4384ef6399667bce389e2f277b7e812 Mon Sep 17 00:00:00 2001 From: Philip Ridout Date: Sat, 4 Sep 2010 15:26:04 +0100 Subject: [PATCH 08/25] Corrected one line that was missed (not by me :-p) --- openlp/plugins/songs/lib/songimport.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/plugins/songs/lib/songimport.py b/openlp/plugins/songs/lib/songimport.py index bf5079c8c..63ef6a8ed 100644 --- a/openlp/plugins/songs/lib/songimport.py +++ b/openlp/plugins/songs/lib/songimport.py @@ -300,7 +300,7 @@ class SongImport(QtCore.QObject): topic = Topic.populate(name=topictext) song.topics.append(topic) self.manager.save_object(song) - self.setDefaults() + self.set_defaults() def print_song(self): """ From 62a031982e9da73bfc70a336404cabf1fcf91f43 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 4 Sep 2010 16:51:18 +0100 Subject: [PATCH 09/25] Renderer cleanup --- openlp/core/lib/renderer.py | 93 +++++++------------------------------ 1 file changed, 17 insertions(+), 76 deletions(-) diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index 39eff80bd..e7689d012 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -69,21 +69,11 @@ class Renderer(object): self.theme_name = theme.theme_name if theme.background_type == u'image': if theme.background_filename: - self.set_bg_image(theme.background_filename) - - def set_bg_image(self, filename): - """ - Set a background image. - - ``filename`` - The name of the image file. - """ - log.debug(u'set bg image %s', filename) - self._bg_image_filename = unicode(filename) - if self.frame: - self.bg_image = resize_image(self._bg_image_filename, - self.frame.width(), - self.frame.height()) + self._bg_image_filename = unicode(filename) + if self.frame: + self.bg_image = resize_image(self._bg_image_filename, + self.frame.width(), + self.frame.height()) def set_text_rectangle(self, rect_main, rect_footer): """ @@ -99,7 +89,7 @@ class Renderer(object): self._rect = rect_main self._rect_footer = rect_footer - def set_frame_dest(self, frame_width, frame_height, preview=False): + def set_frame_dest(self, frame_width, frame_height): """ Set the size of the slide. @@ -109,11 +99,7 @@ class Renderer(object): ``frame_height`` The height of the slide. - ``preview`` - Defaults to *False*. Whether or not to generate a preview. """ - if preview: - self.bg_frame = None log.debug(u'set frame dest (frame) w %d h %d', frame_width, frame_height) self.frame = QtGui.QImage(frame_width, frame_height, @@ -121,8 +107,17 @@ class Renderer(object): if self._bg_image_filename and not self.bg_image: self.bg_image = resize_image(self._bg_image_filename, self.frame.width(), self.frame.height()) - if self.bg_frame is None: - self._generate_background_frame() + if self._theme.background_type == u'image': + self.bg_frame = QtGui.QImage(self.frame.width(), + self.frame.height(), QtGui.QImage.Format_ARGB32_Premultiplied) + painter = QtGui.QPainter() + painter.begin(self.bg_frame) + painter.fillRect(self.frame.rect(), QtCore.Qt.black) + if self.bg_image: + painter.drawImage(0, 0, self.bg_image) + painter.end() + else: + self.bg_frame = None def format_slide(self, words, line_break): """ @@ -180,57 +175,3 @@ class Renderer(object): formatted.append(shell % old_html_text) log.debug(u'format_slide - End') return formatted - - def _generate_background_frame(self): - """ - Generate a background frame to the same size as the frame to be used. - Results are cached for performance reasons. - """ - assert(self._theme) - self.bg_frame = QtGui.QImage(self.frame.width(), - self.frame.height(), QtGui.QImage.Format_ARGB32_Premultiplied) - log.debug(u'render background %s start', self._theme.background_type) - if self._theme.background_type == u'solid': - self.bg_frame = None -# painter.fillRect(self.frame.rect(), -# QtGui.QColor(self._theme.background_color)) - elif self._theme.background_type == u'gradient': - self.bg_frame = None - # gradient -# gradient = None -# if self._theme.background_direction == u'horizontal': -# w = int(self.frame.width()) / 2 -# # vertical -# gradient = QtGui.QLinearGradient(w, 0, w, self.frame.height()) -# elif self._theme.background_direction == u'vertical': -# h = int(self.frame.height()) / 2 -# # Horizontal -# gradient = QtGui.QLinearGradient(0, h, self.frame.width(), h) -# else: -# w = int(self.frame.width()) / 2 -# h = int(self.frame.height()) / 2 -# # Circular -# gradient = QtGui.QRadialGradient(w, h, w) -# gradient.setColorAt(0, -# QtGui.QColor(self._theme.background_startColor)) -# gradient.setColorAt(1, -# QtGui.QColor(self._theme.background_endColor)) -# painter.setBrush(QtGui.QBrush(gradient)) -# rect_path = QtGui.QPainterPath() -# max_x = self.frame.width() -# max_y = self.frame.height() -# rect_path.moveTo(0, 0) -# rect_path.lineTo(0, max_y) -# rect_path.lineTo(max_x, max_y) -# rect_path.lineTo(max_x, 0) -# rect_path.closeSubpath() -# painter.drawPath(rect_path) -# painter.end() - elif self._theme.background_type == u'image': - # image - painter = QtGui.QPainter() - painter.begin(self.bg_frame) - painter.fillRect(self.frame.rect(), QtCore.Qt.black) - if self.bg_image: - painter.drawImage(0, 0, self.bg_image) - painter.end() From b9bb5b8c4fdc66d049985fdb5d09694cf8a71108 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 4 Sep 2010 17:14:56 +0100 Subject: [PATCH 10/25] Cleanups --- openlp/core/lib/renderer.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index 5a98faaff..0cb92ad39 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -70,7 +70,7 @@ class Renderer(object): self.theme_name = theme.theme_name if theme.background_type == u'image': if theme.background_filename: - self._bg_image_filename = unicode(filename) + self._bg_image_filename = unicode(theme.background_filename) if self.frame: self.bg_image = resize_image(self._bg_image_filename, self.frame.width(), @@ -138,14 +138,14 @@ class Renderer(object): for verse in verses_text: lines = verse.split(u'\n') for line in lines: - text.append(line) + text.append(line) web = QtWebKit.QWebView() web.resize(self._rect.width(), self._rect.height()) web.setVisible(False) frame = web.page().mainFrame() # Adjust width and height to account for shadow. outline done in css - width = self._rect.width() - int(self._theme.display_shadow_size) - height = self._rect.height() - int(self._theme.display_shadow_size) + width = self._rect.width() - int(self._theme.display_shadow_size) + height = self._rect.height() - int(self._theme.display_shadow_size) shell = u'' \ u'
' % \ (build_lyrics_format_css(self._theme, width, height), From cd9a7d49515336e443dcde24846369afe97c123d Mon Sep 17 00:00:00 2001 From: Philip Ridout Date: Sat, 4 Sep 2010 17:36:07 +0100 Subject: [PATCH 11/25] Changed with and height arround on the general tab. This brings it in line with the standard way of specifing a screen res, as well as bring it in line with the x & y cords before the height and width! --- openlp/core/ui/generaltab.py | 50 ++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/openlp/core/ui/generaltab.py b/openlp/core/ui/generaltab.py index bc050b6f9..0e18b249b 100644 --- a/openlp/core/ui/generaltab.py +++ b/openlp/core/ui/generaltab.py @@ -195,6 +195,19 @@ class GeneralTab(SettingsTab): self.currentYValueLabel.setObjectName(u'currentYValueLabel') self.currentYLayout.addWidget(self.currentYValueLabel) self.currentLayout.addLayout(self.currentYLayout) + self.currentWidthLayout = QtGui.QVBoxLayout() + self.currentWidthLayout.setSpacing(0) + self.currentWidthLayout.setMargin(0) + self.currentWidthLayout.setObjectName(u'currentWidthLayout') + self.currentWidthLabel = QtGui.QLabel(self.displayGroupBox) + self.currentWidthLabel.setAlignment(QtCore.Qt.AlignCenter) + self.currentWidthLabel.setObjectName(u'currentWidthLabel') + self.currentWidthLayout.addWidget(self.currentWidthLabel) + self.currentWidthValueLabel = QtGui.QLabel(self.displayGroupBox) + self.currentWidthValueLabel.setAlignment(QtCore.Qt.AlignCenter) + self.currentWidthValueLabel.setObjectName(u'currentWidthValueLabel') + self.currentWidthLayout.addWidget(self.currentWidthValueLabel) + self.currentLayout.addLayout(self.currentWidthLayout) self.currentHeightLayout = QtGui.QVBoxLayout() self.currentHeightLayout.setSpacing(0) self.currentHeightLayout.setMargin(0) @@ -209,19 +222,6 @@ class GeneralTab(SettingsTab): self.currentHeightValueLabel.setObjectName(u'Height') self.currentHeightLayout.addWidget(self.currentHeightValueLabel) self.currentLayout.addLayout(self.currentHeightLayout) - self.currentWidthLayout = QtGui.QVBoxLayout() - self.currentWidthLayout.setSpacing(0) - self.currentWidthLayout.setMargin(0) - self.currentWidthLayout.setObjectName(u'currentWidthLayout') - self.currentWidthLabel = QtGui.QLabel(self.displayGroupBox) - self.currentWidthLabel.setAlignment(QtCore.Qt.AlignCenter) - self.currentWidthLabel.setObjectName(u'currentWidthLabel') - self.currentWidthLayout.addWidget(self.currentWidthLabel) - self.currentWidthValueLabel = QtGui.QLabel(self.displayGroupBox) - self.currentWidthValueLabel.setAlignment(QtCore.Qt.AlignCenter) - self.currentWidthValueLabel.setObjectName(u'currentWidthValueLabel') - self.currentWidthLayout.addWidget(self.currentWidthValueLabel) - self.currentLayout.addLayout(self.currentWidthLayout) self.displayLayout.addLayout(self.currentLayout) self.overrideCheckBox = QtGui.QCheckBox(self.displayGroupBox) self.overrideCheckBox.setObjectName(u'overrideCheckBox') @@ -256,18 +256,6 @@ class GeneralTab(SettingsTab): self.customYValueEdit.setObjectName(u'customYValueEdit') self.customYLayout.addWidget(self.customYValueEdit) self.customLayout.addLayout(self.customYLayout) - self.customHeightLayout = QtGui.QVBoxLayout() - self.customHeightLayout.setSpacing(0) - self.customHeightLayout.setMargin(0) - self.customHeightLayout.setObjectName(u'customHeightLayout') - self.customHeightLabel = QtGui.QLabel(self.displayGroupBox) - self.customHeightLabel.setAlignment(QtCore.Qt.AlignCenter) - self.customHeightLabel.setObjectName(u'customHeightLabel') - self.customHeightLayout.addWidget(self.customHeightLabel) - self.customHeightValueEdit = QtGui.QLineEdit(self.displayGroupBox) - self.customHeightValueEdit.setObjectName(u'customHeightValueEdit') - self.customHeightLayout.addWidget(self.customHeightValueEdit) - self.customLayout.addLayout(self.customHeightLayout) self.customWidthLayout = QtGui.QVBoxLayout() self.customWidthLayout.setSpacing(0) self.customWidthLayout.setMargin(0) @@ -281,6 +269,18 @@ class GeneralTab(SettingsTab): self.customWidthValueEdit.setObjectName(u'customWidthValueEdit') self.customWidthLayout.addWidget(self.customWidthValueEdit) self.customLayout.addLayout(self.customWidthLayout) + self.customHeightLayout = QtGui.QVBoxLayout() + self.customHeightLayout.setSpacing(0) + self.customHeightLayout.setMargin(0) + self.customHeightLayout.setObjectName(u'customHeightLayout') + self.customHeightLabel = QtGui.QLabel(self.displayGroupBox) + self.customHeightLabel.setAlignment(QtCore.Qt.AlignCenter) + self.customHeightLabel.setObjectName(u'customHeightLabel') + self.customHeightLayout.addWidget(self.customHeightLabel) + self.customHeightValueEdit = QtGui.QLineEdit(self.displayGroupBox) + self.customHeightValueEdit.setObjectName(u'customHeightValueEdit') + self.customHeightLayout.addWidget(self.customHeightValueEdit) + self.customLayout.addLayout(self.customHeightLayout) self.displayLayout.addLayout(self.customLayout) # Bottom spacer self.generalRightSpacer = QtGui.QSpacerItem(20, 40, From 20844c8d289636d063b6569f44d0bb9bfce1aee8 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 4 Sep 2010 18:39:03 +0100 Subject: [PATCH 12/25] Fix CCLI for songs Fixes: https://launchpad.net/bugs/622894 --- openlp/plugins/songs/lib/mediaitem.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 85ba1cf06..9f14698ee 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -359,16 +359,13 @@ class SongMediaItem(MediaManagerItem): author_list = author_list + u', ' author_list = author_list + unicode(author.display_name) author_audit.append(unicode(author.display_name)) - if song.ccli_number is None or len(song.ccli_number) == 0: - ccli = QtCore.QSettings().value(u'general/ccli number', - QtCore.QVariant(u'')).toString() - else: - ccli = unicode(song.ccli_number) raw_footer.append(song.title) raw_footer.append(author_list) raw_footer.append(song.copyright ) raw_footer.append(unicode( - translate('SongsPlugin.MediaItem', 'CCLI Licence: ') + ccli)) + translate('SongsPlugin.MediaItem', 'CCLI Licence: ') + + QtCore.QSettings().value(u'general/ccli number', + QtCore.QVariant(u'')).toString())) service_item.raw_footer = raw_footer service_item.audit = [ song.title, author_audit, song.copyright, unicode(song.ccli_number) From 2901c79ed6dbd5ce78bb724451b767a1f84e3da6 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Sat, 4 Sep 2010 19:51:41 +0200 Subject: [PATCH 13/25] Start work on the openlp.org 1.x importer. Add a couple of fixes to the song import. Add a few fixes to the OpenSong importer. --- openlp/plugins/songs/lib/olp1import.py | 102 +++++++-------------- openlp/plugins/songs/lib/opensongimport.py | 5 + openlp/plugins/songs/lib/songimport.py | 7 +- 3 files changed, 44 insertions(+), 70 deletions(-) diff --git a/openlp/plugins/songs/lib/olp1import.py b/openlp/plugins/songs/lib/olp1import.py index 1625bfff2..ae386335a 100644 --- a/openlp/plugins/songs/lib/olp1import.py +++ b/openlp/plugins/songs/lib/olp1import.py @@ -52,7 +52,6 @@ class OpenLP1SongImport(SongImport): The database providing the data to import. """ SongImport.__init__(self, manager) - self.manager = manager self.import_source = kwargs[u'filename'] def do_import(self): @@ -61,71 +60,38 @@ class OpenLP1SongImport(SongImport): """ connection = sqlite.connect(self.import_source) cursor = connection.cursor() + cursor.execute(u'SELECT COUNT(authorid) FROM authors') + count = int(cursor.fetchone()[0]) + cursor.execute(u'SELECT COUNT(songid) FROM songs') + count = int(cursor.fetchone()[0]) + self.import_wizard.importProgressBar.setMaximum(count) -# for song in source_songs: -# new_song = Song() -# new_song.title = song.title -# if has_media_files: -# new_song.alternate_title = song.alternate_title -# else: -# old_titles = song.search_title.split(u'@') -# if len(old_titles) > 1: -# new_song.alternate_title = old_titles[1] -# else: -# new_song.alternate_title = u'' -# new_song.search_title = song.search_title -# new_song.song_number = song.song_number -# new_song.lyrics = song.lyrics -# new_song.search_lyrics = song.search_lyrics -# new_song.verse_order = song.verse_order -# new_song.copyright = song.copyright -# new_song.comments = song.comments -# new_song.theme_name = song.theme_name -# new_song.ccli_number = song.ccli_number -# if song.authors: -# for author in song.authors: -# existing_author = self.master_manager.get_object_filtered( -# Author, Author.display_name == author.display_name) -# if existing_author: -# new_song.authors.append(existing_author) -# else: -# new_song.authors.append(Author.populate( -# first_name=author.first_name, -# last_name=author.last_name, -# display_name=author.display_name)) -# else: -# au = self.master_manager.get_object_filtered(Author, -# Author.display_name == u'Author Unknown') -# if au: -# new_song.authors.append(au) -# else: -# new_song.authors.append(Author.populate( -# display_name=u'Author Unknown')) -# if song.book: -# existing_song_book = self.master_manager.get_object_filtered( -# Book, Book.name == song.book.name) -# if existing_song_book: -# new_song.book = existing_song_book -# else: -# new_song.book = Book.populate(name=song.book.name, -# publisher=song.book.publisher) -# if song.topics: -# for topic in song.topics: -# existing_topic = self.master_manager.get_object_filtered( -# Topic, Topic.name == topic.name) -# if existing_topic: -# new_song.topics.append(existing_topic) -# else: -# new_song.topics.append(Topic.populate(name=topic.name)) -## if has_media_files: -## if song.media_files: -## for media_file in song.media_files: -## existing_media_file = \ -## self.master_manager.get_object_filtered(MediaFile, -## MediaFile.file_name == media_file.file_name) -## if existing_media_file: -## new_song.media_files.append(existing_media_file) -## else: -## new_song.media_files.append(MediaFile.populate( -## file_name=media_file.file_name)) -# self.master_manager.save_object(new_song) + old_cursor.execute(u'SELECT authorid AS id, authorname AS displayname FROM authors') + rows = old_cursor.fetchall() + if not debug and verbose: + print 'done.' + author_map = {} + for row in rows: + display_name = unicode(row[1], u'cp1252') + names = display_name.split(u' ') + first_name = names[0] + last_name = u' '.join(names[1:]) + if last_name is None: + last_name = u'' + sql_insert = u'INSERT INTO authors '\ + '(id, first_name, last_name, display_name) '\ + 'VALUES (NULL, ?, ?, ?)' + sql_params = (first_name, last_name, display_name) + if debug: + print '...', display_sql(sql_insert, sql_params) + elif verbose: + print '... importing "%s"' % display_name + new_cursor.execute(sql_insert, sql_params) + author_map[row[0]] = new_cursor.lastrowid + if debug: + print ' >>> authors.authorid =', row[0], 'authors.id =', author_map[row[0]] + + + cursor.execute(u'SELECT songid AS id, songtitle AS title, ' + u'lyrics || \'\' AS lyrics, copyrightinfo AS copyright FROM songs') + rows = cursor.fetchall() diff --git a/openlp/plugins/songs/lib/opensongimport.py b/openlp/plugins/songs/lib/opensongimport.py index d51ff5b49..5666fe0eb 100644 --- a/openlp/plugins/songs/lib/opensongimport.py +++ b/openlp/plugins/songs/lib/opensongimport.py @@ -125,6 +125,9 @@ class OpenSongImport(SongImport): if ext.lower() == u'.zip': log.debug(u'Zipfile found %s', filename) z = ZipFile(filename, u'r') + self.import_wizard.importProgressBar.setMaximum( + self.import_wizard.importProgressBar.maximum() + + len(z.infolist())) for song in z.infolist(): if self.stop_import_flag: break @@ -138,6 +141,7 @@ class OpenSongImport(SongImport): self.do_import_file(songfile) if self.commit: self.finish() + self.set_defaults() if self.stop_import_flag: break else: @@ -148,6 +152,7 @@ class OpenSongImport(SongImport): self.do_import_file(file) if self.commit: self.finish() + self.set_defaults() if not self.commit: self.finish() diff --git a/openlp/plugins/songs/lib/songimport.py b/openlp/plugins/songs/lib/songimport.py index 5889a3774..60cdfd969 100644 --- a/openlp/plugins/songs/lib/songimport.py +++ b/openlp/plugins/songs/lib/songimport.py @@ -52,6 +52,11 @@ class SongImport(QtCore.QObject): """ self.manager = manager self.stop_import_flag = False + self.set_defaults() + QtCore.QObject.connect(Receiver.get_receiver(), + QtCore.SIGNAL(u'songs_stop_import'), self.stop_import) + + def set_defaults(self): self.title = u'' self.song_number = u'' self.alternate_title = u'' @@ -71,8 +76,6 @@ class SongImport(QtCore.QObject): 'SongsPlugin.SongImport', 'copyright')) self.copyright_symbol = unicode(translate( 'SongsPlugin.SongImport', '\xa9')) - QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'songs_stop_import'), self.stop_import) def stop_import(self): """ From e2c117034a0471b1d3ae18e778561dc1097ecac2 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 4 Sep 2010 20:40:28 +0100 Subject: [PATCH 14/25] Fix up bug for bible settings of duel drop down Fixes: https://launchpad.net/bugs/629848 --- openlp/core/ui/generaltab.py | 1 - openlp/core/ui/settingsform.py | 3 +++ openlp/plugins/bibles/lib/biblestab.py | 10 +++++----- openlp/plugins/bibles/lib/mediaitem.py | 3 ++- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/openlp/core/ui/generaltab.py b/openlp/core/ui/generaltab.py index 0e18b249b..d8481e801 100644 --- a/openlp/core/ui/generaltab.py +++ b/openlp/core/ui/generaltab.py @@ -476,7 +476,6 @@ class GeneralTab(SettingsTab): # Order is important so be careful if you change if self.overrideChanged or postUpdate: Receiver.send_message(u'config_screen_changed') - Receiver.send_message(u'config_updated') self.overrideChanged = False def onOverrideCheckBoxToggled(self, checked): diff --git a/openlp/core/ui/settingsform.py b/openlp/core/ui/settingsform.py index 97f2aebaf..37fe1f329 100644 --- a/openlp/core/ui/settingsform.py +++ b/openlp/core/ui/settingsform.py @@ -30,6 +30,7 @@ import logging from PyQt4 import QtGui +from openlp.core.lib import Receiver from openlp.core.ui import AdvancedTab, GeneralTab, ThemesTab from settingsdialog import Ui_SettingsDialog @@ -87,6 +88,8 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog): """ for tabIndex in range(0, self.settingsTabWidget.count()): self.settingsTabWidget.widget(tabIndex).save() + # Must go after all settings are save + Receiver.send_message(u'config_updated') return QtGui.QDialog.accept(self) def postSetUp(self): diff --git a/openlp/plugins/bibles/lib/biblestab.py b/openlp/plugins/bibles/lib/biblestab.py index 8399ee1d4..0903c9625 100644 --- a/openlp/plugins/bibles/lib/biblestab.py +++ b/openlp/plugins/bibles/lib/biblestab.py @@ -196,10 +196,10 @@ class BiblesTab(SettingsTab): self.show_new_chapters = True def onBibleDualCheckBox(self, check_state): - self.duel_bibles = False + self.dual_bibles = False # we have a set value convert to True/False if check_state == QtCore.Qt.Checked: - self.duel_bibles = True + self.dual_bibles = True def load(self): settings = QtCore.QSettings() @@ -212,12 +212,12 @@ class BiblesTab(SettingsTab): u'verse layout style', QtCore.QVariant(0)).toInt()[0] self.bible_theme = unicode( settings.value(u'bible theme', QtCore.QVariant(u'')).toString()) - self.duel_bibles = settings.value( + self.dual_bibles = settings.value( u'dual bibles', QtCore.QVariant(True)).toBool() self.NewChaptersCheckBox.setChecked(self.show_new_chapters) self.DisplayStyleComboBox.setCurrentIndex(self.display_style) self.LayoutStyleComboBox.setCurrentIndex(self.layout_style) - self.BibleDualCheckBox.setChecked(self.duel_bibles) + self.BibleDualCheckBox.setChecked(self.dual_bibles) settings.endGroup() def save(self): @@ -229,7 +229,7 @@ class BiblesTab(SettingsTab): QtCore.QVariant(self.display_style)) settings.setValue(u'verse layout style', QtCore.QVariant(self.layout_style)) - settings.setValue(u'dual bibles', QtCore.QVariant(self.duel_bibles)) + settings.setValue(u'dual bibles', QtCore.QVariant(self.dual_bibles)) settings.setValue(u'bible theme', QtCore.QVariant(self.bible_theme)) settings.endGroup() diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index e7850c65c..57e70617a 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -275,8 +275,9 @@ class BibleMediaItem(MediaManagerItem): self.SearchProgress.setObjectName(u'SearchProgress') def configUpdated(self): + log.debug(u'configUpdated') if QtCore.QSettings().value(self.settingsSection + u'/dual bibles', - QtCore.QVariant(False)).toBool(): + QtCore.QVariant(True)).toBool(): self.AdvancedSecondBibleLabel.setVisible(True) self.AdvancedSecondBibleComboBox.setVisible(True) self.QuickSecondVersionLabel.setVisible(True) From aa0f4f7af0745702f570dbe4aad01c1f79c397bf Mon Sep 17 00:00:00 2001 From: Jonathan Corwin Date: Sun, 5 Sep 2010 16:16:48 +0100 Subject: [PATCH 15/25] Finish wizard integration --- openlp/plugins/songs/lib/oooimport.py | 3 +++ openlp/plugins/songs/lib/sofimport.py | 3 +++ openlp/plugins/songs/lib/songimport.py | 8 ++++---- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/openlp/plugins/songs/lib/oooimport.py b/openlp/plugins/songs/lib/oooimport.py index 9a3be2843..e8c723c0e 100644 --- a/openlp/plugins/songs/lib/oooimport.py +++ b/openlp/plugins/songs/lib/oooimport.py @@ -82,6 +82,9 @@ class OooImport(SongImport): self.process_doc() self.close_ooo_file() self.close_ooo() + self.import_wizard.importProgressBar.setMaximum(1) + self.import_wizard.incrementProgressBar(u'', 1) + return True def stop_import(self): self.abort = True diff --git a/openlp/plugins/songs/lib/sofimport.py b/openlp/plugins/songs/lib/sofimport.py index 0d7c085de..ab91e1923 100644 --- a/openlp/plugins/songs/lib/sofimport.py +++ b/openlp/plugins/songs/lib/sofimport.py @@ -89,6 +89,9 @@ class SofImport(OooImport): self.process_sof_file() self.close_ooo_file() self.close_ooo() + self.import_wizard.importProgressBar.setMaximum(1) + self.import_wizard.incrementProgressBar(u'', 1) + return True def process_sof_file(self): """ diff --git a/openlp/plugins/songs/lib/songimport.py b/openlp/plugins/songs/lib/songimport.py index 63ef6a8ed..17000a2ba 100644 --- a/openlp/plugins/songs/lib/songimport.py +++ b/openlp/plugins/songs/lib/songimport.py @@ -129,13 +129,13 @@ class SongImport(QtCore.QObject): def process_verse_text(self, text): lines = text.split(u'\n') - if text.lower().find(COPYRIGHT_STRING) >= 0 \ - or text.lower().find(COPYRIGHT_SYMBOL) >= 0: + if text.lower().find(self.copyright_string) >= 0 \ + or text.lower().find(self.copyright_symbol) >= 0: copyright_found = False for line in lines: if (copyright_found or - line.lower().find(COPYRIGHT_STRING) >= 0 or - line.lower().find(COPYRIGHT_SYMBOL) >= 0): + line.lower().find(self.copyright_string) >= 0 or + line.lower().find(self.copyright_symbol) >= 0): copyright_found = True self.add_copyright(line) else: From a4d8e225c0f8c5ff1f6c662a9b763a55bc8544d6 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 5 Sep 2010 17:11:50 +0100 Subject: [PATCH 16/25] Allow images to blank to theme. As none defined cos it's an image use global Fixes: https://launchpad.net/bugs/630254 --- openlp/core/lib/htmlbuilder.py | 23 ++++++++++++----------- openlp/core/lib/rendermanager.py | 2 ++ openlp/core/lib/serviceitem.py | 1 + 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/openlp/core/lib/htmlbuilder.py b/openlp/core/lib/htmlbuilder.py index 9c696526e..acf00bdeb 100644 --- a/openlp/core/lib/htmlbuilder.py +++ b/openlp/core/lib/htmlbuilder.py @@ -145,6 +145,7 @@ body { } document.getElementById('black').style.display = black; document.getElementById('lyricsmain').style.visibility = lyrics; + document.getElementById('image').style.visibility = lyrics; outline = document.getElementById('lyricsoutline') if(outline!=null) outline.style.visibility = lyrics; @@ -327,7 +328,7 @@ def build_background_css(item, width, height): else: background = \ u'background: -webkit-gradient(radial, %s 50%%, 100, %s ' \ - u'50%%, %s, from(%s), to(%s))' % (width, width, width, + u'50%%, %s, from(%s), to(%s))' % (width, width, width, theme.background_startColor, theme.background_endColor) return background @@ -370,10 +371,10 @@ def build_lyrics_css(item, webkitvers): lyricsmain = u'' outline = u'' shadow = u'' - if theme: + if theme and item.main: lyricstable = u'left: %spx; top: %spx;' % \ (item.main.x(), item.main.y()) - lyrics = build_lyrics_format_css(theme, item.main.width(), + lyrics = build_lyrics_format_css(theme, item.main.width(), item.main.height()) # For performance reasons we want to show as few DIV's as possible, # especially when animating/transitions. @@ -393,7 +394,7 @@ def build_lyrics_css(item, webkitvers): if webkitvers >= 533.3: lyricsmain += build_lyrics_outline_css(theme) else: - outline = build_lyrics_outline_css(theme) + outline = build_lyrics_outline_css(theme) if theme.display_shadow: if theme.display_outline and webkitvers < 534.3: shadow = u'padding-left: %spx; padding-top: %spx ' % \ @@ -405,7 +406,7 @@ def build_lyrics_css(item, webkitvers): theme.display_shadow_size) lyrics_css = style % (lyricstable, lyrics, lyricsmain, outline, shadow) return lyrics_css - + def build_lyrics_outline_css(theme, is_shadow=False): """ Build the css which controls the theme outline @@ -413,7 +414,7 @@ def build_lyrics_outline_css(theme, is_shadow=False): `theme` Object containing theme information - + `is_shadow` If true, use the shadow colors instead """ @@ -437,7 +438,7 @@ def build_lyrics_format_css(theme, width, height): `theme` Object containing theme information - + `width` Width of the lyrics block @@ -461,8 +462,8 @@ def build_lyrics_format_css(theme, width, height): 'text-align: %s; vertical-align: %s; font-family: %s; ' \ 'font-size: %spt; color: %s; line-height: %d%%; ' \ 'margin:0; padding:0; width: %spx; height: %spx; ' % \ - (align, valign, theme.font_main_name, theme.font_main_proportion, - theme.font_main_color, 100 + int(theme.font_main_line_adjustment), + (align, valign, theme.font_main_name, theme.font_main_proportion, + theme.font_main_color, 100 + int(theme.font_main_line_adjustment), width, height) if theme.display_outline: if webkit_version() < 534.3: @@ -472,7 +473,7 @@ def build_lyrics_format_css(theme, width, height): if theme.font_main_weight == u'Bold': lyrics += u' font-weight:bold; ' return lyrics - + def build_lyrics_html(item, webkitvers): """ Build the HTML required to show the lyrics @@ -520,7 +521,7 @@ def build_footer_css(item): text-align: %s; """ theme = item.themedata - if not theme: + if not theme or not item.footer: return u'' if theme.display_horizontalAlign == 2: align = u'center' diff --git a/openlp/core/lib/rendermanager.py b/openlp/core/lib/rendermanager.py index 6be26bd82..a6e494b01 100644 --- a/openlp/core/lib/rendermanager.py +++ b/openlp/core/lib/rendermanager.py @@ -93,6 +93,8 @@ class RenderManager(object): """ self.global_theme = global_theme self.theme_level = theme_level + self.global_theme_data = \ + self.theme_manager.getThemeData(self.global_theme) self.themedata = None def set_service_theme(self, service_theme): diff --git a/openlp/core/lib/serviceitem.py b/openlp/core/lib/serviceitem.py index 0e8625ce7..b0d453af5 100644 --- a/openlp/core/lib/serviceitem.py +++ b/openlp/core/lib/serviceitem.py @@ -170,6 +170,7 @@ class ServiceItem(object): u'verseTag': slide[u'verseTag'] }) log.log(15, u'Formatting took %4s' % (time.time() - before)) elif self.service_item_type == ServiceItemType.Image: + self.themedata = self.render_manager.global_theme_data for slide in self._raw_frames: slide[u'image'] = resize_image(slide[u'image'], self.render_manager.width, self.render_manager.height) From 91eff095a55471d3acbd22b0760b1aeb424420dc Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 5 Sep 2010 20:52:49 +0100 Subject: [PATCH 17/25] Fix hiding of screen and adding items behind it and showing them. Fixes: https://launchpad.net/bugs/630285 --- openlp/core/ui/maindisplay.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index e682a3a0f..3e0b070b9 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -97,6 +97,7 @@ class MainDisplay(DisplayWidget): self.screens = screens self.isLive = live self.alertTab = None + self.hide_mode = None self.setWindowTitle(u'OpenLP Display') self.setWindowFlags(QtCore.Qt.FramelessWindowHint | QtCore.Qt.WindowStaysOnTopHint) @@ -340,6 +341,9 @@ class MainDisplay(DisplayWidget): self.webView.setHtml(html) if serviceItem.foot_text and serviceItem.foot_text: self.footer(serviceItem.foot_text) + # if was hidden keep it hidden + if self.hide_mode and self.isLive: + self.hideDisplay(self.hide_mode) def footer(self, text): """ @@ -365,6 +369,7 @@ class MainDisplay(DisplayWidget): self.frame.evaluateJavaScript(u'show_blank("theme");') if mode != HideMode.Screen and self.isHidden(): self.setVisible(True) + self.hide_mode = mode def showDisplay(self): """ @@ -378,6 +383,7 @@ class MainDisplay(DisplayWidget): self.setVisible(True) # Trigger actions when display is active again Receiver.send_message(u'maindisplay_active') + self.hide_mode = None class AudioPlayer(QtCore.QObject): """ From f82513f11d77aebb97e3530eadf663f6e1897b66 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Mon, 6 Sep 2010 22:33:28 +0200 Subject: [PATCH 18/25] Finally done the openlp.org 1.x song importer. --- openlp/plugins/songs/lib/olp1import.py | 80 +++++++++++++--------- openlp/plugins/songs/lib/opensongimport.py | 17 +++-- openlp/plugins/songs/lib/songimport.py | 20 +++++- 3 files changed, 76 insertions(+), 41 deletions(-) diff --git a/openlp/plugins/songs/lib/olp1import.py b/openlp/plugins/songs/lib/olp1import.py index ae386335a..ab3e0d720 100644 --- a/openlp/plugins/songs/lib/olp1import.py +++ b/openlp/plugins/songs/lib/olp1import.py @@ -58,40 +58,56 @@ class OpenLP1SongImport(SongImport): """ Run the import for an openlp.org 1.x song database. """ + # Connect to the database connection = sqlite.connect(self.import_source) cursor = connection.cursor() - cursor.execute(u'SELECT COUNT(authorid) FROM authors') - count = int(cursor.fetchone()[0]) + # Count the number of records we need to import, for the progress bar cursor.execute(u'SELECT COUNT(songid) FROM songs') count = int(cursor.fetchone()[0]) + success = True self.import_wizard.importProgressBar.setMaximum(count) - - old_cursor.execute(u'SELECT authorid AS id, authorname AS displayname FROM authors') - rows = old_cursor.fetchall() - if not debug and verbose: - print 'done.' - author_map = {} - for row in rows: - display_name = unicode(row[1], u'cp1252') - names = display_name.split(u' ') - first_name = names[0] - last_name = u' '.join(names[1:]) - if last_name is None: - last_name = u'' - sql_insert = u'INSERT INTO authors '\ - '(id, first_name, last_name, display_name) '\ - 'VALUES (NULL, ?, ?, ?)' - sql_params = (first_name, last_name, display_name) - if debug: - print '...', display_sql(sql_insert, sql_params) - elif verbose: - print '... importing "%s"' % display_name - new_cursor.execute(sql_insert, sql_params) - author_map[row[0]] = new_cursor.lastrowid - if debug: - print ' >>> authors.authorid =', row[0], 'authors.id =', author_map[row[0]] - - - cursor.execute(u'SELECT songid AS id, songtitle AS title, ' - u'lyrics || \'\' AS lyrics, copyrightinfo AS copyright FROM songs') - rows = cursor.fetchall() + # Import the songs + cursor.execute(u'SELECT songid, songtitle, lyrics || \'\' AS lyrics, ' + u'copyrightinfo FROM songs') + songs = cursor.fetchall() + for song in songs: + self.set_defaults() + if self.stop_import_flag: + success = False + break + song_id = song[0] + title = unicode(song[1], u'cp1252') + lyrics = unicode(song[2], u'cp1252') + copyright = unicode(song[3], u'cp1252') + self.import_wizard.incrementProgressBar( + unicode(translate('SongsPlugin.ImportWizardForm', + 'Importing %s...')) % title) + self.title = title + self.process_song_text(lyrics) + self.add_copyright(copyright) + cursor.execute(u'SELECT displayname FROM authors a ' + u'JOIN songauthors sa ON a.authorid = sa.authorid ' + u'WHERE sa.songid = %s' % song_id) + authors = cursor.fetchall() + for author in authors: + if self.stop_import_flag: + success = False + break + self.parse_author(unicode(author[0], u'cp1252')) + if self.stop_import_flag: + success = False + break + cursor.execute(u'SELECT fulltrackname FROM tracks t ' + u'JOIN songtracks st ON t.trackid = st.trackid ' + u'WHERE st.songid = %s ORDER BY st.listindex' % song_id) + tracks = cursor.fetchall() + for track in tracks: + if self.stop_import_flag: + success = False + break + self.add_media_file(unicode(track[0], u'cp1252')) + if self.stop_import_flag: + success = False + break + self.finish() + return success diff --git a/openlp/plugins/songs/lib/opensongimport.py b/openlp/plugins/songs/lib/opensongimport.py index 5666fe0eb..f6048d566 100644 --- a/openlp/plugins/songs/lib/opensongimport.py +++ b/openlp/plugins/songs/lib/opensongimport.py @@ -116,10 +116,11 @@ class OpenSongImport(SongImport): opensong files. If `self.commit` is set False, the import will not be committed to the database (useful for test scripts). """ - success = False + success = True self.import_wizard.importProgressBar.setMaximum(len(self.filenames)) for filename in self.filenames: if self.stop_import_flag: + success = False break ext = os.path.splitext(filename)[1] if ext.lower() == u'.zip': @@ -130,24 +131,28 @@ class OpenSongImport(SongImport): len(z.infolist())) for song in z.infolist(): if self.stop_import_flag: + success = False break parts = os.path.split(song.filename) if parts[-1] == u'': #No final part => directory continue - self.import_wizard.incrementProgressBar(u'Importing %s...' \ - % parts[-1]) + self.import_wizard.incrementProgressBar( + unicode(translate('SongsPlugin.ImportWizardForm', + 'Importing %s...')) % parts[-1]) songfile = z.open(song) self.do_import_file(songfile) if self.commit: self.finish() self.set_defaults() if self.stop_import_flag: + success = False break else: log.info('Direct import %s', filename) - self.import_wizard.incrementProgressBar(u'Importing %s...' \ - % os.path.split(filename)[-1]) + self.import_wizard.incrementProgressBar( + unicode(translate('SongsPlugin.ImportWizardForm', + 'Importing %s...')) % os.path.split(filename)[-1]) file = open(filename) self.do_import_file(file) if self.commit: @@ -155,7 +160,7 @@ class OpenSongImport(SongImport): self.set_defaults() if not self.commit: self.finish() - + return success def do_import_file(self, file): """ diff --git a/openlp/plugins/songs/lib/songimport.py b/openlp/plugins/songs/lib/songimport.py index 17000a2ba..ea763c1ee 100644 --- a/openlp/plugins/songs/lib/songimport.py +++ b/openlp/plugins/songs/lib/songimport.py @@ -30,7 +30,7 @@ from PyQt4 import QtCore from openlp.core.lib import Receiver, translate from openlp.plugins.songs.lib import VerseType -from openlp.plugins.songs.lib.db import Song, Author, Topic, Book +from openlp.plugins.songs.lib.db import Song, Author, Topic, Book, MediaFile from openlp.plugins.songs.lib.xml import SongXMLBuilder log = logging.getLogger(__name__) @@ -66,6 +66,7 @@ class SongImport(QtCore.QObject): self.ccli_number = u'' self.authors = [] self.topics = [] + self.media_files = [] self.song_book_name = u'' self.song_book_pub = u'' self.verse_order_list = [] @@ -76,7 +77,7 @@ class SongImport(QtCore.QObject): 'SongsPlugin.SongImport', 'copyright')) self.copyright_symbol = unicode(translate( 'SongsPlugin.SongImport', '\xa9')) - + def stop_import(self): """ Sets the flag for importers to stop their import @@ -184,6 +185,14 @@ class SongImport(QtCore.QObject): return self.authors.append(author) + def add_media_file(self, filename): + """ + Add a media file to the list + """ + if filename in self.media_files: + return + self.media_files.append(filename) + def add_verse(self, verse, versetag=None): """ Add a verse. This is the whole verse, lines split by \n @@ -279,11 +288,16 @@ class SongImport(QtCore.QObject): for authortext in self.authors: author = self.manager.get_object_filtered(Author, Author.display_name == authortext) - if author is None: + if not author: author = Author.populate(display_name = authortext, last_name=authortext.split(u' ')[-1], first_name=u' '.join(authortext.split(u' ')[:-1])) song.authors.append(author) + for filename in self.media_files: + media_file = self.manager.get_object_filtered(MediaFile, + MediaFile.file_name == filename) + if not media_file: + song.media_files.append(MediaFile.populate(file_name=filename)) if self.song_book_name: song_book = self.manager.get_object_filtered(Book, Book.name == self.song_book_name) From 63139e8c3b5491bdbf7f13650dccacdd69dacb4b Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Mon, 6 Sep 2010 22:41:11 +0200 Subject: [PATCH 19/25] Just check for the tracks table before importing from it. --- openlp/plugins/songs/lib/olp1import.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/openlp/plugins/songs/lib/olp1import.py b/openlp/plugins/songs/lib/olp1import.py index ab3e0d720..968eac25c 100644 --- a/openlp/plugins/songs/lib/olp1import.py +++ b/openlp/plugins/songs/lib/olp1import.py @@ -97,15 +97,19 @@ class OpenLP1SongImport(SongImport): if self.stop_import_flag: success = False break - cursor.execute(u'SELECT fulltrackname FROM tracks t ' - u'JOIN songtracks st ON t.trackid = st.trackid ' - u'WHERE st.songid = %s ORDER BY st.listindex' % song_id) - tracks = cursor.fetchall() - for track in tracks: - if self.stop_import_flag: - success = False - break - self.add_media_file(unicode(track[0], u'cp1252')) + cursor.execute(u'SELECT name FROM sqlite_master ' + u'WHERE type = \'table\' NAME name = \'tracks\'') + table_list = cursor.fetchall() + if len(table_list) > 0: + cursor.execute(u'SELECT fulltrackname FROM tracks t ' + u'JOIN songtracks st ON t.trackid = st.trackid ' + u'WHERE st.songid = %s ORDER BY st.listindex' % song_id) + tracks = cursor.fetchall() + for track in tracks: + if self.stop_import_flag: + success = False + break + self.add_media_file(unicode(track[0], u'cp1252')) if self.stop_import_flag: success = False break From f30aecfd46b09eef2f7e3cc8f09110aa7efd037b Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Tue, 7 Sep 2010 00:02:48 +0200 Subject: [PATCH 20/25] A couple of bugfixes. --- openlp/plugins/songs/forms/songimportform.py | 15 ++++--- openlp/plugins/songs/lib/importer.py | 5 ++- openlp/plugins/songs/lib/olp1import.py | 43 ++++++++++++-------- 3 files changed, 37 insertions(+), 26 deletions(-) diff --git a/openlp/plugins/songs/forms/songimportform.py b/openlp/plugins/songs/forms/songimportform.py index f2a59ba81..0c58b8650 100644 --- a/openlp/plugins/songs/forms/songimportform.py +++ b/openlp/plugins/songs/forms/songimportform.py @@ -31,7 +31,6 @@ from PyQt4 import QtCore, QtGui from songimportwizard import Ui_SongImportWizard from openlp.core.lib import Receiver, SettingsManager, translate -#from openlp.core.utils import AppLocation from openlp.plugins.songs.lib.importer import SongFormat log = logging.getLogger(__name__) @@ -136,7 +135,7 @@ class ImportWizardForm(QtGui.QWizard, Ui_SongImportWizard): self.openLP2BrowseButton.setFocus() return False elif source_format == SongFormat.OpenLP1: - if self.openSongFilenameEdit.text().isEmpty(): + if self.openLP1FilenameEdit.text().isEmpty(): QtGui.QMessageBox.critical(self, translate('SongsPlugin.ImportWizardForm', 'No openlp.org 1.x Song Database Selected'), @@ -292,7 +291,7 @@ class ImportWizardForm(QtGui.QWizard, Ui_SongImportWizard): def onCCLIRemoveButtonClicked(self): self.removeSelectedItems(self.ccliFileListWidget) - + def onSongsOfFellowshipAddButtonClicked(self): self.getFiles( translate('SongsPlugin.ImportWizardForm', @@ -374,11 +373,11 @@ class ImportWizardForm(QtGui.QWizard, Ui_SongImportWizard): importer = self.plugin.importSongs(SongFormat.OpenLP2, filename=unicode(self.openLP2FilenameEdit.text()) ) - #elif source_format == SongFormat.OpenLP1: - # # Import an openlp.org database - # importer = self.plugin.importSongs(SongFormat.OpenLP1, - # filename=unicode(self.field(u'openlp1_filename').toString()) - # ) + elif source_format == SongFormat.OpenLP1: + # Import an openlp.org database + importer = self.plugin.importSongs(SongFormat.OpenLP1, + filename=unicode(self.openLP1FilenameEdit.text()) + ) elif source_format == SongFormat.OpenLyrics: # Import OpenLyrics songs importer = self.plugin.importSongs(SongFormat.OpenLyrics, diff --git a/openlp/plugins/songs/lib/importer.py b/openlp/plugins/songs/lib/importer.py index 5801ea44a..da9618ef2 100644 --- a/openlp/plugins/songs/lib/importer.py +++ b/openlp/plugins/songs/lib/importer.py @@ -26,6 +26,7 @@ from opensongimport import OpenSongImport from olpimport import OpenLPSongImport +from olp1import import OpenLP1SongImport try: from sofimport import SofImport from oooimport import OooImport @@ -61,6 +62,8 @@ class SongFormat(object): """ if format == SongFormat.OpenLP2: return OpenLPSongImport + if format == SongFormat.OpenLP1: + return OpenLP1SongImport elif format == SongFormat.OpenSong: return OpenSongImport elif format == SongFormat.SongsOfFellowship: @@ -70,7 +73,7 @@ class SongFormat(object): elif format == SongFormat.Generic: return OooImport elif format == SongFormat.CCLI: - return CCLIFileImport + return CCLIFileImport # else: return None diff --git a/openlp/plugins/songs/lib/olp1import.py b/openlp/plugins/songs/lib/olp1import.py index 968eac25c..953b509b4 100644 --- a/openlp/plugins/songs/lib/olp1import.py +++ b/openlp/plugins/songs/lib/olp1import.py @@ -30,8 +30,7 @@ openlp.org 1.x song databases into the current installation database. import logging import sqlite -#from openlp.core.lib.db import BaseModel -from openlp.plugins.songs.lib.db import Author, Book, Song, Topic #, MediaFile +from openlp.core.lib import translate from songimport import SongImport log = logging.getLogger(__name__) @@ -66,6 +65,12 @@ class OpenLP1SongImport(SongImport): count = int(cursor.fetchone()[0]) success = True self.import_wizard.importProgressBar.setMaximum(count) + # "cache" our list of authors + cursor.execute(u'SELECT authorid, authorname FROM authors') + authors = cursor.fetchall() + # "cache" our list of tracks + cursor.execute(u'SELECT trackid, fulltrackname FROM tracks') + tracks = cursor.fetchall() # Import the songs cursor.execute(u'SELECT songid, songtitle, lyrics || \'\' AS lyrics, ' u'copyrightinfo FROM songs') @@ -77,39 +82,43 @@ class OpenLP1SongImport(SongImport): break song_id = song[0] title = unicode(song[1], u'cp1252') - lyrics = unicode(song[2], u'cp1252') + lyrics = unicode(song[2], u'cp1252').replace(u'\r', u'') copyright = unicode(song[3], u'cp1252') self.import_wizard.incrementProgressBar( unicode(translate('SongsPlugin.ImportWizardForm', - 'Importing %s...')) % title) + 'Importing "%s"...')) % title) self.title = title self.process_song_text(lyrics) self.add_copyright(copyright) - cursor.execute(u'SELECT displayname FROM authors a ' - u'JOIN songauthors sa ON a.authorid = sa.authorid ' - u'WHERE sa.songid = %s' % song_id) - authors = cursor.fetchall() - for author in authors: + cursor.execute(u'SELECT authorid FROM songauthors ' + u'WHERE songid = %s' % song_id) + author_ids = cursor.fetchall() + for author_id in author_ids: if self.stop_import_flag: success = False break - self.parse_author(unicode(author[0], u'cp1252')) + for author in authors: + if author[0] == author_id[0]: + self.parse_author(unicode(author[1], u'cp1252')) + break if self.stop_import_flag: success = False break cursor.execute(u'SELECT name FROM sqlite_master ' - u'WHERE type = \'table\' NAME name = \'tracks\'') + u'WHERE type = \'table\' AND name = \'tracks\'') table_list = cursor.fetchall() if len(table_list) > 0: - cursor.execute(u'SELECT fulltrackname FROM tracks t ' - u'JOIN songtracks st ON t.trackid = st.trackid ' - u'WHERE st.songid = %s ORDER BY st.listindex' % song_id) - tracks = cursor.fetchall() - for track in tracks: + cursor.execute(u'SELECT trackid FROM songtracks ' + u'WHERE songid = %s ORDER BY listindex' % song_id) + track_ids = cursor.fetchall() + for track_id in track_ids: if self.stop_import_flag: success = False break - self.add_media_file(unicode(track[0], u'cp1252')) + for track in tracks: + if track[0] == track_id[0]: + self.add_media_file(unicode(track[1], u'cp1252')) + break if self.stop_import_flag: success = False break From 4c648f142c3efdd703fcbfbf422bb6e8232cfe7b Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Tue, 7 Sep 2010 17:12:47 +0100 Subject: [PATCH 21/25] Fix song editing display bug Fixes: https://launchpad.net/bugs/630247 --- openlp/plugins/songs/forms/editsongform.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 9d96beb06..458e7200c 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -274,7 +274,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): item = self.VerseListWidget.item(row, 0) data = unicode(item.data(QtCore.Qt.UserRole).toString()) bit = data.split(u':') - rowTag = u'%s\n%s' % (bit[0][0:1], bit[1]) + rowTag = u'%s%s' % (bit[0][0:1], bit[1]) rowLabel.append(rowTag) self.VerseListWidget.setVerticalHeaderLabels(rowLabel) @@ -395,9 +395,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): self.VerseDeleteButton.setEnabled(True) def onVerseAddButtonClicked(self): - # Allow insert button as you do not know if multiple verses will - # be entered. - self.verse_form.setVerse(u'') + self.verse_form.setVerse(u'', True) if self.verse_form.exec_(): afterText, verse, subVerse = self.verse_form.getVerse() data = u'%s:%s' % (verse, subVerse) From 7c2da6e2e3199b23c516a92db2ea5f847b746b23 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Tue, 7 Sep 2010 22:42:33 +0200 Subject: [PATCH 22/25] Added a global exception catcher, so that our poor n00bs can see what happened. --- openlp.pyw | 11 ++- openlp/core/ui/exceptiondialog.py | 82 ++++++++++++++++++ openlp/core/ui/exceptionform.py | 38 +++++++++ resources/forms/exceptiondialog.ui | 130 +++++++++++++++++++++++++++++ resources/images/exception.png | Bin 0 -> 1709 bytes resources/images/openlp-2.qrc | 1 + 6 files changed, 261 insertions(+), 1 deletion(-) create mode 100644 openlp/core/ui/exceptiondialog.py create mode 100644 openlp/core/ui/exceptionform.py create mode 100644 resources/forms/exceptiondialog.ui create mode 100644 resources/images/exception.png diff --git a/openlp.pyw b/openlp.pyw index dfe973ceb..805181c11 100755 --- a/openlp.pyw +++ b/openlp.pyw @@ -29,12 +29,14 @@ import os import sys import logging from optparse import OptionParser +from traceback import format_exception from PyQt4 import QtCore, QtGui from openlp.core.lib import Receiver from openlp.core.resources import qInitResources from openlp.core.ui.mainwindow import MainWindow +from openlp.core.ui.exceptionform import ExceptionForm from openlp.core.ui import SplashScreen, ScreenList from openlp.core.utils import AppLocation, LanguageManager, VersionThread @@ -144,6 +146,13 @@ class OpenLP(QtGui.QApplication): VersionThread(self.mainWindow, app_version).start() return self.exec_() + def hookException(self, exctype, value, traceback): + if not hasattr(self, u'exceptionForm'): + self.exceptionForm = ExceptionForm(self.mainWindow) + self.exceptionForm.exceptionTextEdit.setPlainText( + ''.join(format_exception(exctype, value, traceback))) + self.exceptionForm.exec_() + def main(): """ The main function which parses command line options and then runs @@ -194,7 +203,7 @@ def main(): language = LanguageManager.get_language() appTranslator = LanguageManager.get_translator(language) app.installTranslator(appTranslator) - + sys.excepthook = app.hookException sys.exit(app.run()) if __name__ == u'__main__': diff --git a/openlp/core/ui/exceptiondialog.py b/openlp/core/ui/exceptiondialog.py new file mode 100644 index 000000000..28097e938 --- /dev/null +++ b/openlp/core/ui/exceptiondialog.py @@ -0,0 +1,82 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2010 Raoul Snyman # +# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael # +# Gorven, Scott Guerrieri, Meinert Jordan, Andreas Preikschat, Christian # +# Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon Tibble, # +# Carsten Tinggaard, Frode Woldsund # +# --------------------------------------------------------------------------- # +# 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 PyQt4 import QtCore, QtGui + +from openlp.core.lib import translate + +class Ui_ExceptionDialog(object): + def setupUi(self, exceptionDialog): + exceptionDialog.setObjectName(u'exceptionDialog') + exceptionDialog.resize(580, 407) + self.exceptionLayout = QtGui.QVBoxLayout(exceptionDialog) + self.exceptionLayout.setSpacing(8) + self.exceptionLayout.setMargin(8) + self.exceptionLayout.setObjectName(u'exceptionLayout') + self.messageLayout = QtGui.QHBoxLayout() + self.messageLayout.setSpacing(0) + self.messageLayout.setContentsMargins(0, -1, 0, -1) + self.messageLayout.setObjectName(u'messageLayout') + self.bugLabel = QtGui.QLabel(exceptionDialog) + self.bugLabel.setMinimumSize(QtCore.QSize(64, 64)) + self.bugLabel.setMaximumSize(QtCore.QSize(64, 64)) + self.bugLabel.setText(u'') + self.bugLabel.setPixmap(QtGui.QPixmap(u':/graphics/exception.png')) + self.bugLabel.setAlignment(QtCore.Qt.AlignCenter) + self.bugLabel.setObjectName(u'bugLabel') + self.messageLayout.addWidget(self.bugLabel) + self.messageLabel = QtGui.QLabel(exceptionDialog) + self.messageLabel.setWordWrap(True) + self.messageLabel.setObjectName(u'messageLabel') + self.messageLayout.addWidget(self.messageLabel) + self.exceptionLayout.addLayout(self.messageLayout) + self.exceptionTextEdit = QtGui.QPlainTextEdit(exceptionDialog) + self.exceptionTextEdit.setReadOnly(True) + self.exceptionTextEdit.setBackgroundVisible(False) + self.exceptionTextEdit.setObjectName(u'exceptionTextEdit') + self.exceptionLayout.addWidget(self.exceptionTextEdit) + self.exceptionButtonBox = QtGui.QDialogButtonBox(exceptionDialog) + self.exceptionButtonBox.setOrientation(QtCore.Qt.Horizontal) + self.exceptionButtonBox.setStandardButtons(QtGui.QDialogButtonBox.Close) + self.exceptionButtonBox.setObjectName(u'exceptionButtonBox') + self.exceptionLayout.addWidget(self.exceptionButtonBox) + + self.retranslateUi(exceptionDialog) + QtCore.QObject.connect(self.exceptionButtonBox, + QtCore.SIGNAL(u'accepted()'), exceptionDialog.accept) + QtCore.QObject.connect(self.exceptionButtonBox, + QtCore.SIGNAL(u'rejected()'), exceptionDialog.reject) + QtCore.QMetaObject.connectSlotsByName(exceptionDialog) + + def retranslateUi(self, exceptionDialog): + exceptionDialog.setWindowTitle( + translate('OpenLP.ExceptionDialog', 'Error Occured')) + self.messageLabel.setText(translate('OpenLP.ExceptionDialog', 'Oops! ' + 'OpenLP hit a problem, and couldn\'t recover. The text in the box ' + 'below contains information that might be helpful to the OpenLP ' + 'developers, so please e-mail it to bugs@openlp.org, along with a ' + 'detailed description of what you were doing when the problem ' + 'occurred.')) diff --git a/openlp/core/ui/exceptionform.py b/openlp/core/ui/exceptionform.py new file mode 100644 index 000000000..d181ad0d1 --- /dev/null +++ b/openlp/core/ui/exceptionform.py @@ -0,0 +1,38 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2010 Raoul Snyman # +# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael # +# Gorven, Scott Guerrieri, Meinert Jordan, Andreas Preikschat, Christian # +# Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon Tibble, # +# Carsten Tinggaard, Frode Woldsund # +# --------------------------------------------------------------------------- # +# 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 PyQt4 import QtCore, QtGui + +from exceptiondialog import Ui_ExceptionDialog +from openlp.core.lib import translate + +class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog): + """ + The exception dialog + """ + def __init__(self, parent): + QtGui.QDialog.__init__(self, parent) + self.setupUi(self) diff --git a/resources/forms/exceptiondialog.ui b/resources/forms/exceptiondialog.ui new file mode 100644 index 000000000..f6f15cdc7 --- /dev/null +++ b/resources/forms/exceptiondialog.ui @@ -0,0 +1,130 @@ + + + ExceptionDialog + + + + 0 + 0 + 580 + 407 + + + + Dialog + + + + 8 + + + 8 + + + + + 0 + + + 0 + + + 0 + + + + + + 64 + 64 + + + + + 64 + 64 + + + + + + + :/graphics/exception.png + + + Qt::AlignCenter + + + + + + + Oops! OpenLP hit a problem, and couldn't recover. The text in the box below contains information that might be helpful to the OpenLP developers, so please e-mail it to bugs@openlp.org, along with a detailed description of what you were doing when the problem occurred. + + + true + + + + + + + + + true + + + false + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Close + + + + + + + + + + + exceptionButtonBox + accepted() + ExceptionDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + exceptionButtonBox + rejected() + ExceptionDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/resources/images/exception.png b/resources/images/exception.png new file mode 100644 index 0000000000000000000000000000000000000000..c7ace707e3a21503efe02b1b32cd913926c7dc92 GIT binary patch literal 1709 zcmV;e22%NnP)4Q?BA8iq7DN{gO5vCY)0y>mQ z)D02iOs2%mq0@yaS+dQM83P$QBb#m-W`fz&jYNUCI3FzX z=*#-C(Jf$XtC=xRY;5cX^rhh>ATbyW>r^V0KZ~)EWeP>PiLp|f&6cdw>0Bv{&7IEJ z!VHzlhDc3C1Xf{AL^uhk1wrV<;st!CGHJw~(n8}&hdt_Fk6`L9&QYGkcmp7{+wIF8 z4##dT+OQEY8jZ0&pRWyznwqxf9sX#ga3?EZC51vxYL%Q)y-~D!p}2cfjqojO9hsS# z?VNPj2t-9iMSH#8wOi}#2YS1P)23P@Ii1cBqNAfpuh-L(A~F5(i_)adB~>F%%wd*oQUYtb|gCudG6$-d<`l_ZC=fRG22vl&oPi(wj&l zye`TQIw?2FP6b9Iy{0$bFPAAl0a^D`6X0Ql^NI;--SxvFO>ZX?)8CkKBVJ9vADT*I zGXpdx7@*eAUZ8*Mdb-LO-izooQ}&LHvYy6q%y`ss9L#wn&izD-#d5P%q`iC|3txiy zHQ+jOp6B;dYHBKFWMoh#+8aUw-B78i3-2$=6trKYIhT@>asq3lJP`pNa+J}@C@|G- zxBJs~WV(&Z9PzZtV!`g<9J#)`>@9kuq=b@^k_dvM;b?EArPIx5dx&78+fBP-T@Nax z+Ep4bO6YHRr36CVeL(UyTRPXUK4=8HXrc*eAG|uIsKP3|C76iJ#b0>9d*+Nqi zJv1{gifXemsb_2!-F6CeS|+FD`7gkc!bLQ0uYo2RtQ%MgZb*@zVQ{ zkiODn{>$U>P!`mFh38+braSosbY;Q#h4+f|+zHE}pK6M3fF&6fXMC zGyK=STNFP#V0%&#T35vjx1Ym;U*eo!hIyA*LN^_;bSZHdH76v{nVcNz$$p-?l6}+- zZEzuO07(InYEAK9#2UsSpMo^TTtB+qy=NmLs5LT@@^Q@K%x0QtFj5=Z-DV4Q_)}>+ zLLY;EItXyP2y>H2TjQL35e5y zQjAI&dY6Er)QM#~VRI@wyT`_u`DyBap=CtcwKk208X-Vl^C417M2MG4rL+sv&!IX- zqYt5l-r0Z)7(WZ$v;~44T!c?UK-u8)9ci}P=^#uO!7JqYc_SkuF?j{zl|TW}&O1kVrL zxz%drYlw$JK#%fy1g)Zo$;$l>M<~xZ*x@=%n-Ax&Si?`*K{(iH{QjQJ?d{z-<5t$K(7HGLRkr^Gxv{q8E~v7}tO&00000NkvXXu0mjf DNC^_> literal 0 HcmV?d00001 diff --git a/resources/images/openlp-2.qrc b/resources/images/openlp-2.qrc index c9277c3cf..78d74cf7e 100644 --- a/resources/images/openlp-2.qrc +++ b/resources/images/openlp-2.qrc @@ -62,6 +62,7 @@ openlp-logo-256x256.png + exception.png openlp-about-logo.png openlp-splash-screen.png From cfca50ff2578fd9deeea07542eff67555604956b Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Wed, 8 Sep 2010 18:51:19 +0100 Subject: [PATCH 23/25] Fix setText bug when null list item Fixes: https://launchpad.net/bugs/632674 --- openlp/core/ui/plugindialog.py | 1 - openlp/core/ui/pluginform.py | 5 +++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/openlp/core/ui/plugindialog.py b/openlp/core/ui/plugindialog.py index a4256c0e5..9d12651c9 100644 --- a/openlp/core/ui/plugindialog.py +++ b/openlp/core/ui/plugindialog.py @@ -93,7 +93,6 @@ class Ui_PluginViewDialog(object): self.pluginListButtonBox.setStandardButtons(QtGui.QDialogButtonBox.Ok) self.pluginListButtonBox.setObjectName(u'pluginListButtonBox') self.pluginLayout.addWidget(self.pluginListButtonBox) - self.retranslateUi(pluginViewDialog) QtCore.QObject.connect(self.pluginListButtonBox, QtCore.SIGNAL(u'accepted()'), pluginViewDialog.close) diff --git a/openlp/core/ui/pluginform.py b/openlp/core/ui/pluginform.py index c0fd53938..8bf490f85 100644 --- a/openlp/core/ui/pluginform.py +++ b/openlp/core/ui/pluginform.py @@ -134,5 +134,6 @@ class PluginForm(QtGui.QDialog, Ui_PluginViewDialog): elif self.activePlugin.status == PluginStatus.Disabled: status_text = unicode( translate('OpenLP.PluginForm', '%s (Disabled)')) - self.pluginListWidget.currentItem().setText( - status_text % self.activePlugin.name) + if self.pluginListWidget.currentItem(): + self.pluginListWidget.currentItem().setText( + status_text % self.activePlugin.name) From b39136782e35fee9b72c5c964e2cb4ff5d922780 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Wed, 8 Sep 2010 19:00:48 +0100 Subject: [PATCH 24/25] Quick hack to get songs back --- openlp/core/lib/htmlbuilder.py | 1 + openlp/plugins/songs/lib/olp1import.py | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/openlp/core/lib/htmlbuilder.py b/openlp/core/lib/htmlbuilder.py index acf00bdeb..0d6482797 100644 --- a/openlp/core/lib/htmlbuilder.py +++ b/openlp/core/lib/htmlbuilder.py @@ -519,6 +519,7 @@ def build_footer_css(item): font-size: %spt; color: %s; text-align: %s; + vertical-align: bottom; """ theme = item.themedata if not theme or not item.footer: diff --git a/openlp/plugins/songs/lib/olp1import.py b/openlp/plugins/songs/lib/olp1import.py index 953b509b4..51e3e1fbf 100644 --- a/openlp/plugins/songs/lib/olp1import.py +++ b/openlp/plugins/songs/lib/olp1import.py @@ -28,7 +28,10 @@ The :mod:`olp1import` module provides the functionality for importing openlp.org 1.x song databases into the current installation database. """ import logging -import sqlite +try: + import sqlite +except: + pass from openlp.core.lib import translate from songimport import SongImport From ccb75ad3b6ca7bed5a9c017406c5320f7b636819 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Wed, 8 Sep 2010 19:12:16 +0100 Subject: [PATCH 25/25] Fix display to work on 1024x768 resolution without nasty slider movements Fixes: https://launchpad.net/bugs/594808 --- openlp/core/lib/htmlbuilder.py | 1 - openlp/core/ui/slidecontroller.py | 14 ++------------ 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/openlp/core/lib/htmlbuilder.py b/openlp/core/lib/htmlbuilder.py index 0d6482797..acf00bdeb 100644 --- a/openlp/core/lib/htmlbuilder.py +++ b/openlp/core/lib/htmlbuilder.py @@ -519,7 +519,6 @@ def build_footer_css(item): font-size: %spt; color: %s; text-align: %s; - vertical-align: bottom; """ theme = item.themedata if not theme or not item.footer: diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 5d688b890..2ea985598 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -162,11 +162,6 @@ class SlideController(QtGui.QWidget): sizeToolbarPolicy.setHeightForWidth( self.Toolbar.sizePolicy().hasHeightForWidth()) self.Toolbar.setSizePolicy(sizeToolbarPolicy) -# if self.isLive: -# self.Toolbar.addToolbarButton( -# u'First Slide', u':/slides/slide_first.png', -# translate('OpenLP.SlideController', 'Move to first'), -# self.onSlideSelectedFirst) self.Toolbar.addToolbarButton( u'Previous Slide', u':/slides/slide_previous.png', translate('OpenLP.SlideController', 'Move to previous'), @@ -175,11 +170,6 @@ class SlideController(QtGui.QWidget): u'Next Slide', u':/slides/slide_next.png', translate('OpenLP.SlideController', 'Move to next'), self.onSlideSelectedNext) -# if self.isLive: -# self.Toolbar.addToolbarButton( -# u'Last Slide', u':/slides/slide_last.png', -# translate('OpenLP.SlideController', 'Move to last'), -# self.onSlideSelectedLast) if self.isLive: self.Toolbar.addToolbarSeparator(u'Close Separator') self.HideMenu = QtGui.QToolButton(self.Toolbar) @@ -279,11 +269,11 @@ class SlideController(QtGui.QWidget): if isLive: self.SongMenu = QtGui.QToolButton(self.Toolbar) self.SongMenu.setText(translate('OpenLP.SlideController', - 'Go to Verse')) + 'Go to')) self.SongMenu.setPopupMode(QtGui.QToolButton.InstantPopup) self.Toolbar.addToolbarWidget(u'Song Menu', self.SongMenu) self.SongMenu.setMenu(QtGui.QMenu( - translate('OpenLP.SlideController', 'Go to Verse'), + translate('OpenLP.SlideController', 'Go to'), self.Toolbar)) self.Toolbar.makeWidgetsInvisible([u'Song Menu']) # Screen preview area