From 88d717690025e07158bd8a4bfaa740a8872b78f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20P=C3=B5ldaru?= Date: Tue, 13 Dec 2011 02:34:46 +0200 Subject: [PATCH 1/6] Fix for #828385, more sensible and partly alphabetical order of import formats. --- openlp/plugins/songs/forms/songimportform.py | 3 ++- openlp/plugins/songs/lib/importer.py | 26 ++++++++++---------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/openlp/plugins/songs/forms/songimportform.py b/openlp/plugins/songs/forms/songimportform.py index b79e56f7b..d556ffde3 100644 --- a/openlp/plugins/songs/forms/songimportform.py +++ b/openlp/plugins/songs/forms/songimportform.py @@ -238,7 +238,8 @@ class SongImportForm(OpenLPWizard): self.sourcePage.setTitle(WizardStrings.ImportSelect) self.sourcePage.setSubTitle(WizardStrings.ImportSelectLong) self.formatLabel.setText(WizardStrings.FormatLabel) - self.formatComboBox.setItemText(SongFormat.OpenLP2, UiStrings().OLPV2) + self.formatComboBox.setItemText(SongFormat.OpenLP2, + translate('SongsPlugin.ImportWizardForm', 'OpenLP 2.0 database')) self.formatComboBox.setItemText(SongFormat.OpenLP1, UiStrings().OLPV1) self.formatComboBox.setItemText(SongFormat.OpenLyrics, translate('SongsPlugin.ImportWizardForm', diff --git a/openlp/plugins/songs/lib/importer.py b/openlp/plugins/songs/lib/importer.py index d8432f668..bdc8d61e1 100644 --- a/openlp/plugins/songs/lib/importer.py +++ b/openlp/plugins/songs/lib/importer.py @@ -68,19 +68,19 @@ class SongFormat(object): """ _format_availability = {} Unknown = -1 - OpenLP2 = 0 - OpenLP1 = 1 - OpenLyrics = 2 - OpenSong = 3 - WordsOfWorship = 4 - CCLI = 5 - SongsOfFellowship = 6 - Generic = 7 - EasiSlides = 8 - EasyWorship = 9 - SongBeamer = 10 - SongShowPlus = 11 - FoilPresenter = 12 + OpenLyrics = 0 + OpenLP2 = 1 + OpenLP1 = 2 + Generic = 3 + CCLI = 4 + EasiSlides = 5 + EasyWorship = 6 + FoilPresenter = 7 + OpenSong = 8 + SongBeamer = 9 + SongShowPlus = 10 + SongsOfFellowship = 11 + WordsOfWorship = 12 #CSV = 13 @staticmethod From 4f603d7353ca717e812d16aaa41c974c458aa9ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20P=C3=B5ldaru?= Date: Tue, 13 Dec 2011 21:33:49 +0200 Subject: [PATCH 2/6] Previous change of order was not enough, now is actually works. It also saves the type of import last time used and uses that value as default (as suggested), otherwise defaults to OpenLyrics. --- openlp/plugins/songs/forms/songimportform.py | 56 +++++++++++--------- 1 file changed, 31 insertions(+), 25 deletions(-) diff --git a/openlp/plugins/songs/forms/songimportform.py b/openlp/plugins/songs/forms/songimportform.py index d556ffde3..4629703de 100644 --- a/openlp/plugins/songs/forms/songimportform.py +++ b/openlp/plugins/songs/forms/songimportform.py @@ -191,32 +191,32 @@ class SongImportForm(OpenLPWizard): QtGui.QSizePolicy.Expanding) self.formatStack = QtGui.QStackedLayout() self.formatStack.setObjectName(u'FormatStack') + # OpenLyrics + self.addFileSelectItem(u'openLyrics', u'OpenLyrics', True) # OpenLP 2.0 self.addFileSelectItem(u'openLP2', single_select=True) # openlp.org 1.x self.addFileSelectItem(u'openLP1', None, True, True) - # OpenLyrics - self.addFileSelectItem(u'openLyrics', u'OpenLyrics', True) - # Open Song - self.addFileSelectItem(u'openSong', u'OpenSong') - # Words of Worship - self.addFileSelectItem(u'wordsOfWorship') - # CCLI File import - self.addFileSelectItem(u'ccli') - # Songs of Fellowship - self.addFileSelectItem(u'songsOfFellowship', None, True) # Generic Document/Presentation import self.addFileSelectItem(u'generic', None, True) - # EasySlides + # CCLI File import + self.addFileSelectItem(u'ccli') + # EasiSlides self.addFileSelectItem(u'easiSlides', single_select=True) # EasyWorship self.addFileSelectItem(u'ew', single_select=True) - # Words of Worship + # Foilpresenter + self.addFileSelectItem(u'foilPresenter') + # Open Song + self.addFileSelectItem(u'openSong', u'OpenSong') + # SongBeamer self.addFileSelectItem(u'songBeamer') # Song Show Plus self.addFileSelectItem(u'songShowPlus') - # Foilpresenter - self.addFileSelectItem(u'foilPresenter') + # Songs of Fellowship + self.addFileSelectItem(u'songsOfFellowship', None, True) + # Words of Worship + self.addFileSelectItem(u'wordsOfWorship') # Commented out for future use. # self.addFileSelectItem(u'csv', u'CSV', single_select=True) self.sourceLayout.addLayout(self.formatStack) @@ -238,31 +238,30 @@ class SongImportForm(OpenLPWizard): self.sourcePage.setTitle(WizardStrings.ImportSelect) self.sourcePage.setSubTitle(WizardStrings.ImportSelectLong) self.formatLabel.setText(WizardStrings.FormatLabel) - self.formatComboBox.setItemText(SongFormat.OpenLP2, - translate('SongsPlugin.ImportWizardForm', 'OpenLP 2.0 database')) - self.formatComboBox.setItemText(SongFormat.OpenLP1, UiStrings().OLPV1) self.formatComboBox.setItemText(SongFormat.OpenLyrics, translate('SongsPlugin.ImportWizardForm', 'OpenLyrics or OpenLP 2.0 Exported Song')) - self.formatComboBox.setItemText(SongFormat.OpenSong, WizardStrings.OS) - self.formatComboBox.setItemText( - SongFormat.WordsOfWorship, WizardStrings.WoW) - self.formatComboBox.setItemText(SongFormat.CCLI, WizardStrings.CCLI) - self.formatComboBox.setItemText( - SongFormat.SongsOfFellowship, WizardStrings.SoF) + self.formatComboBox.setItemText(SongFormat.OpenLP2, UiStrings().OLPV2) + self.formatComboBox.setItemText(SongFormat.OpenLP1, UiStrings().OLPV1) self.formatComboBox.setItemText(SongFormat.Generic, translate('SongsPlugin.ImportWizardForm', 'Generic Document/Presentation')) + self.formatComboBox.setItemText(SongFormat.CCLI, WizardStrings.CCLI) self.formatComboBox.setItemText( SongFormat.EasiSlides, WizardStrings.ES) self.formatComboBox.setItemText( SongFormat.EasyWorship, WizardStrings.EW) + self.formatComboBox.setItemText( + SongFormat.FoilPresenter, WizardStrings.FP) + self.formatComboBox.setItemText(SongFormat.OpenSong, WizardStrings.OS) self.formatComboBox.setItemText( SongFormat.SongBeamer, WizardStrings.SB) self.formatComboBox.setItemText( SongFormat.SongShowPlus, WizardStrings.SSP) self.formatComboBox.setItemText( - SongFormat.FoilPresenter, WizardStrings.FP) + SongFormat.SongsOfFellowship, WizardStrings.SoF) + self.formatComboBox.setItemText( + SongFormat.WordsOfWorship, WizardStrings.WoW) # self.formatComboBox.setItemText(SongFormat.CSV, WizardStrings.CSV) self.openLP2FilenameLabel.setText( translate('SongsPlugin.ImportWizardForm', 'Filename:')) @@ -360,6 +359,8 @@ class SongImportForm(OpenLPWizard): return True elif self.currentPage() == self.sourcePage: source_format = self.formatComboBox.currentIndex() + QtCore.QSettings().setValue(u'songs/last import type', + source_format) if source_format == SongFormat.OpenLP2: if self.openLP2FilenameEdit.text().isEmpty(): critical_error_message_box(UiStrings().NFSs, @@ -658,7 +659,12 @@ class SongImportForm(OpenLPWizard): self.restart() self.finishButton.setVisible(False) self.cancelButton.setVisible(True) - self.formatComboBox.setCurrentIndex(0) + try: + last_import_type = int(QtCore.QSettings().value( + u'songs/last import type').toString()) + self.formatComboBox.setCurrentIndex(last_import_type) + except ValueError: + self.formatComboBox.setCurrentIndex(0) self.openLP2FilenameEdit.setText(u'') self.openLP1FilenameEdit.setText(u'') self.openLyricsFileListWidget.clear() From 57d78d00dff69c4a569fd0f4ebd3fc865acad89b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20P=C3=B5ldaru?= Date: Tue, 13 Dec 2011 21:52:57 +0200 Subject: [PATCH 3/6] Make loading of variable slightly more bulletproof. --- openlp/plugins/songs/forms/songimportform.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/openlp/plugins/songs/forms/songimportform.py b/openlp/plugins/songs/forms/songimportform.py index 4629703de..fa24eaf83 100644 --- a/openlp/plugins/songs/forms/songimportform.py +++ b/openlp/plugins/songs/forms/songimportform.py @@ -662,6 +662,9 @@ class SongImportForm(OpenLPWizard): try: last_import_type = int(QtCore.QSettings().value( u'songs/last import type').toString()) + if last_import_type >= self.formatComboBox.count() or \ + last_import_type < 0: + last_import_type = 0 self.formatComboBox.setCurrentIndex(last_import_type) except ValueError: self.formatComboBox.setCurrentIndex(0) From 143d87cc88bde53a1139df6ae25de969fc14acf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20P=C3=B5ldaru?= Date: Tue, 13 Dec 2011 22:01:21 +0200 Subject: [PATCH 4/6] One more list which needs right order. --- openlp/plugins/songs/lib/importer.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/openlp/plugins/songs/lib/importer.py b/openlp/plugins/songs/lib/importer.py index bdc8d61e1..03ab897f6 100644 --- a/openlp/plugins/songs/lib/importer.py +++ b/openlp/plugins/songs/lib/importer.py @@ -125,19 +125,19 @@ class SongFormat(object): Return a list of the supported song formats. """ return [ + SongFormat.OpenLyrics, SongFormat.OpenLP2, SongFormat.OpenLP1, - SongFormat.OpenLyrics, - SongFormat.OpenSong, - SongFormat.WordsOfWorship, - SongFormat.CCLI, - SongFormat.SongsOfFellowship, SongFormat.Generic, + SongFormat.CCLI, SongFormat.EasiSlides, - SongFormat.EasyWorship, + SongFormat.EasyWorship, + SongFormat.FoilPresenter + SongFormat.OpenSong, SongFormat.SongBeamer, SongFormat.SongShowPlus, - SongFormat.FoilPresenter + SongFormat.SongsOfFellowship, + SongFormat.WordsOfWorship, ] @staticmethod From 1665c557c1218f1602301ff344cc982579c50680 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20P=C3=B5ldaru?= Date: Tue, 13 Dec 2011 22:20:17 +0200 Subject: [PATCH 5/6] I always forget something :( --- openlp/plugins/songs/lib/importer.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/songs/lib/importer.py b/openlp/plugins/songs/lib/importer.py index 03ab897f6..c24313be1 100644 --- a/openlp/plugins/songs/lib/importer.py +++ b/openlp/plugins/songs/lib/importer.py @@ -132,12 +132,12 @@ class SongFormat(object): SongFormat.CCLI, SongFormat.EasiSlides, SongFormat.EasyWorship, - SongFormat.FoilPresenter + SongFormat.FoilPresenter, SongFormat.OpenSong, SongFormat.SongBeamer, SongFormat.SongShowPlus, SongFormat.SongsOfFellowship, - SongFormat.WordsOfWorship, + SongFormat.WordsOfWorship ] @staticmethod From 13385116af8e1e6ad4a49eb57380f487ec06508f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20P=C3=B5ldaru?= Date: Tue, 13 Dec 2011 23:04:16 +0200 Subject: [PATCH 6/6] Using toInt of QVariant for sure is better than a chain of toString, str and int. Thanks to superfly. --- openlp/plugins/songs/forms/songimportform.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/openlp/plugins/songs/forms/songimportform.py b/openlp/plugins/songs/forms/songimportform.py index fa24eaf83..53e70cde6 100644 --- a/openlp/plugins/songs/forms/songimportform.py +++ b/openlp/plugins/songs/forms/songimportform.py @@ -659,15 +659,12 @@ class SongImportForm(OpenLPWizard): self.restart() self.finishButton.setVisible(False) self.cancelButton.setVisible(True) - try: - last_import_type = int(QtCore.QSettings().value( - u'songs/last import type').toString()) - if last_import_type >= self.formatComboBox.count() or \ - last_import_type < 0: - last_import_type = 0 - self.formatComboBox.setCurrentIndex(last_import_type) - except ValueError: - self.formatComboBox.setCurrentIndex(0) + last_import_type = QtCore.QSettings().value( + u'songs/last import type').toInt()[0] + if last_import_type < 0 or \ + last_import_type >= self.formatComboBox.count(): + last_import_type = 0 + self.formatComboBox.setCurrentIndex(last_import_type) self.openLP2FilenameEdit.setText(u'') self.openLP1FilenameEdit.setText(u'') self.openLyricsFileListWidget.clear()