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)) SettingsManager.get_last_dir(self.songsplugin.settingsSection, 1))
if filename: if filename:
editbox.setText(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): def incrementProgressBar(self, status_text):
log.debug(u'IncrementBar %s', status_text) log.debug(u'IncrementBar %s', status_text)
@ -253,4 +254,4 @@ class ImportWizardForm(QtGui.QWizard, Ui_SongImportWizard):
self.ImportProgressBar.setValue(self.ImportProgressBar.maximum()) self.ImportProgressBar.setValue(self.ImportProgressBar.maximum())
self.finishButton.setVisible(True) self.finishButton.setVisible(True)
self.cancelButton.setVisible(False) self.cancelButton.setVisible(False)
Receiver.send_message(u'process_events') Receiver.send_message(u'process_events')

View File

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

View File

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

View File

@ -123,53 +123,10 @@ class SongImport(object):
if len(lines) == 1: if len(lines) == 1:
self.parse_author(lines[0]) self.parse_author(lines[0])
return return
if not self.get_title(): if not self.title:
self.set_title(lines[0]) self.title = lines[0]
self.add_verse(text) 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): def add_copyright(self, copyright):
""" """
Build the copyright field Build the copyright field

View File

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