← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~phill-ridout/openlp/wow_import into lp:openlp

 

phill has proposed merging lp:~phill-ridout/openlp/wow_import into lp:openlp.

Requested reviews:
  Tim Bentley (trb143)
  Raoul Snyman (raoul-snyman)

-- 
https://code.launchpad.net/~phill-ridout/openlp/wow_import/+merge/37658
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp/plugins/songs/forms/songimportform.py'
--- openlp/plugins/songs/forms/songimportform.py	2010-09-23 19:01:52 +0000
+++ openlp/plugins/songs/forms/songimportform.py	2010-10-05 20:01:53 +0000
@@ -248,18 +248,24 @@
             # Progress page
             return True
 
-    def getFileName(self, title, editbox):
+    def getFileName(self, title, editbox,  
+        filters = '%s (*)' % translate('SongsPlugin.ImportWizardForm',
+            'All Files')):
         filename = QtGui.QFileDialog.getOpenFileName(self, title,
-            SettingsManager.get_last_dir(self.plugin.settingsSection, 1))
+            SettingsManager.get_last_dir(self.plugin.settingsSection, 1),
+            filters)
         if filename:
             editbox.setText(filename)
             SettingsManager.set_last_dir(
                 self.plugin.settingsSection,
                 os.path.split(unicode(filename))[0], 1)
 
-    def getFiles(self, title, listbox):
+    def getFiles(self, title, listbox,  
+        filters = u'%s (*)' % translate('SongsPlugin.ImportWizardForm',
+            'All Files')):
         filenames = QtGui.QFileDialog.getOpenFileNames(self, title,
-            SettingsManager.get_last_dir(self.plugin.settingsSection, 1))
+            SettingsManager.get_last_dir(self.plugin.settingsSection, 1),
+            filters)
         if filenames:
             listbox.addItems(filenames)
             SettingsManager.set_last_dir(
@@ -281,14 +287,24 @@
         self.getFileName(
             translate('SongsPlugin.ImportWizardForm',
             'Select OpenLP 2.0 Database File'),
-            self.openLP2FilenameEdit
+            self.openLP2FilenameEdit,
+            u'%s (*.sqlite);;%s (*)'
+            % (translate('SongsPlugin.ImportWizardForm',
+            'OpenLP 2.0 Databases'), 
+            translate('SongsPlugin.ImportWizardForm',
+            'All Files'))
         )
 
     def onOpenLP1BrowseButtonClicked(self):
         self.getFileName(
             translate('SongsPlugin.ImportWizardForm',
             'Select openlp.org 1.x Database File'),
-            self.openLP1FilenameEdit
+            self.openLP1FilenameEdit, 
+            u'%s (*.olp);;%s (*)'
+            % (translate('SongsPlugin.ImportWizardForm',
+            'openlp.org v1.x Databases'), 
+            translate('SongsPlugin.ImportWizardForm',
+            'All Files'))
         )
 
     #def onOpenLyricsAddButtonClicked(self):
@@ -305,7 +321,12 @@
         self.getFiles(
             translate('SongsPlugin.ImportWizardForm',
             'Select Open Song Files'),
-            self.openSongFileListWidget
+            self.openSongFileListWidget, 
+            u'%s (*.xml);;%s (*)'
+            % (translate('SongsPlugin.ImportWizardForm',
+            'OpenSong html Files'), 
+            translate('SongsPlugin.ImportWizardForm',
+            'All Files'))
         )
 
     def onOpenSongRemoveButtonClicked(self):
@@ -315,7 +336,12 @@
         self.getFiles(
             translate('SongsPlugin.ImportWizardForm',
             'Select Words of Worship Files'),
-            self.wordsOfWorshipFileListWidget
+            self.wordsOfWorshipFileListWidget, 
+            u'%s (*.wsg *.wow-song);;%s (*)'
+            % (translate('SongsPlugin.ImportWizardForm',
+            'Words Of Worship Song Files'), 
+            translate('SongsPlugin.ImportWizardForm',
+            'All Files'))
         )
 
     def onWordsOfWorshipRemoveButtonClicked(self):
@@ -335,7 +361,12 @@
         self.getFiles(
             translate('SongsPlugin.ImportWizardForm',
             'Select Songs of Fellowship Files'),
-            self.songsOfFellowshipFileListWidget
+            self.songsOfFellowshipFileListWidget, 
+            u'%s (*.rtf);;%s (*)'
+            % (translate('SongsPlugin.ImportWizardForm',
+            'Songs Of Felloship Song Files'), 
+            translate('SongsPlugin.ImportWizardForm',
+            'All Files'))
         )
 
     def onSongsOfFellowshipRemoveButtonClicked(self):

=== modified file 'openlp/plugins/songs/lib/wowimport.py'
--- openlp/plugins/songs/lib/wowimport.py	2010-09-02 23:20:35 +0000
+++ openlp/plugins/songs/lib/wowimport.py	2010-10-05 20:01:53 +0000
@@ -116,16 +116,16 @@
             self.import_wizard.importProgressBar.setMaximum(
                 len(self.import_source))
             for file in self.import_source:
-                # TODO: check that it is a valid words of worship file (could 
-                # check header for WoW File Song Word)
                 self.author = u''
                 self.copyright = u''
-                # Get the song title
                 self.file_name = os.path.split(file)[1]
                 self.import_wizard.incrementProgressBar(
                     "Importing %s" % (self.file_name),  0)
+                # Get the song title
                 self.title = self.file_name.rpartition(u'.')[0]
                 self.songData = open(file, 'rb')
+                if self.songData.read(19) != u'WoW File\nSong Words':
+                    continue
                 # Seek to byte which stores number of blocks in the song
                 self.songData.seek(56) 
                 self.no_of_blocks = ord(self.songData.read(1))


Follow ups