forked from openlp/openlp
Fix Bible import bugs for duplicate bibles
Fix Bibles refresh errors on nw bible creation Finish Topic / Author and Songbook code for now
This commit is contained in:
parent
11a9d28bed
commit
2c5e701e10
@ -23,16 +23,13 @@ import sys
|
|||||||
import time
|
import time
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from openlp.core.resources import *
|
|
||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
from PyQt4.QtGui import QDialog
|
|
||||||
|
|
||||||
from bibleimportdialog import Ui_BibleImportDialog
|
from bibleimportdialog import Ui_BibleImportDialog
|
||||||
from openlp.core.lib import Receiver
|
from openlp.core.lib import Receiver, translate
|
||||||
|
|
||||||
|
|
||||||
class BibleImportForm(QDialog, Ui_BibleImportDialog):
|
class BibleImportForm(QtGui.QDialog, Ui_BibleImportDialog):
|
||||||
global log
|
global log
|
||||||
log=logging.getLogger("BibleImportForm")
|
log=logging.getLogger("BibleImportForm")
|
||||||
log.info("BibleImportForm loaded")
|
log.info("BibleImportForm loaded")
|
||||||
@ -43,7 +40,7 @@ class BibleImportForm(QDialog, Ui_BibleImportDialog):
|
|||||||
"""
|
"""
|
||||||
Constructor
|
Constructor
|
||||||
"""
|
"""
|
||||||
QDialog.__init__(self, parent)
|
QtGui.QDialog.__init__(self, parent)
|
||||||
self.setupUi(self)
|
self.setupUi(self)
|
||||||
self.biblemanager = biblemanager
|
self.biblemanager = biblemanager
|
||||||
self.config = config
|
self.config = config
|
||||||
@ -110,7 +107,8 @@ class BibleImportForm(QDialog, Ui_BibleImportDialog):
|
|||||||
if len(self.OSISLocationEdit.displayText() ) > 0:
|
if len(self.OSISLocationEdit.displayText() ) > 0:
|
||||||
self.setOsis()
|
self.setOsis()
|
||||||
else:
|
else:
|
||||||
if self.bible_type == "OSIS": # Was OSIS and is not any more stops lostFocus running mad
|
# Was OSIS and is not any more stops lostFocus running mad
|
||||||
|
if self.bible_type == "OSIS":
|
||||||
self.bible_type = None
|
self.bible_type = None
|
||||||
self.freeAll()
|
self.freeAll()
|
||||||
|
|
||||||
@ -156,6 +154,10 @@ class BibleImportForm(QDialog, Ui_BibleImportDialog):
|
|||||||
self.ProgressBar.setValue(self.barmax)
|
self.ProgressBar.setValue(self.barmax)
|
||||||
# tell bibleplugin to reload the bibles
|
# tell bibleplugin to reload the bibles
|
||||||
Receiver().send_message("openlpreloadbibles")
|
Receiver().send_message("openlpreloadbibles")
|
||||||
|
message = u'Bible import completered'
|
||||||
|
reply = QtGui.QMessageBox.information(self,
|
||||||
|
translate(u'BibleMediaItem', u'Information'),
|
||||||
|
translate(u'BibleMediaItem', message))
|
||||||
|
|
||||||
def setMax(self, max):
|
def setMax(self, max):
|
||||||
log.debug("set Max %s", max)
|
log.debug("set Max %s", max)
|
||||||
@ -170,19 +172,25 @@ class BibleImportForm(QDialog, Ui_BibleImportDialog):
|
|||||||
def importBible(self):
|
def importBible(self):
|
||||||
log.debug("Import Bible ")
|
log.debug("Import Bible ")
|
||||||
if self.bible_type == "OSIS":
|
if self.bible_type == "OSIS":
|
||||||
self.biblemanager.register_osis_file_bible(str(self.BibleNameEdit.displayText()), self.OSISLocationEdit.displayText())
|
loaded = self.biblemanager.register_osis_file_bible(str(self.BibleNameEdit.displayText()),
|
||||||
|
self.OSISLocationEdit.displayText())
|
||||||
elif self.bible_type == "CSV":
|
elif self.bible_type == "CSV":
|
||||||
self.biblemanager.register_csv_file_bible(str(self.BibleNameEdit.displayText()), self.BooksLocationEdit.displayText(), self.VerseLocationEdit.displayText())
|
loaded = self.biblemanager.register_csv_file_bible(str(self.BibleNameEdit.displayText()),
|
||||||
|
self.BooksLocationEdit.displayText(), self.VerseLocationEdit.displayText())
|
||||||
else:
|
else:
|
||||||
self.setMax(1) # set a value as it will not be needed
|
self.setMax(1) # set a value as it will not be needed
|
||||||
bible = self.bible_versions[str(self.BibleComboBox.currentText())]
|
bible = self.bible_versions[str(self.BibleComboBox.currentText())]
|
||||||
self.biblemanager.register_http_bible(str(self.BibleComboBox.currentText()), \
|
loaded = self.biblemanager.register_http_bible(str(self.BibleComboBox.currentText()), \
|
||||||
str(self.LocationComboBox.currentText()), \
|
str(self.LocationComboBox.currentText()), \
|
||||||
str(bible), \
|
str(bible), \
|
||||||
str(self.AddressEdit.displayText()), \
|
str(self.AddressEdit.displayText()), \
|
||||||
str(self.UsernameEdit .displayText()), \
|
str(self.UsernameEdit .displayText()), \
|
||||||
str(self.PasswordEdit.displayText()))
|
str(self.PasswordEdit.displayText()))
|
||||||
self.biblemanager.save_meta_data(str(self.BibleNameEdit.displayText()), str(self.VersionNameEdit.displayText()), str(self.CopyrightEdit.displayText()), str(self.PermisionEdit.displayText()))
|
if loaded:
|
||||||
|
self.biblemanager.save_meta_data(str(self.BibleNameEdit.displayText()),
|
||||||
|
str(self.VersionNameEdit.displayText()),
|
||||||
|
str(self.CopyrightEdit.displayText()),
|
||||||
|
str(self.PermisionEdit.displayText()))
|
||||||
self.bible_type = None
|
self.bible_type = None
|
||||||
self.freeAll() # free the screen state restrictions
|
self.freeAll() # free the screen state restrictions
|
||||||
self.resetAll() # reset all the screen fields
|
self.resetAll() # reset all the screen fields
|
||||||
@ -191,7 +199,8 @@ class BibleImportForm(QDialog, Ui_BibleImportDialog):
|
|||||||
if len(self.BooksLocationEdit.displayText()) > 0 or len(self.VerseLocationEdit.displayText()) > 0:
|
if len(self.BooksLocationEdit.displayText()) > 0 or len(self.VerseLocationEdit.displayText()) > 0:
|
||||||
self.setCsv()
|
self.setCsv()
|
||||||
else:
|
else:
|
||||||
if self.bible_type == "CSV": # Was CSV and is not any more stops lostFocus running mad
|
# Was CSV and is not any more stops lostFocus running mad
|
||||||
|
if self.bible_type == "CSV":
|
||||||
self.bible_type = None
|
self.bible_type = None
|
||||||
self.freeAll()
|
self.freeAll()
|
||||||
|
|
||||||
@ -199,7 +208,8 @@ class BibleImportForm(QDialog, Ui_BibleImportDialog):
|
|||||||
if self.BibleComboBox.currentIndex() != 0 : # First slot is blank so no bible
|
if self.BibleComboBox.currentIndex() != 0 : # First slot is blank so no bible
|
||||||
self.setHttp()
|
self.setHttp()
|
||||||
else:
|
else:
|
||||||
if self.bible_type == "HTTP": # Was HTTP and is not any more stops lostFocus running mad
|
# Was HTTP and is not any more stops lostFocus running mad
|
||||||
|
if self.bible_type == "HTTP":
|
||||||
self.bible_type = None
|
self.bible_type = None
|
||||||
self.freeAll()
|
self.freeAll()
|
||||||
|
|
||||||
|
@ -101,6 +101,7 @@ class BibleDBImpl(BibleCommon):
|
|||||||
return book
|
return book
|
||||||
|
|
||||||
def save_meta(self, key, value):
|
def save_meta(self, key, value):
|
||||||
|
log.debug( "save_meta %s/%s", key, value)
|
||||||
metadata.bind.echo = False
|
metadata.bind.echo = False
|
||||||
session = self.session()
|
session = self.session()
|
||||||
bmeta= BibleMeta()
|
bmeta= BibleMeta()
|
||||||
|
@ -128,7 +128,10 @@ class BibleManager():
|
|||||||
nbible.save_meta("proxyid", proxyid) # store the proxy userid
|
nbible.save_meta("proxyid", proxyid) # store the proxy userid
|
||||||
if proxypass != None and proxypass != "":
|
if proxypass != None and proxypass != "":
|
||||||
nbible.save_meta("proxypass", proxypass) # store the proxy password
|
nbible.save_meta("proxypass", proxypass) # store the proxy password
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
log.debug( "register_http_file_bible %s not created already exists", biblename)
|
||||||
|
return False
|
||||||
|
|
||||||
def register_csv_file_bible(self, biblename, booksfile, versefile):
|
def register_csv_file_bible(self, biblename, booksfile, versefile):
|
||||||
"""
|
"""
|
||||||
@ -143,6 +146,10 @@ class BibleManager():
|
|||||||
self.bible_db_cache[biblename] = nbible # cache the database for use later
|
self.bible_db_cache[biblename] = nbible # cache the database for use later
|
||||||
bcsv = BibleCSVImpl(nbible) # create the loader and pass in the database
|
bcsv = BibleCSVImpl(nbible) # create the loader and pass in the database
|
||||||
bcsv.load_data(booksfile, versefile, self.dialogobject)
|
bcsv.load_data(booksfile, versefile, self.dialogobject)
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
log.debug( "register_csv_file_bible %s not created already exists", biblename)
|
||||||
|
return False
|
||||||
|
|
||||||
def register_osis_file_bible(self, biblename, osisfile):
|
def register_osis_file_bible(self, biblename, osisfile):
|
||||||
"""
|
"""
|
||||||
@ -157,6 +164,10 @@ class BibleManager():
|
|||||||
self.bible_db_cache[biblename] = nbible # cache the database for use later
|
self.bible_db_cache[biblename] = nbible # cache the database for use later
|
||||||
bcsv = BibleOSISImpl(self.biblePath, nbible) # create the loader and pass in the database
|
bcsv = BibleOSISImpl(self.biblePath, nbible) # create the loader and pass in the database
|
||||||
bcsv.load_data(osisfile, self.dialogobject)
|
bcsv.load_data(osisfile, self.dialogobject)
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
log.debug( "register_OSIS_file_bible %s , %s not created already exists", biblename, osisfile)
|
||||||
|
return False
|
||||||
|
|
||||||
def get_bibles(self, mode="full"):
|
def get_bibles(self, mode="full"):
|
||||||
log.debug("get_bibles")
|
log.debug("get_bibles")
|
||||||
|
@ -283,7 +283,7 @@ class BibleMediaItem(MediaManagerItem):
|
|||||||
self.initialiseBible(bible) # use the first bible as the trigger
|
self.initialiseBible(bible) # use the first bible as the trigger
|
||||||
|
|
||||||
def onAdvancedVersionComboBox(self):
|
def onAdvancedVersionComboBox(self):
|
||||||
self.initialiseBible(str(self.AdvancedVersionComboBox.currentText())) # restet the bible info
|
self.initialiseBible(str(self.AdvancedVersionComboBox.currentText())) # reset the bible info
|
||||||
|
|
||||||
def onAdvancedBookComboBox(self):
|
def onAdvancedBookComboBox(self):
|
||||||
self.initialiseBible(str(self.AdvancedVersionComboBox.currentText())) # reset the bible info
|
self.initialiseBible(str(self.AdvancedVersionComboBox.currentText())) # reset the bible info
|
||||||
@ -291,7 +291,7 @@ class BibleMediaItem(MediaManagerItem):
|
|||||||
def onBibleNewClick(self):
|
def onBibleNewClick(self):
|
||||||
self.bibleimportform = BibleImportForm(self.parent.config, self.parent.biblemanager, self)
|
self.bibleimportform = BibleImportForm(self.parent.config, self.parent.biblemanager, self)
|
||||||
self.bibleimportform.exec_()
|
self.bibleimportform.exec_()
|
||||||
pass
|
self.reloadBibles()
|
||||||
|
|
||||||
def onAdvancedFromVerse(self):
|
def onAdvancedFromVerse(self):
|
||||||
frm = self.AdvancedFromVerse.currentText()
|
frm = self.AdvancedFromVerse.currentText()
|
||||||
@ -417,22 +417,14 @@ class BibleMediaItem(MediaManagerItem):
|
|||||||
|
|
||||||
def initialiseBible(self, bible):
|
def initialiseBible(self, bible):
|
||||||
log.debug(u"initialiseBible %s", bible)
|
log.debug(u"initialiseBible %s", bible)
|
||||||
current_book = str(self.AdvancedBookComboBox.currentText())
|
books = self.parent.biblemanager.get_bible_books(str(bible))
|
||||||
chapter_count = self.parent.biblemanager.get_book_chapter_count(bible,
|
self.AdvancedBookComboBox.clear()
|
||||||
current_book)[0]
|
first = True
|
||||||
log.debug(u'Book change bible %s book %s ChapterCount %s', bible,
|
for book in books:
|
||||||
current_book, chapter_count)
|
self.AdvancedBookComboBox.addItem(book.name)
|
||||||
if chapter_count == None:
|
if first:
|
||||||
# Only change the search details if the book is missing from the new bible
|
first = False
|
||||||
books = self.parent.biblemanager.get_bible_books(str(
|
self.initialiseChapterVerse(bible, book.name)
|
||||||
self.AdvancedVersionComboBox.currentText()))
|
|
||||||
self.AdvancedBookComboBox.clear()
|
|
||||||
first = True
|
|
||||||
for book in books:
|
|
||||||
self.AdvancedBookComboBox.addItem(book.name)
|
|
||||||
if first:
|
|
||||||
first = False
|
|
||||||
self.initialiseChapterVerse(bible, book.name)
|
|
||||||
|
|
||||||
def initialiseChapterVerse(self, bible, book):
|
def initialiseChapterVerse(self, bible, book):
|
||||||
log.debug(u"initialiseChapterVerse %s , %s", bible, book)
|
log.debug(u"initialiseChapterVerse %s , %s", bible, book)
|
||||||
|
@ -55,7 +55,8 @@ class AuthorsForm(QtGui.QDialog, Ui_AuthorsDialog):
|
|||||||
authors = self.songmanager.get_authors()
|
authors = self.songmanager.get_authors()
|
||||||
for author in authors:
|
for author in authors:
|
||||||
self.AuthorListData.addRow(author.id,author.display_name)
|
self.AuthorListData.addRow(author.id,author.display_name)
|
||||||
row_count = self.AuthorListData.rowCount(None)
|
#rowCount is number of rows BUT test should be Zero based
|
||||||
|
row_count = self.AuthorListData.rowCount(None) - 1
|
||||||
if self.currentRow > row_count:
|
if self.currentRow > row_count:
|
||||||
# in case we have delete the last row of the table
|
# in case we have delete the last row of the table
|
||||||
self.currentRow = row_count
|
self.currentRow = row_count
|
||||||
|
@ -55,7 +55,8 @@ class SongBookForm(QtGui.QDialog, Ui_SongBookDialog):
|
|||||||
Books = self.songmanager.get_books()
|
Books = self.songmanager.get_books()
|
||||||
for Book in Books:
|
for Book in Books:
|
||||||
self.BookSongListData.addRow(Book.id,Book.name)
|
self.BookSongListData.addRow(Book.id,Book.name)
|
||||||
row_count = self.BookSongListData.rowCount(None)
|
#rowCount is number of rows BUT test should be Zero based
|
||||||
|
row_count = self.BookSongListData.rowCount(None) - 1
|
||||||
if self.currentRow > row_count:
|
if self.currentRow > row_count:
|
||||||
# in case we have delete the last row of the table
|
# in case we have delete the last row of the table
|
||||||
self.currentRow = row_count
|
self.currentRow = row_count
|
||||||
|
@ -35,7 +35,7 @@ class TopicsForm(QtGui.QDialog, Ui_TopicsDialog):
|
|||||||
self.setupUi(self)
|
self.setupUi(self)
|
||||||
self.songmanager = songmanager
|
self.songmanager = songmanager
|
||||||
self.currentRow = 0
|
self.currentRow = 0
|
||||||
self.songbook = None
|
self.topic = None
|
||||||
|
|
||||||
QtCore.QObject.connect(self.DeleteButton,
|
QtCore.QObject.connect(self.DeleteButton,
|
||||||
QtCore.SIGNAL('pressed()'), self.onDeleteButtonClick)
|
QtCore.SIGNAL('pressed()'), self.onDeleteButtonClick)
|
||||||
@ -52,13 +52,13 @@ class TopicsForm(QtGui.QDialog, Ui_TopicsDialog):
|
|||||||
"""
|
"""
|
||||||
Refresh the screen and rest fields
|
Refresh the screen and rest fields
|
||||||
"""
|
"""
|
||||||
print "topics load form start"
|
|
||||||
self.TopicsListData.resetStore()
|
self.TopicsListData.resetStore()
|
||||||
self.onClearButtonClick() # tidy up screen
|
self.onClearButtonClick() # tidy up screen
|
||||||
Topics = self.songmanager.get_topics()
|
topics = self.songmanager.get_topics()
|
||||||
for Topic in Topics:
|
for topic in topics:
|
||||||
self.TopicsListData.addRow(Topic.id,Topic.name)
|
self.TopicsListData.addRow(topic.id,topic.name)
|
||||||
row_count = self.TopicsListData.rowCount(None)
|
#rowCount is number of rows BUT test should be Zero based
|
||||||
|
row_count = self.TopicsListData.rowCount(None) - 1
|
||||||
if self.currentRow > row_count:
|
if self.currentRow > row_count:
|
||||||
# in case we have delete the last row of the table
|
# in case we have delete the last row of the table
|
||||||
self.currentRow = row_count
|
self.currentRow = row_count
|
||||||
@ -67,14 +67,12 @@ class TopicsForm(QtGui.QDialog, Ui_TopicsDialog):
|
|||||||
self.TopicsListView.selectionModel().setCurrentIndex(row,
|
self.TopicsListView.selectionModel().setCurrentIndex(row,
|
||||||
QtGui.QItemSelectionModel.SelectCurrent)
|
QtGui.QItemSelectionModel.SelectCurrent)
|
||||||
self._validate_form()
|
self._validate_form()
|
||||||
print "topics load form end"
|
|
||||||
|
|
||||||
def onDeleteButtonClick(self):
|
def onDeleteButtonClick(self):
|
||||||
"""
|
"""
|
||||||
Delete the Topic is the Topic is not attached to any songs
|
Delete the Topic is the Topic is not attached to any songs
|
||||||
"""
|
"""
|
||||||
self.songmanager.delete_topic(self.Topic.id)
|
self.songmanager.delete_topic(self.topic.id)
|
||||||
self.onClearButtonClick()
|
|
||||||
self.load_form()
|
self.load_form()
|
||||||
|
|
||||||
def onTopicNameEditLostFocus(self):
|
def onTopicNameEditLostFocus(self):
|
||||||
@ -84,10 +82,10 @@ class TopicsForm(QtGui.QDialog, Ui_TopicsDialog):
|
|||||||
"""
|
"""
|
||||||
Sent New or update details to the database
|
Sent New or update details to the database
|
||||||
"""
|
"""
|
||||||
if self.Topic == None:
|
if self.topic == None:
|
||||||
self.Topic = Topic()
|
self.topic = Topic()
|
||||||
self.Topic.name = unicode(self.TopicNameEdit.displayText())
|
self.topic.name = unicode(self.TopicNameEdit.displayText())
|
||||||
self.songmanager.save_topic(self.Topic)
|
self.songmanager.save_topic(self.topic)
|
||||||
self.onClearButtonClick()
|
self.onClearButtonClick()
|
||||||
self.load_form()
|
self.load_form()
|
||||||
|
|
||||||
@ -99,7 +97,7 @@ class TopicsForm(QtGui.QDialog, Ui_TopicsDialog):
|
|||||||
self.MessageLabel.setText(u'')
|
self.MessageLabel.setText(u'')
|
||||||
self.DeleteButton.setEnabled(False)
|
self.DeleteButton.setEnabled(False)
|
||||||
self.AddUpdateButton.setEnabled(True)
|
self.AddUpdateButton.setEnabled(True)
|
||||||
self.Topic = None
|
self.topic = None
|
||||||
self._validate_form()
|
self._validate_form()
|
||||||
|
|
||||||
def onTopicsListViewItemClicked(self, index):
|
def onTopicsListViewItemClicked(self, index):
|
||||||
@ -109,10 +107,10 @@ class TopicsForm(QtGui.QDialog, Ui_TopicsDialog):
|
|||||||
"""
|
"""
|
||||||
self.currentRow = index.row()
|
self.currentRow = index.row()
|
||||||
id = int(self.TopicsListData.getId(index))
|
id = int(self.TopicsListData.getId(index))
|
||||||
self.Topic = self.songmanager.get_topic(id)
|
self.topic = self.songmanager.get_topic(id)
|
||||||
|
|
||||||
self.TopicNameEdit.setText(self.Topic.name)
|
self.TopicNameEdit.setText(self.topic.name)
|
||||||
if len(self.Topic.songs) > 0:
|
if len(self.topic.songs) > 0:
|
||||||
self.MessageLabel.setText("Topic in use 'Delete' is disabled")
|
self.MessageLabel.setText("Topic in use 'Delete' is disabled")
|
||||||
self.DeleteButton.setEnabled(False)
|
self.DeleteButton.setEnabled(False)
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user