Fix up Icon code to use isinstance

Fix up code to ignore cases when doing tests.
This commit is contained in:
Tim Bentley 2009-12-04 20:25:48 +00:00
parent 547074d29a
commit b8149cc826
4 changed files with 16 additions and 12 deletions

View File

@ -97,9 +97,9 @@ def build_icon(icon):
``:/resource/file.png``, or a file location like ``/path/to/file.png``.
"""
ButtonIcon = None
if type(icon) is QtGui.QIcon:
if isinstance(icon, QtGui.QIcon):
ButtonIcon = icon
elif type(icon) is types.StringType or type(icon) is types.UnicodeType:
elif isinstance(icon, basestring):
ButtonIcon = QtGui.QIcon()
if icon.startswith(u':/'):
ButtonIcon.addPixmap(
@ -124,7 +124,7 @@ def build_icon(icon):
ButtonIcon.addPixmap(
pmap, QtGui.QIcon.Normal, QtGui.QIcon.Off)
elif type(icon) is QtGui.QImage:
elif isinstance(icon, QtGui.QImage):
ButtonIcon = QtGui.QIcon()
ButtonIcon.addPixmap(
QtGui.QPixmap.fromImage(icon), QtGui.QIcon.Normal, QtGui.QIcon.Off)

View File

@ -356,7 +356,7 @@ class SlideController(QtGui.QWidget):
self.Songbar.actions[action].setVisible(False)
if item.verse_order:
for slide in self.slideList:
self.Songbar.actions[slide].setVisible(True)
self.Songbar.actions[slide.lower()].setVisible(True)
self.Songbar.setVisible(True)
elif item.is_image():
#Not sensible to allow loops with 1 frame
@ -447,9 +447,9 @@ class SlideController(QtGui.QWidget):
if self.serviceItem.is_text():
#only load the slot once
try:
test = self.slideList[frame[u'verseTag']]
test = self.slideList[frame[u'verseTag'].lower()]
except:
self.slideList[frame[u'verseTag']] = framenumber
self.slideList[frame[u'verseTag'].lower()] = framenumber
item.setText(frame[u'text'])
else:
label = QtGui.QLabel()

View File

@ -401,7 +401,8 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
if self.AuthorsListView.count() == 0:
self.SongTabWidget.setCurrentIndex(2)
self.AuthorsListView.setFocus()
for verse in unicode(self.VerseOrderEdit.text()).split(u' '):
#split the verse list by space and mark lower case for testing
for verse in unicode(self.VerseOrderEdit.text()).lower().split(u' '):
if len(verse) == 2:
if verse[0:1] == u'v' and verse[1:].isdigit():
pass
@ -411,7 +412,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
return False, \
self.trUtf8('Invalid verse entry - vX')
else:
if u' BCITPEO'.find(verse.upper()) > -1:
if u' bcitped'.find(verse) > -1:
pass
else:
self.SongTabWidget.setCurrentIndex(0)

View File

@ -293,21 +293,24 @@ class SongMediaItem(MediaManagerItem):
if song.lyrics.startswith(u'<?xml version='):
songXML = SongXMLParser(song.lyrics)
verseList = songXML.get_verses()
if service_item.verse_order is None or service_item.verse_order == u'':
#no verse list or only 1 space (in error)
if service_item.verse_order is None or \
service_item.verse_order == u'' or service_item.verse_order == u' ':
for verse in verseList:
service_item.add_from_text(verse[1][:30], unicode(verse[1]))
else:
#Loop through the verse list and expand the song accordingly.
for order in service_item.verse_order.split(u' '):
for verse in verseList:
if verse[1]:
if verse[0][u'type'] == "Verse" and \
verse[0][u'label'][0] == order[1:]:
if verse[0][u'type'].lower() == "verse" and \
verse[0][u'label'][0].lower() == order[1:].lower():
verseTag = u'%s:%s' % \
(verse[0][u'type'], verse[0][u'label'])
service_item.add_from_text\
(verse[1][:30], verse[1], verseTag)
else:
if verse[0][u'type'][0] == order[0]:
if verse[0][u'type'][0].lower() == order[0].lower():
verseTag = u'%s:%s' % \
(verse[0][u'type'], verse[0][u'label'])
service_item.add_from_text\