moved Dialog from mediaitem.py to bibleimportform.py

some fixes
This commit is contained in:
Armin Köhler 2011-04-02 21:17:48 +02:00
parent c04a76e12d
commit 9de33cf194
14 changed files with 57 additions and 57 deletions

View File

@ -50,9 +50,8 @@ This allows OpenLP to use ``self.object`` for all the GUI elements while keeping
them separate from the functionality, so that it is easier to recreate the GUI
from the .ui files later if necessary.
"""
from bibleimportform import BibleImportForm
from booknameform import BookNameForm
from languageform import LanguageForm
from bibleimportform import BibleImportForm
__all__ = ['BibleImportForm']

View File

@ -40,6 +40,7 @@ from openlp.core.ui.wizard import OpenLPWizard, WizardStrings
from openlp.core.utils import AppLocation, string_is_unicode
from openlp.plugins.bibles.lib.manager import BibleFormat
from openlp.plugins.bibles.lib.db import BiblesResourcesDB
from openlp.plugins.bibles.forms import BookNameForm, LanguageForm
log = logging.getLogger(__name__)
@ -758,3 +759,13 @@ class BibleImportForm(OpenLPWizard):
'BiblesPlugin.ImportWizardForm', 'Your Bible import failed.'))
del self.manager.db_cache[importer.name]
delete_database(self.plugin.settingsSection, importer.file)
def bookNameDialog(self, name):
self.book_name = BookNameForm(self)
if self.book_name.exec_(name):
return unicode(self.book_name.requestComboBox.currentText())
def languageDialog(self):
self.language = LanguageForm(self)
if self.language.exec_():
return unicode(self.language.requestComboBox.currentText())

View File

@ -31,7 +31,7 @@ from openlp.core.lib.ui import create_accept_reject_button_box
class Ui_BookNameDialog(object):
def setupUi(self, bookNameDialog):
bookNameDialog.setObjectName("BookNameDialog")
bookNameDialog.setObjectName(u'BookNameDialog')
bookNameDialog.resize(400, 175)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred,
QtGui.QSizePolicy.MinimumExpanding)
@ -42,25 +42,25 @@ class Ui_BookNameDialog(object):
bookNameDialog.setSizePolicy(sizePolicy)
self.widget = QtGui.QWidget(bookNameDialog)
self.widget.setGeometry(QtCore.QRect(10, 15, 381, 151))
self.widget.setObjectName("widget")
self.widget.setObjectName(u'widget')
self.verticalLayout = QtGui.QVBoxLayout(self.widget)
self.verticalLayout.setObjectName("verticalLayout")
self.verticalLayout.setObjectName(u'verticalLayout')
self.headlineLabel = QtGui.QLabel(self.widget)
font = QtGui.QFont()
font.setFamily("Arial")
font.setFamily(u'Arial')
font.setPointSize(11)
font.setWeight(75)
font.setBold(True)
self.headlineLabel.setFont(font)
self.headlineLabel.setObjectName("HeadlineLabel")
self.headlineLabel.setObjectName(u'HeadlineLabel')
self.verticalLayout.addWidget(self.headlineLabel)
self.infoLabel = QtGui.QLabel(self.widget)
self.infoLabel.setObjectName("InfoLabel")
self.infoLabel.setObjectName(u'InfoLabel')
self.verticalLayout.addWidget(self.infoLabel)
self.formLayout = QtGui.QFormLayout()
self.formLayout.setObjectName("formLayout")
self.formLayout.setObjectName(u'formLayout')
self.requestLabel = QtGui.QLabel(self.widget)
self.requestLabel.setObjectName("RequestLabel")
self.requestLabel.setObjectName(u'RequestLabel')
self.formLayout.setWidget(0, QtGui.QFormLayout.LabelRole,
self.requestLabel)
self.requestComboBox = QtGui.QComboBox(self.widget)
@ -71,7 +71,7 @@ class Ui_BookNameDialog(object):
sizePolicy.setHeightForWidth(self.requestComboBox.sizePolicy()
.hasHeightForWidth())
self.requestComboBox.setSizePolicy(sizePolicy)
self.requestComboBox.setObjectName("RequestComboBox")
self.requestComboBox.setObjectName(u'RequestComboBox')
self.formLayout.setWidget(0, QtGui.QFormLayout.FieldRole,
self.requestComboBox)
self.verticalLayout.addLayout(self.formLayout)
@ -85,11 +85,11 @@ class Ui_BookNameDialog(object):
def retranslateUi(self, bookNameDialog):
bookNameDialog.setWindowTitle(
translate("BiblesPlugin.BookNameDialog", "Choose Book"))
translate('BiblesPlugin.BookNameDialog', 'Choose Book'))
self.headlineLabel.setText(
translate("BiblesPlugin.BookNameDialog", "Choose Book:"))
self.infoLabel.setText(translate("BiblesPlugin.BookNameDialog",
"The following books cannot be clearly attributed. \n"
"Please choose the book it is."))
self.requestLabel.setText(translate("BiblesPlugin.BookNameDialog",
"Book:"))
translate('BiblesPlugin.BookNameDialog', 'Choose Book:'))
self.infoLabel.setText(translate('BiblesPlugin.BookNameDialog',
'The following books cannot be clearly attributed. \n'
'Please choose the book it is.'))
self.requestLabel.setText(translate('BiblesPlugin.BookNameDialog',
'Book:'))

View File

@ -41,7 +41,8 @@ log = logging.getLogger(__name__)
class BookNameForm(QDialog, Ui_BookNameDialog):
"""
Class documentation goes here.
Class to manage a dialog which help the user to refer a book name a
to a english book name
"""
log.info(u'BookNameForm loaded')
@ -56,14 +57,14 @@ class BookNameForm(QDialog, Ui_BookNameDialog):
items = []
self.requestComboBox.addItem(u'')
self.requestLabel.setText(
translate("BiblesPlugin.BookNameForm", name))
translate('BiblesPlugin.BookNameForm', name))
items = BiblesResourcesDB.get_books()
for item in items:
self.requestComboBox.addItem(item[u'name'])
return QDialog.exec_(self)
def accept(self):
if self.requestComboBox.currentText() == u"":
if self.requestComboBox.currentText() == u'':
critical_error_message_box(
message=translate('BiblesPlugin.BookNameForm',
'You need to choose a book.'))

View File

@ -31,7 +31,7 @@ from openlp.core.lib.ui import create_accept_reject_button_box
class Ui_LanguageDialog(object):
def setupUi(self, languageDialog):
languageDialog.setObjectName("LanugageDialog")
languageDialog.setObjectName(u'LanugageDialog')
languageDialog.resize(400, 175)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred,
QtGui.QSizePolicy.MinimumExpanding)
@ -42,25 +42,25 @@ class Ui_LanguageDialog(object):
languageDialog.setSizePolicy(sizePolicy)
self.widget = QtGui.QWidget(languageDialog)
self.widget.setGeometry(QtCore.QRect(10, 15, 381, 151))
self.widget.setObjectName("widget")
self.widget.setObjectName(u'widget')
self.verticalLayout = QtGui.QVBoxLayout(self.widget)
self.verticalLayout.setObjectName("verticalLayout")
self.verticalLayout.setObjectName(u'verticalLayout')
self.headlineLabel = QtGui.QLabel(self.widget)
font = QtGui.QFont()
font.setFamily("Arial")
font.setFamily(u'Arial')
font.setPointSize(11)
font.setWeight(75)
font.setBold(True)
self.headlineLabel.setFont(font)
self.headlineLabel.setObjectName("HeadlineLabel")
self.headlineLabel.setObjectName(u'HeadlineLabel')
self.verticalLayout.addWidget(self.headlineLabel)
self.infoLabel = QtGui.QLabel(self.widget)
self.infoLabel.setObjectName("InfoLabel")
self.infoLabel.setObjectName(u'InfoLabel')
self.verticalLayout.addWidget(self.infoLabel)
self.formLayout = QtGui.QFormLayout()
self.formLayout.setObjectName("formLayout")
self.formLayout.setObjectName(u'formLayout')
self.requestLabel = QtGui.QLabel(self.widget)
self.requestLabel.setObjectName("RequestLabel")
self.requestLabel.setObjectName(u'RequestLabel')
self.formLayout.setWidget(0, QtGui.QFormLayout.LabelRole,
self.requestLabel)
self.requestComboBox = QtGui.QComboBox(self.widget)
@ -71,7 +71,7 @@ class Ui_LanguageDialog(object):
sizePolicy.setHeightForWidth(self.requestComboBox.sizePolicy()
.hasHeightForWidth())
self.requestComboBox.setSizePolicy(sizePolicy)
self.requestComboBox.setObjectName("RequestComboBox")
self.requestComboBox.setObjectName(u'RequestComboBox')
self.formLayout.setWidget(0, QtGui.QFormLayout.FieldRole,
self.requestComboBox)
self.verticalLayout.addLayout(self.formLayout)
@ -85,10 +85,10 @@ class Ui_LanguageDialog(object):
def retranslateUi(self, languageDialog):
languageDialog.setWindowTitle(
translate("BiblesPlugin.LanguageDialog", "Choose Language"))
translate('BiblesPlugin.LanguageDialog', 'Choose Language'))
self.headlineLabel.setText(
translate("BiblesPlugin.LanguageDialog", "Choose Language:"))
self.infoLabel.setText(translate("BiblesPlugin.LanguageDialog",
"Please choose the language the bible is."))
self.requestLabel.setText(translate("BiblesPlugin.languageDialog",
"Language:"))
translate('BiblesPlugin.LanguageDialog', 'Choose Language:'))
self.infoLabel.setText(translate('BiblesPlugin.LanguageDialog',
'Please choose the language the bible is.'))
self.requestLabel.setText(translate('BiblesPlugin.languageDialog',
'Language:'))

View File

@ -41,7 +41,7 @@ log = logging.getLogger(__name__)
class LanguageForm(QDialog, Ui_LanguageDialog):
"""
Class documentation goes here.
Class to manage a dialog which ask the user for a language.
"""
log.info(u'LanguageForm loaded')
@ -61,7 +61,7 @@ class LanguageForm(QDialog, Ui_LanguageDialog):
return QDialog.exec_(self)
def accept(self):
if self.requestComboBox.currentText() == u"":
if self.requestComboBox.currentText() == u'':
critical_error_message_box(
message=translate('BiblesPlugin.LanguageForm',
'You need to choose a language.'))

View File

@ -139,7 +139,7 @@ class CSVBible(BibleDB):
self.wizard.progressBar.setMinimum(0)
self.wizard.progressBar.setMaximum(66)
success = True
language = self.parent.mediaItem.languageDialog()
language = self.parent.manager.import_wizard.languageDialog()
if not language:
log.exception(u'Importing books from %s " '\
'failed' % self.booksfile)

View File

@ -785,7 +785,7 @@ class BiblesResourcesDB(QtCore.QObject, Manager):
``name``
The name or abbreviation of the language.
"""
log.debug(u'BiblesResourcesDB.get_language("%s", "%s")', name)
log.debug(u'BiblesResourcesDB.get_language("%s")', name)
if not isinstance(name, unicode):
name = unicode(name)
name = name.title()

View File

@ -414,7 +414,7 @@ class HTTPBible(BibleDB):
if bible[u'language_id']:
language_id = bible[u'language_id']
else:
language = self.parent.mediaItem.languageDialog()
language = self.parent.manager.import_wizard.languageDialog()
if not language:
log.exception(u'Importing books from %s - download name: "%s" '\
'failed' % (self.download_source, self.download_name))

View File

@ -348,7 +348,7 @@ class BibleManager(object):
book_id = self.alternative_book_names_cache.get_book_reference_id(
book, language_id)
else:
book_ref = self.parent.mediaItem.bookNameDialog(book)
book_ref = self.import_wizard.bookNameDialog(book)
log.debug(book_ref)
book_temp = BiblesResourcesDB.get_book(book_ref)
log.debug(book_temp)

View File

@ -33,8 +33,7 @@ from openlp.core.lib import MediaManagerItem, Receiver, ItemCapabilities, \
from openlp.core.lib.searchedit import SearchEdit
from openlp.core.lib.ui import UiStrings, add_widget_completer, \
media_item_combo_box, critical_error_message_box
from openlp.plugins.bibles.forms import BibleImportForm, BookNameForm, \
LanguageForm
from openlp.plugins.bibles.forms import BibleImportForm
from openlp.plugins.bibles.lib import LayoutStyle, DisplayStyle, \
VerseReferenceList, get_reference_match
@ -287,16 +286,6 @@ class BibleMediaItem(MediaManagerItem):
if self.import_wizard.exec_():
self.reloadBibles()
def bookNameDialog(self, name):
self.book_name = BookNameForm(self)
if self.book_name.exec_(name):
return unicode(self.book_name.requestComboBox.currentText())
def languageDialog(self):
self.language = LanguageForm(self)
if self.language.exec_():
return unicode(self.language.requestComboBox.currentText())
def loadBibles(self):
log.debug(u'Loading Bibles')
self.quickVersionComboBox.clear()

View File

@ -58,7 +58,7 @@ class OpenLP1Bible(BibleDB):
except:
return False
#Create the bible language
language = self.parent.mediaItem.languageDialog()
language = self.parent.manager.import_wizard.languageDialog()
if not language:
log.exception(u'Importing books from %s " '\
'failed' % self.filename)

View File

@ -62,7 +62,7 @@ class OpenSongBible(BibleDB):
file = open(self.filename, u'r')
opensong = objectify.parse(file)
bible = opensong.getroot()
language = self.parent.mediaItem.languageDialog()
language = self.parent.manager.import_wizard.languageDialog()
if not language:
log.exception(u'Importing books from %s " '\
'failed' % self.filename)

View File

@ -107,7 +107,7 @@ class OSISBible(BibleDB):
if detect_file:
detect_file.close()
# Set meta language_id
language = self.parent.mediaItem.languageDialog()
language = self.parent.manager.import_wizard.languageDialog()
if not language:
log.exception(u'Importing books from %s " '\
'failed' % self.filename)