Fixes and cleanups

bzr-revno: 949
This commit is contained in:
Jon Tibble 2010-07-17 19:47:55 +01:00
commit f757117771
5 changed files with 31 additions and 85 deletions

View File

@ -178,7 +178,8 @@ class ImportWizardForm(QtGui.QWizard, Ui_SongImportWizard):
SettingsManager.get_last_dir(self.songsplugin.settingsSection, 1))
if filename:
editbox.setText(filename)
self.config.set_last_dir(filename, 1)
SettingsManager.set_last_dir(self.songsplugin.settingsSection,
filename, 1)
def incrementProgressBar(self, status_text):
log.debug(u'IncrementBar %s', status_text)

View File

@ -109,16 +109,16 @@ class Ui_SongImportWizard(object):
self.OpenLyricsButtonLayout.setSpacing(8)
self.OpenLyricsButtonLayout.setObjectName(u'OpenLyricsButtonLayout')
self.OpenLyricsAddButton = QtGui.QPushButton(self.OpenLyricsPage)
self.OpenLyricsAddButton.setIcon(
build_icon(u':/general/general_open.png'))
openIcon = build_icon(u':/general/general_open.png')
self.OpenLyricsAddButton.setIcon(openIcon)
self.OpenLyricsAddButton.setObjectName(u'OpenLyricsAddButton')
self.OpenLyricsButtonLayout.addWidget(self.OpenLyricsAddButton)
self.OpenLyricsButtonSpacer = QtGui.QSpacerItem(40, 20,
QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.OpenLyricsButtonLayout.addItem(self.OpenLyricsButtonSpacer)
self.OpenLyricsRemoveButton = QtGui.QPushButton(self.OpenLyricsPage)
self.OpenLyricsRemoveButton.setIcon(
build_icon(u':/general/general_delete.png'))
deleteIcon = build_icon(u':/general/general_delete.png')
self.OpenLyricsRemoveButton.setIcon(deleteIcon)
self.OpenLyricsRemoveButton.setObjectName(u'OpenLyricsRemoveButton')
self.OpenLyricsButtonLayout.addWidget(self.OpenLyricsRemoveButton)
self.OpenLyricsLayout.addLayout(self.OpenLyricsButtonLayout)
@ -136,14 +136,14 @@ class Ui_SongImportWizard(object):
self.OpenSongButtonLayout.setSpacing(8)
self.OpenSongButtonLayout.setObjectName(u'OpenSongButtonLayout')
self.OpenSongAddButton = QtGui.QPushButton(self.OpenSongPage)
self.OpenSongAddButton.setIcon(self.OpenIcon)
self.OpenSongAddButton.setIcon(openIcon)
self.OpenSongAddButton.setObjectName(u'OpenSongAddButton')
self.OpenSongButtonLayout.addWidget(self.OpenSongAddButton)
self.OpenSongButtonSpacer = QtGui.QSpacerItem(40, 20,
QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.OpenSongButtonLayout.addItem(self.OpenSongButtonSpacer)
self.OpenSongRemoveButton = QtGui.QPushButton(self.OpenSongPage)
self.OpenSongRemoveButton.setIcon(self.DeleteIcon)
self.OpenSongRemoveButton.setIcon(deleteIcon)
self.OpenSongRemoveButton.setObjectName(u'OpenSongRemoveButton')
self.OpenSongButtonLayout.addWidget(self.OpenSongRemoveButton)
self.OpenSongLayout.addLayout(self.OpenSongButtonLayout)
@ -161,14 +161,14 @@ class Ui_SongImportWizard(object):
self.CCLIButtonLayout.setSpacing(8)
self.CCLIButtonLayout.setObjectName(u'CCLIButtonLayout')
self.CCLIAddButton = QtGui.QPushButton(self.CCLIPage)
self.CCLIAddButton.setIcon(self.OpenIcon)
self.CCLIAddButton.setIcon(openIcon)
self.CCLIAddButton.setObjectName(u'CCLIAddButton')
self.CCLIButtonLayout.addWidget(self.CCLIAddButton)
self.CCLIButtonSpacer = QtGui.QSpacerItem(40, 20,
QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.CCLIButtonLayout.addItem(self.CCLIButtonSpacer)
self.CCLIRemoveButton = QtGui.QPushButton(self.CCLIPage)
self.CCLIRemoveButton.setIcon(self.DeleteIcon)
self.CCLIRemoveButton.setIcon(deleteIcon)
self.CCLIRemoveButton.setObjectName(u'CCLIRemoveButton')
self.CCLIButtonLayout.addWidget(self.CCLIRemoveButton)
self.CCLILayout.addLayout(self.CCLIButtonLayout)
@ -190,7 +190,7 @@ class Ui_SongImportWizard(object):
self.CSVFilenameEdit.setObjectName(u'CSVFilenameEdit')
self.CSVFileLayout.addWidget(self.CSVFilenameEdit)
self.CSVBrowseButton = QtGui.QToolButton(self.CSVPage)
self.CSVBrowseButton.setIcon(self.OpenIcon)
self.CSVBrowseButton.setIcon(openIcon)
self.CSVBrowseButton.setObjectName(u'CSVBrowseButton')
self.CSVFileLayout.addWidget(self.CSVBrowseButton)
self.CSVLayout.setLayout(0, QtGui.QFormLayout.FieldRole,
@ -213,14 +213,11 @@ class Ui_SongImportWizard(object):
self.ImportProgressBar.setObjectName(u'ImportProgressBar')
self.ImportLayout.addWidget(self.ImportProgressBar)
SongImportWizard.addPage(self.ImportPage)
self.retranslateUi(SongImportWizard)
self.FormatStackedWidget.setCurrentIndex(0)
QtCore.QObject.connect(
self.FormatComboBox,
QtCore.QObject.connect(self.FormatComboBox,
QtCore.SIGNAL(u'currentIndexChanged(int)'),
self.FormatStackedWidget.setCurrentIndex
)
self.FormatStackedWidget.setCurrentIndex)
QtCore.QMetaObject.connectSlotsByName(SongImportWizard)
def retranslateUi(self, SongImportWizard):
@ -275,4 +272,3 @@ class Ui_SongImportWizard(object):
translate('SongsPlugin.ImportWizardForm', 'Ready.'))
self.ImportProgressBar.setFormat(
translate('SongsPlugin.ImportWizardForm', '%p%'))

View File

@ -142,7 +142,7 @@ class SofImport(OooImport):
self.blanklines += 1
if self.blanklines > 1:
return
if self.song.get_title() != u'':
if self.song.title != u'':
self.finish_verse()
return
self.blanklines = 0
@ -166,8 +166,8 @@ class SofImport(OooImport):
self.finish_verse()
self.song.repeat_verse()
return
if self.song.get_title() == u'':
if self.song.get_copyright() == u'':
if self.song.title == u'':
if self.song.copyright == u'':
self.add_author(text)
else:
self.song.add_copyright(text)
@ -187,10 +187,10 @@ class SofImport(OooImport):
return text
if textportion.CharWeight == BOLD:
boldtext = text.strip()
if boldtext.isdigit() and self.song.get_song_number() == '':
if boldtext.isdigit() and self.song.song_number == '':
self.add_songnumber(boldtext)
return u''
if self.song.get_title() == u'':
if self.song.title == u'':
text = self.uncap_text(text)
self.add_title(text)
return text
@ -220,20 +220,17 @@ class SofImport(OooImport):
Add a song number, store as alternate title. Also use the song
number to work out which songbook we're in
"""
self.song.set_song_number(song_no)
self.song.set_alternate_title(song_no + u'.')
self.song.song_number = song_no
self.song.alternate_title = song_no + u'.'
self.song.song_book_pub = u'Kingsway Publications'
if int(song_no) <= 640:
self.song.set_song_book(u'Songs of Fellowship 1',
u'Kingsway Publications')
self.song.song_book = u'Songs of Fellowship 1'
elif int(song_no) <= 1150:
self.song.set_song_book(u'Songs of Fellowship 2',
u'Kingsway Publications')
self.song.song_book = u'Songs of Fellowship 2'
elif int(song_no) <= 1690:
self.song.set_song_book(u'Songs of Fellowship 3',
u'Kingsway Publications')
self.song.song_book = u'Songs of Fellowship 3'
else:
self.song.set_song_book(u'Songs of Fellowship 4',
u'Kingsway Publications')
self.song.song_book = u'Songs of Fellowship 4'
def add_title(self, text):
"""
@ -245,7 +242,7 @@ class SofImport(OooImport):
title = title[1:]
if title.endswith(u','):
title = title[:-1]
self.song.set_title(title)
self.song.title = title
def add_author(self, text):
"""
@ -283,7 +280,7 @@ class SofImport(OooImport):
splitat = None
else:
versetag = u'V'
splitat = self.verse_splits(self.song.get_song_number())
splitat = self.verse_splits(self.song.song_number)
if splitat:
ln = 0
verse = u''
@ -538,4 +535,3 @@ class SofImport(OooImport):
if song_number == 1119:
return 7
return None

View File

@ -123,53 +123,10 @@ class SongImport(object):
if len(lines) == 1:
self.parse_author(lines[0])
return
if not self.get_title():
self.set_title(lines[0])
if not self.title:
self.title = lines[0]
self.add_verse(text)
def get_title(self):
"""
Return the title
"""
return self.title
def get_copyright(self):
"""
Return the copyright
"""
return self.copyright
def get_song_number(self):
"""
Return the song number
"""
return self.song_number
def set_title(self, title):
"""
Set the title
"""
self.title = title
def set_alternate_title(self, title):
"""
Set the alternate title
"""
self.alternate_title = title
def set_song_number(self, song_number):
"""
Set the song number
"""
self.song_number = song_number
def set_song_book(self, song_book, publisher):
"""
Set the song book name and publisher
"""
self.song_book_name = song_book
self.song_book_pub = publisher
def add_copyright(self, copyright):
"""
Build the copyright field

View File

@ -366,10 +366,6 @@ class Song(object):
if len(self.search_title) < 1:
raise SongTitleError(u'The searchable title is empty')
def get_title(self):
"""Return title value"""
return self.title
def from_ccli_text_buffer(self, textList):
"""
Create song from a list of texts (strings) - CCLI text format expected
@ -688,7 +684,7 @@ class Song(object):
raise SongSlideError(u'Slide number too high')
res = []
if self.show_title:
title = self.get_title()
title = self.title
else:
title = ""
if self.show_author_list: