Changed variable names

Doing some styling changes
This commit is contained in:
Oliver Wieland 2013-08-17 00:14:27 +02:00
parent cd8f1e29b1
commit 74572b07fd
4 changed files with 99 additions and 68 deletions

View File

@ -48,7 +48,7 @@ __default_settings__ = {
u'bibles/verse layout style': LayoutStyle.VersePerSlide,
u'bibles/book name language': LanguageSelection.Bible,
u'bibles/display brackets': DisplayStyle.NoBrackets,
u'bibles/verse number display': True,
u'bibles/is verse number visible': True,
u'bibles/display new chapter': False,
u'bibles/second bibles': True,
u'bibles/advanced bible': u'',

View File

@ -58,9 +58,9 @@ class BiblesTab(SettingsTab):
self.verse_display_group_box.setObjectName(u'verse_display_group_box')
self.verse_display_layout = QtGui.QFormLayout(self.verse_display_group_box)
self.verse_display_layout.setObjectName(u'verse_display_layout')
self.verse_number_display_check_box = QtGui.QCheckBox(self.verse_display_group_box)
self.verse_number_display_check_box.setObjectName(u'verse_display_check_box')
self.verse_display_layout.addRow(self.verse_number_display_check_box)
self.is_verse_number_visible_check_box = QtGui.QCheckBox(self.verse_display_group_box)
self.is_verse_number_visible_check_box.setObjectName(u'verse_display_check_box')
self.verse_display_layout.addRow(self.is_verse_number_visible_check_box)
self.new_chapters_check_box = QtGui.QCheckBox(self.verse_display_group_box)
self.new_chapters_check_box.setObjectName(u'new_chapters_check_box')
self.verse_display_layout.addRow(self.new_chapters_check_box)
@ -137,7 +137,7 @@ class BiblesTab(SettingsTab):
self.left_layout.addStretch()
self.right_layout.addStretch()
# Signals and slots
self.verse_number_display_check_box.stateChanged.connect(self.on_verse_number_display_check_box_changed)
self.is_verse_number_visible_check_box.stateChanged.connect(self.on_is_verse_number_visible_check_box_changed)
self.new_chapters_check_box.stateChanged.connect(self.on_new_chapters_check_box_changed)
self.display_style_combo_box.activated.connect(self.on_display_style_combo_box_changed)
self.bible_theme_combo_box.activated.connect(self.on_bible_theme_combo_box_changed)
@ -160,7 +160,7 @@ class BiblesTab(SettingsTab):
def retranslateUi(self):
self.verse_display_group_box.setTitle(translate('BiblesPlugin.BiblesTab', 'Verse Display'))
self.verse_number_display_check_box.setText(translate('BiblesPlugin.BiblesTab', 'Display verse numbers'))
self.is_verse_number_visible_check_box.setText(translate('BiblesPlugin.BiblesTab', 'Is verse number visible'))
self.new_chapters_check_box.setText(translate('BiblesPlugin.BiblesTab', 'Only show new chapter numbers'))
self.layout_style_label.setText(UiStrings().LayoutStyle)
self.display_style_label.setText(UiStrings().DisplayStyle)
@ -213,12 +213,12 @@ class BiblesTab(SettingsTab):
def on_language_selection_combo_box_changed(self):
self.language_selection = self.language_selection_combo_box.currentIndex()
def on_verse_number_display_check_box_changed(self, check_state):
self.verse_number_display = False
def on_is_verse_number_visible_check_box_changed(self, check_state):
self.is_verse_number_visible = False
# We have a set value convert to True/False.
if check_state == QtCore.Qt.Checked:
self.verse_number_display = True
self.check_verse_number_display()
self.is_verse_number_visible = True
self.check_is_verse_number_visible()
def on_new_chapters_check_box_changed(self, check_state):
self.show_new_chapters = False
@ -311,14 +311,14 @@ class BiblesTab(SettingsTab):
def load(self):
settings = Settings()
settings.beginGroup(self.settings_section)
self.verse_number_display = settings.value(u'verse number display')
self.is_verse_number_visible = settings.value(u'is verse number visible')
self.show_new_chapters = settings.value(u'display new chapter')
self.display_style = settings.value(u'display brackets')
self.layout_style = settings.value(u'verse layout style')
self.bible_theme = settings.value(u'bible theme')
self.second_bibles = settings.value(u'second bibles')
self.verse_number_display_check_box.setChecked(self.verse_number_display)
self.check_verse_number_display()
self.is_verse_number_visible_check_box.setChecked(self.is_verse_number_visible)
self.check_is_verse_number_visible()
self.new_chapters_check_box.setChecked(self.show_new_chapters)
self.display_style_combo_box.setCurrentIndex(self.display_style)
self.layout_style_combo_box.setCurrentIndex(self.layout_style)
@ -366,7 +366,7 @@ class BiblesTab(SettingsTab):
def save(self):
settings = Settings()
settings.beginGroup(self.settings_section)
settings.setValue(u'verse number display', self.verse_number_display)
settings.setValue(u'is verse number visible', self.is_verse_number_visible)
settings.setValue(u'display new chapter', self.show_new_chapters)
settings.setValue(u'display brackets', self.display_style)
settings.setValue(u'verse layout style', self.layout_style)
@ -422,11 +422,11 @@ class BiblesTab(SettingsTab):
palette.setColor(QtGui.QPalette.Active, QtGui.QPalette.Text, color)
return palette
def check_verse_number_display(self):
def check_is_verse_number_visible(self):
"""
Enables / Disables verse settings dependent on verse_number_display
Enables / Disables verse settings dependent on is_verse_number_visible
"""
self.new_chapters_check_box.setEnabled(self.verse_number_display)
self.display_style_label.setEnabled(self.verse_number_display)
self.display_style_combo_box.setEnabled(self.verse_number_display)
self.new_chapters_check_box.setEnabled(self.is_verse_number_visible)
self.display_style_label.setEnabled(self.is_verse_number_visible)
self.display_style_combo_box.setEnabled(self.is_verse_number_visible)

View File

@ -943,8 +943,7 @@ class BibleMediaItem(MediaManagerItem):
The verse number (int).
"""
verse_separator = get_reference_separator(u'sep_v_display')
if self.settings.verse_number_display:
if self.settings.is_verse_number_visible:
if not self.settings.show_new_chapters or old_chapter != chapter:
verse_text = unicode(chapter) + verse_separator + unicode(verse)
else:

View File

@ -1,20 +1,21 @@
"""
This module contains tests for the versereferencelist submodule of the Bibles plugin.
"""
from unittest import TestCase
from openlp.plugins.bibles.lib.versereferencelist import VerseReferenceList
class TestVerseReferenceList(TestCase):
def setUp(self):
self.reference_list = VerseReferenceList()
def add_test(self):
"""
Test the addition of verses to the list
Initializes all we need
"""
#GIVEN: book, chapter, verse and version
def add_first_verse_test(self):
"""
Test the addition of a verse to the empty list
"""
# GIVEN: an empty list
reference_list = VerseReferenceList()
book = u'testBook'
chapter = 1
verse = 1
@ -22,63 +23,94 @@ class TestVerseReferenceList(TestCase):
copyright = u'testCopyright'
permission = u'testPermision'
#WHEN: We add it to the verse list
self.reference_list.add(book, chapter, verse, version, copyright, permission)
# WHEN: We add it to the verse list
reference_list.add(book, chapter, verse, version, copyright, permission)
#THEN: The entries should be in the first entry of the list
self.assertEqual(self.reference_list.current_index, 0, u'The current index should be 0')
self.assertEqual(self.reference_list.verse_list[0][u'book'], book, u'The book in first entry should be %s' %book)
self.assertEqual(self.reference_list.verse_list[0][u'chapter'], chapter, u'The chapter in first entry should be %u' %chapter)
self.assertEqual(self.reference_list.verse_list[0][u'start'], verse, u'The start in first entry should be %u' %verse)
self.assertEqual(self.reference_list.verse_list[0][u'version'], version, u'The version in first entry should be %s' %version)
self.assertEqual(self.reference_list.verse_list[0][u'end'], verse, u'The end in first entry should be %u' %verse)
# THEN: The entries should be in the first entry of the list
self.assertEqual(reference_list.current_index, 0, u'The current index should be 0')
self.assertEqual(reference_list.verse_list[0][u'book'], book, u'The book in first entry should be %s' % book)
self.assertEqual(reference_list.verse_list[0][u'chapter'], chapter, u'The chapter in first entry should be %u' % chapter)
self.assertEqual(reference_list.verse_list[0][u'start'], verse, u'The start in first entry should be %u' % verse)
self.assertEqual(reference_list.verse_list[0][u'version'], version, u'The version in first entry should be %s' % version)
self.assertEqual(reference_list.verse_list[0][u'end'], verse, u'The end in first entry should be %u' % verse)
#GIVEN: next verse
verse = 2
def add_next_verse_test(self):
"""
Test the addition of the following verse
"""
# GIVEN: 1 line in the list of verses
book = u'testBook'
chapter = 1
verse = 1
next_verse = 2
version = u'testVersion'
copyright = u'testCopyright'
permission = u'testPermision'
reference_list = VerseReferenceList()
reference_list.add(book, chapter, verse, version, copyright, permission)
#WHEN: We add it to the verse list
self.reference_list.add(book, chapter, verse, version, copyright, permission)
# WHEN: We add the following verse to the verse list
reference_list.add(book, chapter, next_verse, version, copyright, permission)
#THEN: The current index should be 0 and the end pointer of the entry should be '2'
self.assertEqual(self.reference_list.current_index, 0, u'The current index should be 0')
self.assertEqual(self.reference_list.verse_list[0][u'end'], verse, u'The end in first entry should be %u' %verse)
# THEN: The current index should be 0 and the end pointer of the entry should be '2'
self.assertEqual(reference_list.current_index, 0, u'The current index should be 0')
self.assertEqual(reference_list.verse_list[0][u'end'], next_verse, u'The end in first entry should be %u' % next_verse)
#GIVEN: a verse in another book
book = u'testBook2'
chapter = 2
verse = 5
def add_another_verse_test(self):
"""
Test the addition of a verse in another book
"""
# GIVEN: 1 line in the list of verses
book = u'testBook'
chapter = 1
verse = 1
next_verse = 2
another_book = u'testBook2'
another_chapter = 2
another_verse = 5
version = u'testVersion'
copyright = u'testCopyright'
permission = u'testPermision'
reference_list = VerseReferenceList()
reference_list.add(book, chapter, verse, version, copyright, permission)
#WHEN: We add it to the verse list
self.reference_list.add(book, chapter, verse, version, copyright, permission)
# WHEN: We add a verse of another book to the verse list
reference_list.add(another_book, another_chapter, another_verse, version, copyright, permission)
#THEN: the current index should be 1
self.assertEqual(self.reference_list.current_index, 1, u'The current index should be 1')
# THEN: the current index should be 1
self.assertEqual(reference_list.current_index, 1, u'The current index should be 1')
def add_version_test(self):
"""
Test the addition of versions to the list
Test the addition of a version to the list
"""
#GIVEN: version, copyright and permission
# GIVEN: version, copyright and permission
reference_list = VerseReferenceList()
version = u'testVersion'
copyright = u'testCopyright'
permission = u'testPermision'
#WHEN: a not existing version will be added
self.reference_list.add_version(version, copyright, permission)
# WHEN: a not existing version will be added
reference_list.add_version(version, copyright, permission)
#THEN: the data will be appended to the list
self.assertEqual(self.reference_list.version_list[0], {u'version': version, u'copyright': copyright, u'permission': permission},
u'The version data should be appended')
# THEN: the data will be appended to the list
self.assertEqual(len(reference_list.version_list), 1, u'The version data should be appended')
self.assertEqual(reference_list.version_list[0], {u'version': version, u'copyright': copyright, u'permission': permission},
u'The version data should be appended')
#GIVEN: old length of the array
oldLen = self.reference_list.version_list.__len__()
def add_existing_version_test(self):
"""
Test the addition of an existing version to the list
"""
# GIVEN: version, copyright and permission, added to the version list
reference_list = VerseReferenceList()
version = u'testVersion'
copyright = u'testCopyright'
permission = u'testPermision'
reference_list.add_version(version, copyright, permission)
#WHEN: an existing version will be added
self.reference_list.add_version(version, copyright, permission)
# WHEN: an existing version will be added
reference_list.add_version(version, copyright, permission)
#THEN: the data will not be appended to the list
self.assertEqual(self.reference_list.version_list.__len__(), oldLen, u'The version data should not be appended')
# THEN: the data will not be appended to the list
self.assertEqual(len(reference_list.version_list), 1, u'The version data should not be appended')