From 81a1cfc81525b1f62ff94d5d75572ee43db05ed8 Mon Sep 17 00:00:00 2001 From: Jonathan Corwin Date: Thu, 9 Sep 2010 20:34:45 +0100 Subject: [PATCH 1/2] Tidy up versetag counting --- openlp/plugins/songs/lib/songimport.py | 45 ++++++-------------------- 1 file changed, 10 insertions(+), 35 deletions(-) diff --git a/openlp/plugins/songs/lib/songimport.py b/openlp/plugins/songs/lib/songimport.py index 8d29a73a2..30c1865a7 100644 --- a/openlp/plugins/songs/lib/songimport.py +++ b/openlp/plugins/songs/lib/songimport.py @@ -71,13 +71,7 @@ class SongImport(QtCore.QObject): self.song_book_pub = u'' self.verse_order_list = [] self.verses = [] - self.versecount = 0 - self.choruscount = 0 - self.bridgecount = 0 - self.introcount = 0 - self.prechoruscount = 0 - self.endingcount = 0 - self.othercount = 0 + self.versecounts = {} self.copyright_string = unicode(translate( 'SongsPlugin.SongImport', 'copyright')) self.copyright_symbol = unicode(translate( @@ -198,7 +192,7 @@ class SongImport(QtCore.QObject): return self.media_files.append(filename) - def add_verse(self, verse, versetag=None): + def add_verse(self, verse, versetag=u'V'): """ Add a verse. This is the whole verse, lines split by \n Verse tag can be V1/C1/B etc, or 'V' and 'C' (will count the verses/ @@ -210,33 +204,14 @@ class SongImport(QtCore.QObject): if oldverse.strip() == verse.strip(): self.verse_order_list.append(oldversetag) return - if versetag == u'V' or not versetag: - self.versecount += 1 - versetag = u'V' + unicode(self.versecount) - if versetag.startswith(u'C'): - self.choruscount += 1 - if versetag == u'C': - versetag += unicode(self.choruscount) - if versetag.startswith(u'B'): - self.bridgecount += 1 - if versetag == u'B': - versetag += unicode(self.bridgecount) - if versetag.startswith(u'I'): - self.introcount += 1 - if versetag == u'I': - versetag += unicode(self.introcount) - if versetag.startswith(u'P'): - self.prechoruscount += 1 - if versetag == u'P': - versetag += unicode(self.prechoruscount) - if versetag.startswith(u'E'): - self.endingcount += 1 - if versetag == u'E': - versetag += unicode(self.endingcount) - if versetag.startswith(u'O'): - self.othercount += 1 - if versetag == u'O': - versetag += unicode(self.othercount) + if versetag[0] in self.versecounts: + self.versecounts[versetag[0]] += 1 + else: + self.versecounts[versetag[0]] = 1 + if len(versetag) == 1: + versetag += unicode(self.versecounts[versetag[0]]) + elif int(versetag[1:]) > self.versecounts[versetag[0]]: + self.versecounts[versetag[0]] = int(versetag[1:]) self.verses.append([versetag, verse.rstrip()]) self.verse_order_list.append(versetag) if versetag.startswith(u'V') and self.contains_verse(u'C1'): From d549935fa87fdbfef9f80fdfb546915e53685e59 Mon Sep 17 00:00:00 2001 From: Jonathan Corwin Date: Fri, 10 Sep 2010 18:49:22 +0100 Subject: [PATCH 2/2] Bug 634771 - Check for no recent files --- openlp/core/ui/servicemanager.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index c7d3c497f..b6b915b7f 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -632,6 +632,8 @@ class ServiceManager(QtGui.QWidget): def onLoadService(self, lastService=False): if lastService: + if not self.parent.recentFiles: + return filename = self.parent.recentFiles[0] else: filename = QtGui.QFileDialog.getOpenFileName(