forked from openlp/openlp
More code cleanups.
- Corrected more naming conventions - Changed old-style signal-slot connections - Added properties to the author form
This commit is contained in:
parent
0f7f17f79c
commit
761bb6339d
@ -73,9 +73,9 @@ class Ui_CustomEditDialog(object):
|
|||||||
self.buttonLayout.addWidget(self.deleteButton)
|
self.buttonLayout.addWidget(self.deleteButton)
|
||||||
self.buttonLayout.addStretch()
|
self.buttonLayout.addStretch()
|
||||||
self.upButton = create_button(customEditDialog, u'up_button', role=u'up', enabled=False,
|
self.upButton = create_button(customEditDialog, u'up_button', role=u'up', enabled=False,
|
||||||
click=customEditDialog.on_up_button_clicked)
|
click=customEditDialog.onUpButtonClicked)
|
||||||
self.downButton = create_button(customEditDialog, u'down_button', role=u'down', enabled=False,
|
self.downButton = create_button(customEditDialog, u'down_button', role=u'down', enabled=False,
|
||||||
click=customEditDialog.on_down_button_clicked)
|
click=customEditDialog.onDownButtonClicked)
|
||||||
self.buttonLayout.addWidget(self.upButton)
|
self.buttonLayout.addWidget(self.upButton)
|
||||||
self.buttonLayout.addWidget(self.downButton)
|
self.buttonLayout.addWidget(self.downButton)
|
||||||
self.centralLayout.addLayout(self.buttonLayout)
|
self.centralLayout.addLayout(self.buttonLayout)
|
||||||
|
@ -120,3 +120,39 @@ class AuthorsForm(QtGui.QDialog, Ui_AuthorsDialog):
|
|||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
return QtGui.QDialog.accept(self)
|
return QtGui.QDialog.accept(self)
|
||||||
|
|
||||||
|
def _get_first_name(self):
|
||||||
|
"""
|
||||||
|
Get the value of the first name from the UI widget.
|
||||||
|
"""
|
||||||
|
return self.first_name_edit.text()
|
||||||
|
|
||||||
|
def _set_first_name(self, value):
|
||||||
|
"""
|
||||||
|
Set the value of the first name in the UI widget.
|
||||||
|
"""
|
||||||
|
self.first_name_edit.setText(value)
|
||||||
|
|
||||||
|
first_name = property(_get_first_name, _set_first_name)
|
||||||
|
|
||||||
|
def _get_last_name(self):
|
||||||
|
"""
|
||||||
|
Get the value of the last name from the UI widget.
|
||||||
|
"""
|
||||||
|
return self.last_name_edit.text()
|
||||||
|
|
||||||
|
def _set_last_name(self, value):
|
||||||
|
"""
|
||||||
|
Set the value of the last name in the UI widget.
|
||||||
|
"""
|
||||||
|
self.last_name_edit.setText(value)
|
||||||
|
|
||||||
|
last_name = property(_get_last_name, _set_last_name)
|
||||||
|
|
||||||
|
def _get_display_name(self):
|
||||||
|
return self.display_edit.text()
|
||||||
|
|
||||||
|
def _set_display_name(self, value):
|
||||||
|
self.display_edit.setText(value)
|
||||||
|
|
||||||
|
display_name = property(_get_display_name, _set_display_name)
|
||||||
|
@ -70,16 +70,13 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||||||
self.setupUi(self)
|
self.setupUi(self)
|
||||||
# Connecting signals and slots
|
# Connecting signals and slots
|
||||||
self.author_add_button.clicked.connect(self.on_author_add_button_clicked)
|
self.author_add_button.clicked.connect(self.on_author_add_button_clicked)
|
||||||
QtCore.QObject.connect(self.author_remove_button, QtCore.SIGNAL(u'clicked()'), self.onAuthorRemoveButtonClicked)
|
self.author_remove_button.clicked.connect(self.onAuthorRemoveButtonClicked)
|
||||||
QtCore.QObject.connect(self.authors_list_view, QtCore.SIGNAL(u'itemClicked(QListWidgetItem*)'),
|
self.authors_list_view.itemClicked.connect(self.onAuthorsListViewClicked)
|
||||||
self.onAuthorsListViewClicked)
|
self.topic_add_button.clicked.connect(self.onTopicAddButtonClicked)
|
||||||
QtCore.QObject.connect(self.topic_add_button, QtCore.SIGNAL(u'clicked()'), self.onTopicAddButtonClicked)
|
self.topic_remove_button.clicked.connect(self.onTopicRemoveButtonClicked)
|
||||||
QtCore.QObject.connect(self.topic_remove_button, QtCore.SIGNAL(u'clicked()'), self.onTopicRemoveButtonClicked)
|
self.topics_list_view.itemClicked.connect(self.onTopicListViewClicked)
|
||||||
QtCore.QObject.connect(self.topics_list_view, QtCore.SIGNAL(u'itemClicked(QListWidgetItem*)'),
|
self.copyright_insert_button.clicked.connect(self.onCopyrightInsertButtonTriggered)
|
||||||
self.onTopicListViewClicked)
|
self.verse_add_button.clicked.connect(self.onVerseAddButtonClicked)
|
||||||
QtCore.QObject.connect(self.copyright_insert_button, QtCore.SIGNAL(u'clicked()'),
|
|
||||||
self.onCopyrightInsertButtonTriggered)
|
|
||||||
QtCore.QObject.connect(self.verse_add_button, QtCore.SIGNAL(u'clicked()'), self.onVerseAddButtonClicked)
|
|
||||||
QtCore.QObject.connect(self.verse_list_widget, QtCore.SIGNAL(u'doubleClicked(QModelIndex)'),
|
QtCore.QObject.connect(self.verse_list_widget, QtCore.SIGNAL(u'doubleClicked(QModelIndex)'),
|
||||||
self.onVerseEditButtonClicked)
|
self.onVerseEditButtonClicked)
|
||||||
QtCore.QObject.connect(self.verse_edit_button, QtCore.SIGNAL(u'clicked()'), self.onVerseEditButtonClicked)
|
QtCore.QObject.connect(self.verse_edit_button, QtCore.SIGNAL(u'clicked()'), self.onVerseEditButtonClicked)
|
||||||
|
@ -212,9 +212,10 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog):
|
|||||||
self.authorform.auto_display_name = True
|
self.authorform.auto_display_name = True
|
||||||
if self.authorform.exec_():
|
if self.authorform.exec_():
|
||||||
author = Author.populate(
|
author = Author.populate(
|
||||||
first_name=self.authorform.first_name_edit.text(),
|
first_name=self.authorform.first_name,
|
||||||
last_name=self.authorform.last_name_edit.text(),
|
last_name=self.authorform.last_name,
|
||||||
display_name=self.authorform.display_edit.text())
|
display_name=self.authorform.display_name
|
||||||
|
)
|
||||||
if self.checkAuthor(author):
|
if self.checkAuthor(author):
|
||||||
if self.manager.save_object(author):
|
if self.manager.save_object(author):
|
||||||
self.resetAuthors()
|
self.resetAuthors()
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
"""
|
"""
|
||||||
Package to test the openlp.core.ui package.
|
Package to test the openlp.core.ui package.
|
||||||
"""
|
"""
|
||||||
from unittest import TestCase
|
from unittest import TestCase
|
||||||
|
|
||||||
|
1
tests/interfaces/openlp_plugins_songs_forms/__init__.py
Normal file
1
tests/interfaces/openlp_plugins_songs_forms/__init__.py
Normal file
@ -0,0 +1 @@
|
|||||||
|
__author__ = 'raoul'
|
126
tests/interfaces/openlp_plugins_songs_forms/test_authorsform.py
Normal file
126
tests/interfaces/openlp_plugins_songs_forms/test_authorsform.py
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
"""
|
||||||
|
Package to test the openlp.core.ui package.
|
||||||
|
"""
|
||||||
|
import sip
|
||||||
|
sip.setapi(u'QDate', 2)
|
||||||
|
sip.setapi(u'QDateTime', 2)
|
||||||
|
sip.setapi(u'QString', 2)
|
||||||
|
sip.setapi(u'QTextStream', 2)
|
||||||
|
sip.setapi(u'QTime', 2)
|
||||||
|
sip.setapi(u'QUrl', 2)
|
||||||
|
sip.setapi(u'QVariant', 2)
|
||||||
|
|
||||||
|
from unittest import TestCase
|
||||||
|
|
||||||
|
from PyQt4 import QtGui
|
||||||
|
|
||||||
|
from openlp.plugins.songs.forms.authorsform import AuthorsForm
|
||||||
|
from openlp.core.lib import Registry
|
||||||
|
|
||||||
|
|
||||||
|
class TestAuthorsForm(TestCase):
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
"""
|
||||||
|
Create the UI
|
||||||
|
"""
|
||||||
|
Registry.create()
|
||||||
|
self.app = QtGui.QApplication([])
|
||||||
|
self.main_window = QtGui.QMainWindow()
|
||||||
|
Registry().register(u'main_window', self.main_window)
|
||||||
|
self.form = AuthorsForm()
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
"""
|
||||||
|
Delete all the C++ objects at the end so that we don't have a segfault
|
||||||
|
"""
|
||||||
|
del self.form
|
||||||
|
del self.main_window
|
||||||
|
del self.app
|
||||||
|
|
||||||
|
def ui_defaults_test(self):
|
||||||
|
"""
|
||||||
|
Test the AuthorForm defaults are correct
|
||||||
|
"""
|
||||||
|
self.assertEqual(self.form.first_name_edit.text(), u'', u'The first name edit should be empty')
|
||||||
|
self.assertEqual(self.form.last_name_edit.text(), u'', u'The last name edit should be empty')
|
||||||
|
self.assertEqual(self.form.display_edit.text(), u'', u'The display name edit should be empty')
|
||||||
|
|
||||||
|
def get_first_name_property_test(self):
|
||||||
|
"""
|
||||||
|
Test that getting the first name property on the AuthorForm works correctly.
|
||||||
|
"""
|
||||||
|
# GIVEN: A first name to set
|
||||||
|
first_name = u'John'
|
||||||
|
|
||||||
|
# WHEN: The first_name_edit's text is set
|
||||||
|
self.form.first_name_edit.setText(first_name)
|
||||||
|
|
||||||
|
# THEN: The first_name property should have the correct value
|
||||||
|
self.assertEqual(self.form.first_name, first_name, u'The first name property should be correct')
|
||||||
|
|
||||||
|
def set_first_name_property_test(self):
|
||||||
|
"""
|
||||||
|
Test that setting the first name property on the AuthorForm works correctly.
|
||||||
|
"""
|
||||||
|
# GIVEN: A first name to set
|
||||||
|
first_name = u'James'
|
||||||
|
|
||||||
|
# WHEN: The first_name property is set
|
||||||
|
self.form.first_name = first_name
|
||||||
|
|
||||||
|
# THEN: The first_name_edit should have the correct value
|
||||||
|
self.assertEqual(self.form.first_name_edit.text(), first_name, u'The first name should be set correctly')
|
||||||
|
|
||||||
|
def get_last_name_property_test(self):
|
||||||
|
"""
|
||||||
|
Test that getting the last name property on the AuthorForm works correctly.
|
||||||
|
"""
|
||||||
|
# GIVEN: A last name to set
|
||||||
|
last_name = u'Smith'
|
||||||
|
|
||||||
|
# WHEN: The last_name_edit's text is set
|
||||||
|
self.form.last_name_edit.setText(last_name)
|
||||||
|
|
||||||
|
# THEN: The last_name property should have the correct value
|
||||||
|
self.assertEqual(self.form.last_name, last_name, u'The last name property should be correct')
|
||||||
|
|
||||||
|
def set_last_name_property_test(self):
|
||||||
|
"""
|
||||||
|
Test that setting the last name property on the AuthorForm works correctly.
|
||||||
|
"""
|
||||||
|
# GIVEN: A last name to set
|
||||||
|
last_name = u'Potter'
|
||||||
|
|
||||||
|
# WHEN: The last_name property is set
|
||||||
|
self.form.last_name = last_name
|
||||||
|
|
||||||
|
# THEN: The last_name_edit should have the correct value
|
||||||
|
self.assertEqual(self.form.last_name_edit.text(), last_name, u'The last name should be set correctly')
|
||||||
|
|
||||||
|
def get_display_name_property_test(self):
|
||||||
|
"""
|
||||||
|
Test that getting the display name property on the AuthorForm works correctly.
|
||||||
|
"""
|
||||||
|
# GIVEN: A display name to set
|
||||||
|
display_name = u'John'
|
||||||
|
|
||||||
|
# WHEN: The display_name_edit's text is set
|
||||||
|
self.form.display_name_edit.setText(display_name)
|
||||||
|
|
||||||
|
# THEN: The display_name property should have the correct value
|
||||||
|
self.assertEqual(self.form.display_name, display_name, u'The display name property should be correct')
|
||||||
|
|
||||||
|
def set_display_name_property_test(self):
|
||||||
|
"""
|
||||||
|
Test that setting the display name property on the AuthorForm works correctly.
|
||||||
|
"""
|
||||||
|
# GIVEN: A display name to set
|
||||||
|
display_name = u'John'
|
||||||
|
|
||||||
|
# WHEN: The display_name property is set
|
||||||
|
self.form.display_name = display_name
|
||||||
|
|
||||||
|
# THEN: The display_name_edit should have the correct value
|
||||||
|
self.assertEqual(self.form.display_name_edit.text(), display_name, u'The display name should be set correctly')
|
||||||
|
|
Loading…
Reference in New Issue
Block a user