Integrated module openlp.plugins.songs.lib.powersongimport

This commit is contained in:
Samuel Findlay 2012-04-30 16:24:04 +10:00
parent 21a88085e3
commit ea9bfb160d
3 changed files with 54 additions and 5 deletions

View File

@ -171,6 +171,12 @@ class SongImportForm(OpenLPWizard):
QtCore.QObject.connect(self.foilPresenterRemoveButton, QtCore.QObject.connect(self.foilPresenterRemoveButton,
QtCore.SIGNAL(u'clicked()'), QtCore.SIGNAL(u'clicked()'),
self.onFoilPresenterRemoveButtonClicked) self.onFoilPresenterRemoveButtonClicked)
QtCore.QObject.connect(self.powerSongAddButton,
QtCore.SIGNAL(u'clicked()'),
self.powerSongAddButtonClicked)
QtCore.QObject.connect(self.powerSongRemoveButton,
QtCore.SIGNAL(u'clicked()'),
self.powerSongRemoveButtonClicked)
def addCustomPages(self): def addCustomPages(self):
""" """
@ -217,6 +223,8 @@ class SongImportForm(OpenLPWizard):
self.addFileSelectItem(u'foilPresenter') self.addFileSelectItem(u'foilPresenter')
# Open Song # Open Song
self.addFileSelectItem(u'openSong', u'OpenSong') self.addFileSelectItem(u'openSong', u'OpenSong')
# PowerSong
self.addFileSelectItem(u'powerSong')
# SongBeamer # SongBeamer
self.addFileSelectItem(u'songBeamer') self.addFileSelectItem(u'songBeamer')
# Song Show Plus # Song Show Plus
@ -264,6 +272,8 @@ class SongImportForm(OpenLPWizard):
self.formatComboBox.setItemText( self.formatComboBox.setItemText(
SongFormat.FoilPresenter, WizardStrings.FP) SongFormat.FoilPresenter, WizardStrings.FP)
self.formatComboBox.setItemText(SongFormat.OpenSong, WizardStrings.OS) self.formatComboBox.setItemText(SongFormat.OpenSong, WizardStrings.OS)
self.formatComboBox.setItemText(
SongFormat.PowerSong, WizardStrings.PS)
self.formatComboBox.setItemText( self.formatComboBox.setItemText(
SongFormat.SongBeamer, WizardStrings.SB) SongFormat.SongBeamer, WizardStrings.SB)
self.formatComboBox.setItemText( self.formatComboBox.setItemText(
@ -305,6 +315,10 @@ class SongImportForm(OpenLPWizard):
translate('SongsPlugin.ImportWizardForm', 'Add Files...')) translate('SongsPlugin.ImportWizardForm', 'Add Files...'))
self.dreamBeamRemoveButton.setText( self.dreamBeamRemoveButton.setText(
translate('SongsPlugin.ImportWizardForm', 'Remove File(s)')) translate('SongsPlugin.ImportWizardForm', 'Remove File(s)'))
self.powerSongAddButton.setText(
translate('SongsPlugin.ImportWizardForm', 'Add Files...'))
self.powerSongRemoveButton.setText(
translate('SongsPlugin.ImportWizardForm', 'Remove File(s)'))
self.songsOfFellowshipAddButton.setText( self.songsOfFellowshipAddButton.setText(
translate('SongsPlugin.ImportWizardForm', 'Add Files...')) translate('SongsPlugin.ImportWizardForm', 'Add Files...'))
self.songsOfFellowshipRemoveButton.setText( self.songsOfFellowshipRemoveButton.setText(
@ -417,6 +431,12 @@ class SongImportForm(OpenLPWizard):
WizardStrings.YouSpecifyFile % WizardStrings.DB) WizardStrings.YouSpecifyFile % WizardStrings.DB)
self.dreamBeamAddButton.setFocus() self.dreamBeamAddButton.setFocus()
return False return False
elif source_format == SongFormat.PowerSong:
if self.powerSongFileListWidget.count() == 0:
critical_error_message_box(UiStrings().NFSp,
WizardStrings.YouSpecifyFile % WizardStrings.PS)
self.powerSongAddButton.setFocus()
return False
elif source_format == SongFormat.SongsOfFellowship: elif source_format == SongFormat.SongsOfFellowship:
if self.songsOfFellowshipFileListWidget.count() == 0: if self.songsOfFellowshipFileListWidget.count() == 0:
critical_error_message_box(UiStrings().NFSp, critical_error_message_box(UiStrings().NFSp,
@ -600,6 +620,22 @@ class SongImportForm(OpenLPWizard):
""" """
self.removeSelectedItems(self.dreamBeamFileListWidget) self.removeSelectedItems(self.dreamBeamFileListWidget)
def onPowerSongAddButtonClicked(self):
"""
Get PowerSong song database files
"""
self.getFiles(WizardStrings.OpenTypeFile % WizardStrings.PS,
self.powerSongFileListWidget, u'%s (*.song)'
% translate('SongsPlugin.ImportWizardForm',
'PowerSong Song Files')
)
def onPowerSongRemoveButtonClicked(self):
"""
Remove selected PowerSong files from the import list
"""
self.removeSelectedItems(self.powerSongFileListWidget)
def onSongsOfFellowshipAddButtonClicked(self): def onSongsOfFellowshipAddButtonClicked(self):
""" """
Get Songs of Fellowship song database files Get Songs of Fellowship song database files
@ -717,6 +753,7 @@ class SongImportForm(OpenLPWizard):
self.wordsOfWorshipFileListWidget.clear() self.wordsOfWorshipFileListWidget.clear()
self.ccliFileListWidget.clear() self.ccliFileListWidget.clear()
self.dreamBeamFileListWidget.clear() self.dreamBeamFileListWidget.clear()
self.powerSongFileListWidget.clear()
self.songsOfFellowshipFileListWidget.clear() self.songsOfFellowshipFileListWidget.clear()
self.genericFileListWidget.clear() self.genericFileListWidget.clear()
self.easySlidesFilenameEdit.setText(u'') self.easySlidesFilenameEdit.setText(u'')
@ -784,6 +821,12 @@ class SongImportForm(OpenLPWizard):
filenames=self.getListOfFiles( filenames=self.getListOfFiles(
self.dreamBeamFileListWidget) self.dreamBeamFileListWidget)
) )
elif source_format == SongFormat.PowerSong:
# Import PowerSong songs
importer = self.plugin.importSongs(SongFormat.PowerSong,
filenames=self.getListOfFiles(
self.powerSongFileListWidget)
)
elif source_format == SongFormat.SongsOfFellowship: elif source_format == SongFormat.SongsOfFellowship:
# Import a Songs of Fellowship RTF file # Import a Songs of Fellowship RTF file
importer = self.plugin.importSongs(SongFormat.SongsOfFellowship, importer = self.plugin.importSongs(SongFormat.SongsOfFellowship,

View File

@ -36,6 +36,7 @@ from openlyricsimport import OpenLyricsImport
from wowimport import WowImport from wowimport import WowImport
from cclifileimport import CCLIFileImport from cclifileimport import CCLIFileImport
from dreambeamimport import DreamBeamImport from dreambeamimport import DreamBeamImport
from powersongimport import PowerSongImport
from ewimport import EasyWorshipSongImport from ewimport import EasyWorshipSongImport
from songbeamerimport import SongBeamerImport from songbeamerimport import SongBeamerImport
from songshowplusimport import SongShowPlusImport from songshowplusimport import SongShowPlusImport
@ -79,11 +80,12 @@ class SongFormat(object):
EasyWorship = 7 EasyWorship = 7
FoilPresenter = 8 FoilPresenter = 8
OpenSong = 9 OpenSong = 9
SongBeamer = 10 PowerSong = 10
SongShowPlus = 11 SongBeamer = 11
SongsOfFellowship = 12 SongShowPlus = 12
WordsOfWorship = 13 SongsOfFellowship = 13
#CSV = 14 WordsOfWorship = 14
#CSV = 15
@staticmethod @staticmethod
def get_class(format): def get_class(format):
@ -111,6 +113,8 @@ class SongFormat(object):
return CCLIFileImport return CCLIFileImport
elif format == SongFormat.DreamBeam: elif format == SongFormat.DreamBeam:
return DreamBeamImport return DreamBeamImport
elif format == SongFormat.PowerSong:
return PowerSongImport
elif format == SongFormat.EasySlides: elif format == SongFormat.EasySlides:
return EasySlidesImport return EasySlidesImport
elif format == SongFormat.EasyWorship: elif format == SongFormat.EasyWorship:
@ -139,6 +143,7 @@ class SongFormat(object):
SongFormat.EasyWorship, SongFormat.EasyWorship,
SongFormat.FoilPresenter, SongFormat.FoilPresenter,
SongFormat.OpenSong, SongFormat.OpenSong,
SongFormat.PowerSong,
SongFormat.SongBeamer, SongFormat.SongBeamer,
SongFormat.SongShowPlus, SongFormat.SongShowPlus,
SongFormat.SongsOfFellowship, SongFormat.SongsOfFellowship,

View File

@ -103,6 +103,7 @@ class PowerSongImport(SongImport):
'"\x05TITLE" header.')))) '"\x05TITLE" header.'))))
continue continue
song_data = song_file.read() song_data = song_file.read()
# Extract title and author fields
first_part, sep, song_data = song_data.partition( first_part, sep, song_data = song_data.partition(
u'\x0DCOPYRIGHTLINE') u'\x0DCOPYRIGHTLINE')
if sep == '': if sep == '':