2008-11-29 07:56:21 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
"""
|
|
|
|
Module implementing BibleImportDialog.
|
|
|
|
"""
|
|
|
|
import sys
|
2008-11-29 13:38:11 +00:00
|
|
|
import os, os.path
|
|
|
|
import sys
|
2008-11-30 18:31:43 +00:00
|
|
|
import time
|
|
|
|
|
2008-11-29 13:38:11 +00:00
|
|
|
mypath=os.path.split(os.path.abspath(__file__))[0]
|
|
|
|
sys.path.insert(0,(os.path.join(mypath, '..', '..', '..', '..')))
|
2008-11-29 07:56:21 +00:00
|
|
|
|
|
|
|
from PyQt4 import QtCore, QtGui
|
|
|
|
from PyQt4.QtGui import QDialog
|
|
|
|
from PyQt4.QtCore import pyqtSignature
|
|
|
|
|
|
|
|
from bibleimportdialog import Ui_BibleImportDialog
|
2008-11-30 18:31:43 +00:00
|
|
|
from bibleimportprogressform import BibleImportProgressForm
|
|
|
|
|
2008-12-06 09:33:46 +00:00
|
|
|
from openlp.plugins.bibles.lib.biblemanager import BibleManager
|
2008-11-29 07:56:21 +00:00
|
|
|
|
|
|
|
class BibleImportForm(QDialog, Ui_BibleImportDialog):
|
|
|
|
"""
|
|
|
|
Class documentation goes here.
|
|
|
|
"""
|
|
|
|
def __init__(self, biblemanager = None, parent = None):
|
|
|
|
"""
|
|
|
|
Constructor
|
|
|
|
"""
|
|
|
|
QDialog.__init__(self, parent)
|
|
|
|
self.setupUi(self)
|
2008-12-06 19:34:48 +00:00
|
|
|
self.biblemanager = biblemanager
|
2008-11-30 18:31:43 +00:00
|
|
|
|
2008-11-29 07:56:21 +00:00
|
|
|
|
|
|
|
@pyqtSignature("")
|
|
|
|
def on_VersesFileButton_clicked(self):
|
|
|
|
filename = QtGui.QFileDialog.getOpenFileName(self, 'Open file','/home')
|
|
|
|
self.VerseLocationEdit.setText(filename)
|
|
|
|
|
|
|
|
@pyqtSignature("")
|
|
|
|
def on_BooksFileButton_clicked(self):
|
|
|
|
filename = QtGui.QFileDialog.getOpenFileName(self, 'Open file','/home')
|
|
|
|
self.BooksLocationEdit.setText(filename)
|
|
|
|
|
|
|
|
@pyqtSignature("")
|
|
|
|
def on_OsisFileButton_clicked(self):
|
|
|
|
filename = QtGui.QFileDialog.getOpenFileName(self, 'Open file','/home')
|
|
|
|
self.OSISLocationEdit.setText(filename)
|
2008-12-13 10:46:07 +00:00
|
|
|
|
2008-11-30 18:31:43 +00:00
|
|
|
def on_OSISLocationEdit_lostFocus(self):
|
2008-12-13 10:46:07 +00:00
|
|
|
if len(self.OSISLocationEdit.displayText() ) > 1:
|
|
|
|
self.BooksLocationEdit.setReadOnly(True)
|
|
|
|
self.VerseLocationEdit.setReadOnly(True)
|
|
|
|
else:
|
|
|
|
self.BooksLocationEdit.setReadOnly(False)
|
|
|
|
self.VerseLocationEdit.setReadOnly(False)
|
2008-11-30 18:31:43 +00:00
|
|
|
self.validate()
|
2008-12-13 10:46:07 +00:00
|
|
|
|
2008-11-30 18:31:43 +00:00
|
|
|
def on_BooksLocationEdit_lostFocus(self):
|
|
|
|
self.validate()
|
|
|
|
def on_CopyrightEdit_lostFocus(self):
|
|
|
|
self.validate()
|
|
|
|
def on_VersionNameEdit_lostFocus(self):
|
|
|
|
self.validate()
|
|
|
|
def on_PermisionEdit_lostFocus(self):
|
|
|
|
self.validate()
|
|
|
|
def on_BibleNameEdit_lostFocus(self):
|
|
|
|
self.validate()
|
|
|
|
def on_BibleImportButtonBox_clicked(self,button):
|
|
|
|
print button.text()
|
|
|
|
if button.text() == "Save":
|
2008-12-06 19:34:48 +00:00
|
|
|
#bipf = BibleImportProgressForm()
|
|
|
|
#bipf.show()
|
2008-12-06 07:47:01 +00:00
|
|
|
if self.biblemanager != None:
|
|
|
|
self.biblemanager.processDialog(bipf)
|
|
|
|
self.biblemanager.registerOSISFileBible(str(self.BibleNameEdit.displayText()), self.OSISLocationEdit.displayText())
|
|
|
|
elif button.text() == "Cancel":
|
|
|
|
self.close()
|
2008-11-30 18:31:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def validate(self):
|
2008-12-13 10:46:07 +00:00
|
|
|
print "validate"
|
2008-11-30 18:31:43 +00:00
|
|
|
valid = False
|
|
|
|
validcount = 0
|
|
|
|
if len(self.BibleNameEdit.displayText()) > 0:
|
|
|
|
validcount += 1
|
|
|
|
if len(self.OSISLocationEdit.displayText()) > 0:
|
|
|
|
validcount += 1
|
|
|
|
if len(self.BooksLocationEdit.displayText()) > 0:
|
|
|
|
validcount += 1
|
|
|
|
if len(self.VersionNameEdit.displayText()) > 0 and len(self.CopyrightEdit.displayText()) > 0 and len(self.PermisionEdit.displayText()) > 0:
|
|
|
|
valid = True
|
2008-12-06 07:47:01 +00:00
|
|
|
# if validcount == 2 and valid:
|
|
|
|
# self.BibleImportButtonBox.addButton(self.savebutton, QtGui.QDialogButtonBox.AcceptRole) # hide the save button tile screen is valid
|
|
|
|
# else:
|
|
|
|
# self.BibleImportButtonBox.removeButton(self.savebutton) # hide the save button tile screen is valid
|
2008-11-30 18:31:43 +00:00
|
|
|
|
2008-11-29 07:56:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
class runner(QtGui.QApplication):
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
values = ["Genesis","Matthew","Revelation"]
|
2008-12-06 07:47:01 +00:00
|
|
|
self.bm = BibleManager("/home/timali/.openlp")
|
|
|
|
self.bim = BibleImportForm()
|
2008-11-29 07:56:21 +00:00
|
|
|
self.bim.show()
|
|
|
|
self.processEvents()
|
|
|
|
sys.exit(app.exec_())
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
app = runner(sys.argv)
|
|
|
|
app.run()
|