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.SIGNAL(u'clicked()'),
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):
"""
@ -217,6 +223,8 @@ class SongImportForm(OpenLPWizard):
self.addFileSelectItem(u'foilPresenter')
# Open Song
self.addFileSelectItem(u'openSong', u'OpenSong')
# PowerSong
self.addFileSelectItem(u'powerSong')
# SongBeamer
self.addFileSelectItem(u'songBeamer')
# Song Show Plus
@ -264,6 +272,8 @@ class SongImportForm(OpenLPWizard):
self.formatComboBox.setItemText(
SongFormat.FoilPresenter, WizardStrings.FP)
self.formatComboBox.setItemText(SongFormat.OpenSong, WizardStrings.OS)
self.formatComboBox.setItemText(
SongFormat.PowerSong, WizardStrings.PS)
self.formatComboBox.setItemText(
SongFormat.SongBeamer, WizardStrings.SB)
self.formatComboBox.setItemText(
@ -305,6 +315,10 @@ class SongImportForm(OpenLPWizard):
translate('SongsPlugin.ImportWizardForm', 'Add Files...'))
self.dreamBeamRemoveButton.setText(
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(
translate('SongsPlugin.ImportWizardForm', 'Add Files...'))
self.songsOfFellowshipRemoveButton.setText(
@ -417,6 +431,12 @@ class SongImportForm(OpenLPWizard):
WizardStrings.YouSpecifyFile % WizardStrings.DB)
self.dreamBeamAddButton.setFocus()
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:
if self.songsOfFellowshipFileListWidget.count() == 0:
critical_error_message_box(UiStrings().NFSp,
@ -600,6 +620,22 @@ class SongImportForm(OpenLPWizard):
"""
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):
"""
Get Songs of Fellowship song database files
@ -717,6 +753,7 @@ class SongImportForm(OpenLPWizard):
self.wordsOfWorshipFileListWidget.clear()
self.ccliFileListWidget.clear()
self.dreamBeamFileListWidget.clear()
self.powerSongFileListWidget.clear()
self.songsOfFellowshipFileListWidget.clear()
self.genericFileListWidget.clear()
self.easySlidesFilenameEdit.setText(u'')
@ -784,6 +821,12 @@ class SongImportForm(OpenLPWizard):
filenames=self.getListOfFiles(
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:
# Import a Songs of Fellowship RTF file
importer = self.plugin.importSongs(SongFormat.SongsOfFellowship,

View File

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

View File

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