More fixes and UI updates

bzr-revno: 306
This commit is contained in:
Tim Bentley 2009-02-11 18:33:54 +00:00
parent 55059c5d52
commit fcc9b37df6
7 changed files with 81 additions and 57 deletions

View File

@ -27,8 +27,8 @@ class EventReceiver(QObject):
def __init__(self):
QObject.__init__(self)
def send_repaint(self):
self.emit(SIGNAL("openlprepaint"), None)
def send_message(self, event, msg=None):
self.emit(SIGNAL(event), msg)
def received(self, msg=None):
print msg
@ -40,17 +40,15 @@ class Receiver():
As there is only one instance of it in the systems the QT signal/slot architecture
can send messages across the system
Send message
receiver = Receiver()
receiver.send_repaint()
Receiver().send_message("messageid",data)
Receive Message
self.receiver = Receiver()
QtCore.QObject.connect(self.receiver.get_receiver(),QtCore.SIGNAL("openlprepaint"),<<ACTION>>)
QtCore.QObject.connect(Receiver().get_receiver(),QtCore.SIGNAL("openlprepaint"),<<ACTION>>)
"""
eventreceiver=EventReceiver()
@staticmethod
def send_repaint():
Receiver.eventreceiver.send_repaint()
def send_message(event, msg=None):
Receiver.eventreceiver.send_message(event, msg)
@staticmethod
def receive():
Receiver.eventreceiver.receive()

View File

@ -40,8 +40,7 @@ class MainWindow(object):
pluginpath = os.path.abspath(os.path.join(pluginpath, '..', '..','plugins'))
self.plugin_manager = PluginManager(pluginpath)
self.setupUi()
self.receiver = Receiver()
QtCore.QObject.connect(self.receiver.get_receiver(),QtCore.SIGNAL("openlprepaint"),self.repaint)
QtCore.QObject.connect(Receiver().get_receiver(),QtCore.SIGNAL("openlprepaint"),self.repaint)
def repaint(self):
self.main_window.repaint()

View File

@ -119,9 +119,13 @@ class BiblePlugin(Plugin, PluginUtils):
self.QuickSearchButton.setObjectName('QuickSearchButton')
self.QuickSearchButton.setText('Search')
self.QuickLayout.addWidget(self.QuickSearchButton, 3, 2, 1, 1)
self.SearchTabWidget.addTab(self.QuickTab, 'Quick Search')
self.ClearQuickSearchComboBox = QtGui.QComboBox(self.QuickTab)
self.ClearQuickSearchComboBox.setObjectName('ClearQuickSearchComboBox')
self.QuickLayout.addWidget(self.ClearQuickSearchComboBox, 3, 0, 1, 1)
QuickSpacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
self.QuickLayout.addItem(QuickSpacerItem, 4, 2, 1, 1)
self.SearchTabWidget.addTab(self.QuickTab, 'Quick Search')
# Add the Advanced Search tab
self.AdvancedTab = QtGui.QWidget()
self.AdvancedTab.setObjectName('AdvancedTab')
@ -172,6 +176,9 @@ class BiblePlugin(Plugin, PluginUtils):
self.AdvancedToVerse.setObjectName('AdvancedToVerse')
self.AdvancedLayout.addWidget(self.AdvancedToVerse, 4, 3, 1, 1)
self.ClearAdvancedSearchComboBox = QtGui.QComboBox(self.QuickTab)
self.ClearAdvancedSearchComboBox.setObjectName('ClearAdvancedSearchComboBox')
self.AdvancedLayout.addWidget(self.ClearAdvancedSearchComboBox, 5, 0, 1, 1)
self.AdvancedSearchButton = QtGui.QPushButton(self.AdvancedTab)
self.AdvancedSearchButton.setObjectName('AdvancedSearchButton')
self.AdvancedSearchButton.setText('Search')
@ -266,8 +273,12 @@ class BiblePlugin(Plugin, PluginUtils):
self.QuickVersionComboBox.clear()
self.AdvancedVersionComboBox.clear()
bibles = self.biblemanager.get_bibles("full")
self.QuickSearchComboBox.addItem("Text Search")
self.QuickSearchComboBox.addItem("Verse Search")
self.QuickSearchComboBox.addItem("Text Search")
self.ClearQuickSearchComboBox.addItem("Clear Results")
self.ClearQuickSearchComboBox.addItem("Keep Results")
self.ClearAdvancedSearchComboBox.addItem("Clear Results")
self.ClearAdvancedSearchComboBox.addItem("Keep Results")
for b in bibles: # load bibles into the combo boxes
self.QuickVersionComboBox.addItem(b)

View File

@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'bibleimportdialog.ui'
#
# Created: Sat Jan 24 07:46:38 2009
# Created: Wed Feb 11 16:48:24 2009
# by: PyQt4 UI code generator 4.4.4
#
# WARNING! All changes made in this file will be lost!
@ -16,11 +16,6 @@ class Ui_BibleImportDialog(object):
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(":/icon/openlp.org-icon-32.bmp"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
BibleImportDialog.setWindowIcon(icon)
self.BibleImportButtonBox = QtGui.QDialogButtonBox(BibleImportDialog)
self.BibleImportButtonBox.setGeometry(QtCore.QRect(10, 690, 481, 33))
self.BibleImportButtonBox.setOrientation(QtCore.Qt.Horizontal)
self.BibleImportButtonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Save)
self.BibleImportButtonBox.setObjectName("BibleImportButtonBox")
self.ImportToolBox = QtGui.QToolBox(BibleImportDialog)
self.ImportToolBox.setGeometry(QtCore.QRect(10, 0, 471, 431))
self.ImportToolBox.setObjectName("ImportToolBox")
@ -191,6 +186,17 @@ class Ui_BibleImportDialog(object):
self.ProgressBar.setInvertedAppearance(False)
self.ProgressBar.setObjectName("ProgressBar")
self.gridLayout_3.addWidget(self.ProgressBar, 0, 0, 1, 1)
self.widget = QtGui.QWidget(BibleImportDialog)
self.widget.setGeometry(QtCore.QRect(320, 680, 170, 28))
self.widget.setObjectName("widget")
self.horizontalLayout = QtGui.QHBoxLayout(self.widget)
self.horizontalLayout.setObjectName("horizontalLayout")
self.ImportButton = QtGui.QPushButton(self.widget)
self.ImportButton.setObjectName("ImportButton")
self.horizontalLayout.addWidget(self.ImportButton)
self.CancelButton = QtGui.QPushButton(self.widget)
self.CancelButton.setObjectName("CancelButton")
self.horizontalLayout.addWidget(self.CancelButton)
self.retranslateUi(BibleImportDialog)
self.ImportToolBox.setCurrentIndex(1)
@ -210,7 +216,6 @@ class Ui_BibleImportDialog(object):
BibleImportDialog.setTabOrder(self.PasswordEdit, self.VersionNameEdit)
BibleImportDialog.setTabOrder(self.VersionNameEdit, self.CopyrightEdit)
BibleImportDialog.setTabOrder(self.CopyrightEdit, self.PermisionEdit)
BibleImportDialog.setTabOrder(self.PermisionEdit, self.BibleImportButtonBox)
def retranslateUi(self, BibleImportDialog):
BibleImportDialog.setWindowTitle(QtGui.QApplication.translate("BibleImportDialog", "Bible Registration", None, QtGui.QApplication.UnicodeUTF8))
@ -240,3 +245,6 @@ class Ui_BibleImportDialog(object):
self.PermisionLabel.setText(QtGui.QApplication.translate("BibleImportDialog", "Permission:", None, QtGui.QApplication.UnicodeUTF8))
self.ProgressGroupBox.setTitle(QtGui.QApplication.translate("BibleImportDialog", "Import Progress", None, QtGui.QApplication.UnicodeUTF8))
self.ProgressBar.setFormat(QtGui.QApplication.translate("BibleImportDialog", "%p", None, QtGui.QApplication.UnicodeUTF8))
self.ImportButton.setText(QtGui.QApplication.translate("BibleImportDialog", "Import", None, QtGui.QApplication.UnicodeUTF8))
self.CancelButton.setText(QtGui.QApplication.translate("BibleImportDialog", "Cancel", None, QtGui.QApplication.UnicodeUTF8))

View File

@ -37,13 +37,12 @@ class BibleImportForm(QDialog, Ui_BibleImportDialog, PluginUtils):
self.bibleplugin = bibleplugin
self.bibletype = None
self.barmax = 0
self.receiver = Receiver()
QtCore.QObject.connect(self.LocationComboBox, QtCore.SIGNAL("activated(int)"), self.onLocationComboBox)
QtCore.QObject.connect(self.TypeComboBox, QtCore.SIGNAL("activated(int)"), self.onTypeComboBox)
QtCore.QObject.connect(self.BibleComboBox, QtCore.SIGNAL("activated(int)"), self.onBibleComboBox)
QtCore.QObject.connect(self.ProgressBar, QtCore.SIGNAL("valueChanged(int)"), self.on_ProgressBar_changed)
QtCore.QObject.connect(self.receiver.get_receiver(),QtCore.SIGNAL("openlprepaint"),self.on_ProgressBar_changed)
QtCore.QObject.connect(Receiver().get_receiver(),QtCore.SIGNAL("openlprepaint"),self.on_ProgressBar_changed)
def on_ProgressBar_changed(self):
self.repaint()
@ -122,9 +121,12 @@ class BibleImportForm(QDialog, Ui_BibleImportDialog, PluginUtils):
def on_BibleNameEdit_lostFocus(self):
pass
def on_BibleImportButtonBox_clicked(self,button):
log.debug("BibleImportButtonBox %s , %s", button.text() , self.bibletype)
if button.text() == "Save":
@pyqtSignature("")
def on_CancelButton_clicked(self):
self.close()
@pyqtSignature("")
def on_ImportButton_clicked(self):
if self.biblemanager != None:
if not self.bibletype == None or len(self.BibleNameEdit.displayText()) > 0:
self.MessageLabel.setText("Import Started")
@ -136,8 +138,6 @@ class BibleImportForm(QDialog, Ui_BibleImportDialog, PluginUtils):
self.MessageLabel.setText("Import Complete")
self.ProgressBar.setValue(self.barmax)
self.bibleplugin.reload_bibles() # Update form as we have a new bible
elif button.text() == "Cancel":
self.close()
def setMax(self, max):
log.debug("set Max %s", max)

View File

@ -28,7 +28,6 @@ class BibleOSISImpl():
self.booksOfBible = {} # books of the bible linked to bibleid {osis , name}
self.abbrevOfBible = {} # books of the bible linked to bibleid {osis ,Abbrev }
fbibles=open(biblepath+"/osisbooks_en.txt", 'r')
self.receiver = Receiver()
for line in fbibles:
p = line.split(",")
self.booksOfBible[p[0]] = p[1].replace('\n', '')
@ -85,12 +84,12 @@ class BibleOSISImpl():
book_ptr = p[0]
book = self.bibledb.create_book(self.booksOfBible[p[0]] , self.abbrevOfBible[p[0]], testament)
dialogobject.incrementBar(self.booksOfBible[p[0]] )
self.receiver.send_repaint() # send repaint message to dialog as book changed
Receiver().send_message("openlprepaint") # send repaint message to dialog
count = 0
self.bibledb.add_verse(book.id, p[1], p[2], t)
count += 1
if count % 100 == 0: #Every x verses repaint the screen
self.receiver.send_repaint() # send repaint message to dialog
Receiver().send_message("openlprepaint") # send repaint message to dialog
count = 0

View File

@ -17,22 +17,6 @@
<iconset resource="../images/openlp-2.qrc">
<normaloff>:/icon/openlp.org-icon-32.bmp</normaloff>:/icon/openlp.org-icon-32.bmp</iconset>
</property>
<widget class="QDialogButtonBox" name="BibleImportButtonBox">
<property name="geometry">
<rect>
<x>10</x>
<y>690</y>
<width>481</width>
<height>33</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Save</set>
</property>
</widget>
<widget class="QToolBox" name="ImportToolBox">
<property name="geometry">
<rect>
@ -458,6 +442,32 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="">
<property name="geometry">
<rect>
<x>320</x>
<y>680</y>
<width>170</width>
<height>28</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="ImportButton">
<property name="text">
<string>Import</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="CancelButton">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
<tabstops>
<tabstop>BibleNameEdit</tabstop>
@ -476,7 +486,6 @@
<tabstop>VersionNameEdit</tabstop>
<tabstop>CopyrightEdit</tabstop>
<tabstop>PermisionEdit</tabstop>
<tabstop>BibleImportButtonBox</tabstop>
</tabstops>
<resources>
<include location="../images/openlp-2.qrc"/>