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 logging
|
||||
|
||||
from openlp.core.resources import *
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
from PyQt4.QtGui import QDialog
|
||||
|
||||
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
|
||||
log=logging.getLogger("BibleImportForm")
|
||||
log.info("BibleImportForm loaded")
|
||||
@ -43,7 +40,7 @@ class BibleImportForm(QDialog, Ui_BibleImportDialog):
|
||||
"""
|
||||
Constructor
|
||||
"""
|
||||
QDialog.__init__(self, parent)
|
||||
QtGui.QDialog.__init__(self, parent)
|
||||
self.setupUi(self)
|
||||
self.biblemanager = biblemanager
|
||||
self.config = config
|
||||
@ -110,7 +107,8 @@ class BibleImportForm(QDialog, Ui_BibleImportDialog):
|
||||
if len(self.OSISLocationEdit.displayText() ) > 0:
|
||||
self.setOsis()
|
||||
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.freeAll()
|
||||
|
||||
@ -156,6 +154,10 @@ class BibleImportForm(QDialog, Ui_BibleImportDialog):
|
||||
self.ProgressBar.setValue(self.barmax)
|
||||
# tell bibleplugin to reload the bibles
|
||||
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):
|
||||
log.debug("set Max %s", max)
|
||||
@ -170,19 +172,25 @@ class BibleImportForm(QDialog, Ui_BibleImportDialog):
|
||||
def importBible(self):
|
||||
log.debug("Import Bible ")
|
||||
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":
|
||||
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:
|
||||
self.setMax(1) # set a value as it will not be needed
|
||||
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(bible), \
|
||||
str(self.AddressEdit.displayText()), \
|
||||
str(self.UsernameEdit .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.freeAll() # free the screen state restrictions
|
||||
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:
|
||||
self.setCsv()
|
||||
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.freeAll()
|
||||
|
||||
@ -199,7 +208,8 @@ class BibleImportForm(QDialog, Ui_BibleImportDialog):
|
||||
if self.BibleComboBox.currentIndex() != 0 : # First slot is blank so no bible
|
||||
self.setHttp()
|
||||
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.freeAll()
|
||||
|
||||
|
@ -101,6 +101,7 @@ class BibleDBImpl(BibleCommon):
|
||||
return book
|
||||
|
||||
def save_meta(self, key, value):
|
||||
log.debug( "save_meta %s/%s", key, value)
|
||||
metadata.bind.echo = False
|
||||
session = self.session()
|
||||
bmeta= BibleMeta()
|
||||
|
@ -128,7 +128,10 @@ class BibleManager():
|
||||
nbible.save_meta("proxyid", proxyid) # store the proxy userid
|
||||
if proxypass != None and proxypass != "":
|
||||
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):
|
||||
"""
|
||||
@ -143,6 +146,10 @@ class BibleManager():
|
||||
self.bible_db_cache[biblename] = nbible # cache the database for use later
|
||||
bcsv = BibleCSVImpl(nbible) # create the loader and pass in the database
|
||||
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):
|
||||
"""
|
||||
@ -157,6 +164,10 @@ class BibleManager():
|
||||
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.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"):
|
||||
log.debug("get_bibles")
|
||||
|
@ -283,7 +283,7 @@ class BibleMediaItem(MediaManagerItem):
|
||||
self.initialiseBible(bible) # use the first bible as the trigger
|
||||
|
||||
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):
|
||||
self.initialiseBible(str(self.AdvancedVersionComboBox.currentText())) # reset the bible info
|
||||
@ -291,7 +291,7 @@ class BibleMediaItem(MediaManagerItem):
|
||||
def onBibleNewClick(self):
|
||||
self.bibleimportform = BibleImportForm(self.parent.config, self.parent.biblemanager, self)
|
||||
self.bibleimportform.exec_()
|
||||
pass
|
||||
self.reloadBibles()
|
||||
|
||||
def onAdvancedFromVerse(self):
|
||||
frm = self.AdvancedFromVerse.currentText()
|
||||
@ -417,22 +417,14 @@ class BibleMediaItem(MediaManagerItem):
|
||||
|
||||
def initialiseBible(self, bible):
|
||||
log.debug(u"initialiseBible %s", bible)
|
||||
current_book = str(self.AdvancedBookComboBox.currentText())
|
||||
chapter_count = self.parent.biblemanager.get_book_chapter_count(bible,
|
||||
current_book)[0]
|
||||
log.debug(u'Book change bible %s book %s ChapterCount %s', bible,
|
||||
current_book, chapter_count)
|
||||
if chapter_count == None:
|
||||
# Only change the search details if the book is missing from the new bible
|
||||
books = self.parent.biblemanager.get_bible_books(str(
|
||||
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)
|
||||
books = self.parent.biblemanager.get_bible_books(str(bible))
|
||||
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):
|
||||
log.debug(u"initialiseChapterVerse %s , %s", bible, book)
|
||||
|
@ -55,7 +55,8 @@ class AuthorsForm(QtGui.QDialog, Ui_AuthorsDialog):
|
||||
authors = self.songmanager.get_authors()
|
||||
for author in authors:
|
||||
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:
|
||||
# in case we have delete the last row of the table
|
||||
self.currentRow = row_count
|
||||
|
@ -55,7 +55,8 @@ class SongBookForm(QtGui.QDialog, Ui_SongBookDialog):
|
||||
Books = self.songmanager.get_books()
|
||||
for Book in Books:
|
||||
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:
|
||||
# in case we have delete the last row of the table
|
||||
self.currentRow = row_count
|
||||
|
@ -35,7 +35,7 @@ class TopicsForm(QtGui.QDialog, Ui_TopicsDialog):
|
||||
self.setupUi(self)
|
||||
self.songmanager = songmanager
|
||||
self.currentRow = 0
|
||||
self.songbook = None
|
||||
self.topic = None
|
||||
|
||||
QtCore.QObject.connect(self.DeleteButton,
|
||||
QtCore.SIGNAL('pressed()'), self.onDeleteButtonClick)
|
||||
@ -52,13 +52,13 @@ class TopicsForm(QtGui.QDialog, Ui_TopicsDialog):
|
||||
"""
|
||||
Refresh the screen and rest fields
|
||||
"""
|
||||
print "topics load form start"
|
||||
self.TopicsListData.resetStore()
|
||||
self.onClearButtonClick() # tidy up screen
|
||||
Topics = self.songmanager.get_topics()
|
||||
for Topic in Topics:
|
||||
self.TopicsListData.addRow(Topic.id,Topic.name)
|
||||
row_count = self.TopicsListData.rowCount(None)
|
||||
topics = self.songmanager.get_topics()
|
||||
for topic in topics:
|
||||
self.TopicsListData.addRow(topic.id,topic.name)
|
||||
#rowCount is number of rows BUT test should be Zero based
|
||||
row_count = self.TopicsListData.rowCount(None) - 1
|
||||
if self.currentRow > row_count:
|
||||
# in case we have delete the last row of the table
|
||||
self.currentRow = row_count
|
||||
@ -67,14 +67,12 @@ class TopicsForm(QtGui.QDialog, Ui_TopicsDialog):
|
||||
self.TopicsListView.selectionModel().setCurrentIndex(row,
|
||||
QtGui.QItemSelectionModel.SelectCurrent)
|
||||
self._validate_form()
|
||||
print "topics load form end"
|
||||
|
||||
def onDeleteButtonClick(self):
|
||||
"""
|
||||
Delete the Topic is the Topic is not attached to any songs
|
||||
"""
|
||||
self.songmanager.delete_topic(self.Topic.id)
|
||||
self.onClearButtonClick()
|
||||
self.songmanager.delete_topic(self.topic.id)
|
||||
self.load_form()
|
||||
|
||||
def onTopicNameEditLostFocus(self):
|
||||
@ -84,10 +82,10 @@ class TopicsForm(QtGui.QDialog, Ui_TopicsDialog):
|
||||
"""
|
||||
Sent New or update details to the database
|
||||
"""
|
||||
if self.Topic == None:
|
||||
self.Topic = Topic()
|
||||
self.Topic.name = unicode(self.TopicNameEdit.displayText())
|
||||
self.songmanager.save_topic(self.Topic)
|
||||
if self.topic == None:
|
||||
self.topic = Topic()
|
||||
self.topic.name = unicode(self.TopicNameEdit.displayText())
|
||||
self.songmanager.save_topic(self.topic)
|
||||
self.onClearButtonClick()
|
||||
self.load_form()
|
||||
|
||||
@ -99,7 +97,7 @@ class TopicsForm(QtGui.QDialog, Ui_TopicsDialog):
|
||||
self.MessageLabel.setText(u'')
|
||||
self.DeleteButton.setEnabled(False)
|
||||
self.AddUpdateButton.setEnabled(True)
|
||||
self.Topic = None
|
||||
self.topic = None
|
||||
self._validate_form()
|
||||
|
||||
def onTopicsListViewItemClicked(self, index):
|
||||
@ -109,10 +107,10 @@ class TopicsForm(QtGui.QDialog, Ui_TopicsDialog):
|
||||
"""
|
||||
self.currentRow = index.row()
|
||||
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)
|
||||
if len(self.Topic.songs) > 0:
|
||||
self.TopicNameEdit.setText(self.topic.name)
|
||||
if len(self.topic.songs) > 0:
|
||||
self.MessageLabel.setText("Topic in use 'Delete' is disabled")
|
||||
self.DeleteButton.setEnabled(False)
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user