forked from openlp/openlp
Added the Bible Media Item, moved all the media manager code out to the bible media item.
bzr-revno: 356
This commit is contained in:
parent
fa1f2a8ec3
commit
b2c51566b4
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE UserProject SYSTEM "UserProject-4.0.dtd">
|
||||
<!-- eric4 user project file for project openlp.org 2.0 -->
|
||||
<!-- Saved: 2009-03-01, 16:36:06 -->
|
||||
<!-- Saved: 2009-03-02, 23:55:18 -->
|
||||
<!-- Copyright (C) 2009 Raoul Snyman, raoulsnyman@openlp.org -->
|
||||
<UserProject version="4.0">
|
||||
</UserProject>
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE Tasks SYSTEM "Tasks-4.2.dtd">
|
||||
<!-- eric4 tasks file for project openlp.org 2.0 -->
|
||||
<!-- Saved: 2009-03-01, 16:36:15 -->
|
||||
<!-- Saved: 2009-03-02, 23:55:26 -->
|
||||
<Tasks version="4.2">
|
||||
<Task priority="1" completed="False" bugfix="False">
|
||||
<Summary>TODO: what is the tags for bridge, pre-chorus?</Summary>
|
||||
|
@ -1,9 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE Project SYSTEM "Project-4.4.dtd">
|
||||
<!DOCTYPE Project SYSTEM "Project-4.6.dtd">
|
||||
<!-- eric4 project file for project openlp.org 2.0 -->
|
||||
<!-- Saved: 2009-03-01, 01:29:05 -->
|
||||
<!-- Saved: 2009-03-02, 23:55:18 -->
|
||||
<!-- Copyright (C) 2009 Raoul Snyman, raoulsnyman@openlp.org -->
|
||||
<Project version="4.4">
|
||||
<Project version="4.6">
|
||||
<Language>en</Language>
|
||||
<ProgLanguage mixed="0">Python</ProgLanguage>
|
||||
<ProjectType>Qt4</ProjectType>
|
||||
<Description></Description>
|
||||
@ -118,13 +119,10 @@
|
||||
<Source>openlp/core/ui/slidecontroller.py</Source>
|
||||
<Source>openlp/core/lib/eventreceiver.py</Source>
|
||||
<Source>openlp/core/lib/imageserviceitem.py</Source>
|
||||
<Source>openlp/plugins/bibles/forms/bibleeditdialog.py</Source>
|
||||
<Source>resources/forms/Ui_editsongdialog.py</Source>
|
||||
<Source>openlp/core/ui/servicemanager.py</Source>
|
||||
<Source>openlp/core/lib/toolbar.py</Source>
|
||||
<Source>resources/forms/bibleimportdialog.py</Source>
|
||||
<Source>openlp/core/ui/settingsform.py</Source>
|
||||
<Source>openlp/core/ui/generalform.py</Source>
|
||||
<Source>openlp/core/ui/generaltab.py</Source>
|
||||
<Source>openlp/core/ui/themestab.py</Source>
|
||||
<Source>openlp/core/ui/alertstab.py</Source>
|
||||
@ -133,6 +131,9 @@
|
||||
<Source>openlp/core/lib/settingstab.py</Source>
|
||||
<Source>openlp/plugins/bibles/lib/biblestab.py</Source>
|
||||
<Source>openlp/plugins/songs/lib/songstab.py</Source>
|
||||
<Source>openlp/plugins/videos/lib/__init__.py</Source>
|
||||
<Source>openlp/plugins/videos/lib/videotab.py</Source>
|
||||
<Source>openlp/plugins/bibles/lib/biblemediaitem.py</Source>
|
||||
</Sources>
|
||||
<Forms>
|
||||
<Form>resources/forms/openlpexportform.ui</Form>
|
||||
@ -151,8 +152,6 @@
|
||||
<Form>resources/forms/songbookdialog.ui</Form>
|
||||
<Form>resources/forms/topicsdialog.ui</Form>
|
||||
<Form>resources/forms/editsongdialog.ui</Form>
|
||||
<Form>openlp/plugins/bibles/forms/bibleeditdialog.ui</Form>
|
||||
<Form>resources/forms/settings2.ui</Form>
|
||||
</Forms>
|
||||
<Translations>
|
||||
</Translations>
|
||||
@ -284,9 +283,11 @@
|
||||
<FiletypeAssociations>
|
||||
<FiletypeAssociation pattern="*.ui" type="FORMS" />
|
||||
<FiletypeAssociation pattern="*.idl" type="INTERFACES" />
|
||||
<FiletypeAssociation pattern="*.qm" type="TRANSLATIONS" />
|
||||
<FiletypeAssociation pattern="*.ptl" type="SOURCES" />
|
||||
<FiletypeAssociation pattern="*.pyw" type="SOURCES" />
|
||||
<FiletypeAssociation pattern="*.ui.h" type="FORMS" />
|
||||
<FiletypeAssociation pattern="*.ts" type="TRANSLATIONS" />
|
||||
<FiletypeAssociation pattern="*.py" type="SOURCES" />
|
||||
<FiletypeAssociation pattern="*.qrc" type="RESOURCES" />
|
||||
</FiletypeAssociations>
|
||||
|
@ -45,7 +45,19 @@ class MediaManagerItem(QtGui.QWidget):
|
||||
self.PageLayout = QtGui.QVBoxLayout(self)
|
||||
self.PageLayout.setSpacing(0)
|
||||
self.PageLayout.setMargin(0)
|
||||
|
||||
self.setupUi()
|
||||
self.retranslateUi()
|
||||
self.initialise()
|
||||
|
||||
def setupUi(self):
|
||||
pass
|
||||
|
||||
def retranslateUi(self):
|
||||
pass
|
||||
|
||||
def initialise(self):
|
||||
pass
|
||||
|
||||
def addToolbar(self):
|
||||
"""
|
||||
A method to help developers easily add a toolbar to the media manager
|
||||
@ -68,3 +80,29 @@ class MediaManagerItem(QtGui.QWidget):
|
||||
A very simple method to add a separator to the toolbar.
|
||||
"""
|
||||
self.Toolbar.addSeparator()
|
||||
|
||||
def contextMenuSeparator(self, base):
|
||||
action = QtGui.QAction("", base)
|
||||
action.setSeparator(True)
|
||||
return action
|
||||
|
||||
def contextMenuAction(self, base, icon, text, slot):
|
||||
"""
|
||||
Utility method to help build context menus for plugins
|
||||
"""
|
||||
if type(icon) is QtGui.QIcon:
|
||||
ButtonIcon = icon
|
||||
elif type(icon) is types.StringType:
|
||||
ButtonIcon = QtGui.QIcon()
|
||||
if icon.startswith(':/'):
|
||||
ButtonIcon.addPixmap(QtGui.QPixmap(icon), QtGui.QIcon.Normal,
|
||||
QtGui.QIcon.Off)
|
||||
else:
|
||||
ButtonIcon.addPixmap(QtGui.QPixmap.fromImage(QtGui.QImage(icon)),
|
||||
QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||
|
||||
action = QtGui.QAction(text, base)
|
||||
action .setIcon(ButtonIcon)
|
||||
QtCore.QObject.connect(action, QtCore.SIGNAL("triggered()"), slot)
|
||||
return action
|
||||
|
||||
|
@ -29,11 +29,11 @@ class PluginUtils(object):
|
||||
action = QtGui.QAction("", base)
|
||||
action.setSeparator(True)
|
||||
return action
|
||||
|
||||
|
||||
def add_to_context_menu(self, base, icon, text, slot):
|
||||
"""
|
||||
Utility method to help build context menus for plugins
|
||||
"""
|
||||
"""
|
||||
if type(icon) is QtGui.QIcon:
|
||||
ButtonIcon = icon
|
||||
elif type(icon) is types.StringType:
|
||||
@ -44,12 +44,12 @@ class PluginUtils(object):
|
||||
else:
|
||||
ButtonIcon.addPixmap(QtGui.QPixmap.fromImage(QtGui.QImage(icon)),
|
||||
QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||
|
||||
|
||||
action = QtGui.QAction(text, base)
|
||||
action .setIcon(ButtonIcon)
|
||||
QtCore.QObject.connect(action, QtCore.SIGNAL("triggered()"), slot)
|
||||
return action
|
||||
|
||||
|
||||
def _load_display_list(self):
|
||||
"""
|
||||
Load a display list from the config files
|
||||
@ -61,12 +61,12 @@ class PluginUtils(object):
|
||||
x = self.config.get_config("List Item "+str(i))
|
||||
list.append(x)
|
||||
return list
|
||||
|
||||
|
||||
def _save_display_list(self, displaylist):
|
||||
"""
|
||||
Save display list from the config files tidy up the list
|
||||
"""
|
||||
oldcount = self.config.get_config("List Count")
|
||||
oldcount = self.config.get_config("List Count")
|
||||
newcount = len(displaylist)
|
||||
self.config.set_config("List Count", str(newcount))
|
||||
for i in range (0, int(newcount)):
|
||||
@ -74,7 +74,7 @@ class PluginUtils(object):
|
||||
if oldcount > newcount: # Tidy up any old list itrms if list is smaller now
|
||||
for i in range(int(newcount) , int(oldcount)):
|
||||
self.config.delete_config("List Item "+str(i))
|
||||
|
||||
|
||||
def _get_last_dir(self, num=None):
|
||||
"""
|
||||
Read the last directory used for plugin
|
||||
@ -86,13 +86,13 @@ class PluginUtils(object):
|
||||
if lastdir==None:
|
||||
lastdir = ""
|
||||
return lastdir
|
||||
|
||||
|
||||
def _save_last_directory(self, filename, num=None):
|
||||
"""
|
||||
Save the last directory used for plugin
|
||||
"""
|
||||
"""
|
||||
fld = "Last Dir"
|
||||
if not num == None:
|
||||
fld = fld+str(num)
|
||||
path , nm = os.path.split(str(filename))
|
||||
fld = fld+str(num)
|
||||
path , nm = os.path.split(str(filename))
|
||||
self.config.set_config(fld, path)
|
||||
|
@ -24,11 +24,9 @@ from PyQt4.QtCore import *
|
||||
from PyQt4.QtGui import *
|
||||
|
||||
from openlp.core.resources import *
|
||||
from openlp.core.lib import Plugin,PluginUtils, MediaManagerItem, Receiver
|
||||
|
||||
from openlp.plugins.bibles.lib import BibleManager, BiblesTab
|
||||
from openlp.plugins.bibles.forms import BibleImportForm
|
||||
from openlp.core.lib import Plugin, PluginUtils
|
||||
|
||||
from openlp.plugins.bibles.lib import BibleManager, BiblesTab, BibleMediaItem
|
||||
from openlp.plugins.bibles.lib.tables import *
|
||||
from openlp.plugins.bibles.lib.classes import *
|
||||
|
||||
@ -36,6 +34,7 @@ class BiblePlugin(Plugin, PluginUtils):
|
||||
global log
|
||||
log=logging.getLogger("BiblePlugin")
|
||||
log.info("Bible Plugin loaded")
|
||||
|
||||
def __init__(self):
|
||||
# Call the parent constructor
|
||||
Plugin.__init__(self, 'Bible', '1.9.0')
|
||||
@ -46,9 +45,6 @@ class BiblePlugin(Plugin, PluginUtils):
|
||||
QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||
#Register the bible Manager
|
||||
self.biblemanager = BibleManager(self.config)
|
||||
self.search_results = {} # place to store the search results
|
||||
QtCore.QObject.connect(Receiver().get_receiver(),
|
||||
QtCore.SIGNAL("openlpreloadbibles"), self.reload_bibles)
|
||||
|
||||
def get_settings_tab(self):
|
||||
self.BiblesTab = BiblesTab()
|
||||
@ -56,181 +52,9 @@ class BiblePlugin(Plugin, PluginUtils):
|
||||
|
||||
def get_media_manager_item(self):
|
||||
# Create the MediaManagerItem object
|
||||
self.MediaManagerItem = MediaManagerItem(self.icon, 'Bible Verses')
|
||||
# Add a toolbar
|
||||
self.MediaManagerItem.addToolbar()
|
||||
# Create buttons for the toolbar
|
||||
## New Bible Button ##
|
||||
self.MediaManagerItem.addToolbarButton('New Bible', 'Register a new Bible',
|
||||
':/themes/theme_import.png', self.onBibleNewClick, 'BibleNewItem')
|
||||
## Separator Line ##
|
||||
self.MediaManagerItem.addToolbarSeparator()
|
||||
## Preview Bible Button ##
|
||||
self.MediaManagerItem.addToolbarButton('Preview Bible', 'Preview the selected Bible Verse',
|
||||
':/system/system_preview.png', self.onBiblePreviewClick, 'BiblePreviewItem')
|
||||
## Live Bible Button ##
|
||||
self.MediaManagerItem.addToolbarButton('Go Live', 'Send the selected Bible Verse(s) live',
|
||||
':/system/system_live.png', self.onBibleLiveClick, 'BibleLiveItem')
|
||||
## Add Bible Button ##
|
||||
self.MediaManagerItem.addToolbarButton('Add Bible Verse(s) To Service',
|
||||
'Add the selected Bible(s) to the service', ':/system/system_add.png',
|
||||
self.onBibleAddClick, 'BibleAddItem')
|
||||
## Separator Line ##
|
||||
#self.MediaManagerItem.addToolbarSeparator()
|
||||
## Add Bible Button ##
|
||||
|
||||
# Create the tab widget
|
||||
self.SearchTabWidget = QtGui.QTabWidget(self.MediaManagerItem)
|
||||
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(0)
|
||||
sizePolicy.setHeightForWidth(self.SearchTabWidget.sizePolicy().hasHeightForWidth())
|
||||
self.SearchTabWidget.setSizePolicy(sizePolicy)
|
||||
self.SearchTabWidget.setObjectName('SearchTabWidget')
|
||||
# Add the Quick Search tab
|
||||
self.QuickTab = QtGui.QWidget()
|
||||
self.QuickTab.setObjectName('QuickTab')
|
||||
self.QuickLayout = QtGui.QGridLayout(self.QuickTab)
|
||||
self.QuickLayout.setObjectName('QuickLayout')
|
||||
self.QuickVersionComboBox = QtGui.QComboBox(self.QuickTab)
|
||||
self.QuickVersionComboBox.setObjectName('VersionComboBox')
|
||||
self.QuickLayout.addWidget(self.QuickVersionComboBox, 0, 1, 1, 2)
|
||||
self.QuickVersionLabel = QtGui.QLabel(self.QuickTab)
|
||||
self.QuickVersionLabel.setObjectName('QuickVersionLabel')
|
||||
self.QuickVersionLabel.setText('Version:')
|
||||
self.QuickLayout.addWidget(self.QuickVersionLabel, 0, 0, 1, 1)
|
||||
|
||||
self.QuickSearchComboBox = QtGui.QComboBox(self.QuickTab)
|
||||
self.QuickSearchComboBox.setObjectName('SearchComboBox')
|
||||
self.QuickLayout.addWidget(self.QuickSearchComboBox, 1, 1, 1, 2)
|
||||
self.QuickSearchLabel = QtGui.QLabel(self.QuickTab)
|
||||
self.QuickSearchLabel .setObjectName('QuickSearchLabel')
|
||||
self.QuickSearchLabel .setText('Search Type:')
|
||||
self.QuickLayout.addWidget(self.QuickSearchLabel, 1, 0, 1, 1)
|
||||
|
||||
self.QuickSearchLabel = QtGui.QLabel(self.QuickTab)
|
||||
self.QuickSearchLabel.setObjectName('QuickSearchLabel')
|
||||
self.QuickSearchLabel.setText('Find:')
|
||||
self.QuickLayout.addWidget(self.QuickSearchLabel, 2, 0, 1, 1)
|
||||
self.QuickSearchEdit = QtGui.QLineEdit(self.QuickTab)
|
||||
self.QuickSearchEdit.setObjectName('QuickSearchEdit')
|
||||
self.QuickLayout.addWidget(self.QuickSearchEdit, 2, 1, 1, 2)
|
||||
self.QuickSearchButton = QtGui.QPushButton(self.QuickTab)
|
||||
self.QuickSearchButton.setObjectName('QuickSearchButton')
|
||||
self.QuickSearchButton.setText('Search')
|
||||
self.QuickLayout.addWidget(self.QuickSearchButton, 3, 2, 1, 1)
|
||||
|
||||
self.QuickClearLabel = QtGui.QLabel(self.QuickTab)
|
||||
self.QuickClearLabel.setObjectName('QuickSearchLabel')
|
||||
self.QuickClearLabel.setText('Results:')
|
||||
self.QuickLayout.addWidget(self.QuickClearLabel, 3, 0, 1, 1)
|
||||
self.ClearQuickSearchComboBox = QtGui.QComboBox(self.QuickTab)
|
||||
self.ClearQuickSearchComboBox.setObjectName('ClearQuickSearchComboBox')
|
||||
self.QuickLayout.addWidget(self.ClearQuickSearchComboBox, 3, 1, 1, 1)
|
||||
self.SearchTabWidget.addTab(self.QuickTab, 'Quick')
|
||||
QuickSpacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
|
||||
self.QuickLayout.addItem(QuickSpacerItem, 4, 2, 1, 1)
|
||||
|
||||
# Add the Advanced Search tab
|
||||
self.AdvancedTab = QtGui.QWidget()
|
||||
self.AdvancedTab.setObjectName('AdvancedTab')
|
||||
self.AdvancedLayout = QtGui.QGridLayout(self.AdvancedTab)
|
||||
self.AdvancedLayout.setObjectName('AdvancedLayout')
|
||||
self.AdvancedVersionLabel = QtGui.QLabel(self.AdvancedTab)
|
||||
self.AdvancedVersionLabel.setObjectName('AdvancedVersionLabel')
|
||||
self.AdvancedVersionLabel.setText('Version:')
|
||||
self.AdvancedLayout.addWidget(self.AdvancedVersionLabel, 0, 0, 1, 1)
|
||||
self.AdvancedVersionComboBox = QtGui.QComboBox(self.AdvancedTab)
|
||||
self.AdvancedVersionComboBox.setObjectName('AdvancedVersionComboBox')
|
||||
self.AdvancedLayout.addWidget(self.AdvancedVersionComboBox, 0, 2, 1, 2)
|
||||
self.AdvancedBookLabel = QtGui.QLabel(self.AdvancedTab)
|
||||
self.AdvancedBookLabel.setObjectName('AdvancedBookLabel')
|
||||
self.AdvancedBookLabel.setText('Book:')
|
||||
self.AdvancedLayout.addWidget(self.AdvancedBookLabel, 1, 0, 1, 1)
|
||||
self.AdvancedBookComboBox = QtGui.QComboBox(self.AdvancedTab)
|
||||
self.AdvancedBookComboBox.setObjectName('AdvancedBookComboBox')
|
||||
self.AdvancedLayout.addWidget(self.AdvancedBookComboBox, 1, 2, 1, 2)
|
||||
self.AdvancedChapterLabel = QtGui.QLabel(self.AdvancedTab)
|
||||
self.AdvancedChapterLabel.setObjectName('AdvancedChapterLabel')
|
||||
self.AdvancedChapterLabel.setText('Chapter:')
|
||||
self.AdvancedLayout.addWidget(self.AdvancedChapterLabel, 2, 2, 1, 1)
|
||||
self.AdvancedVerseLabel = QtGui.QLabel(self.AdvancedTab)
|
||||
self.AdvancedVerseLabel.setObjectName('AdvancedVerseLabel')
|
||||
self.AdvancedVerseLabel.setText('Verse:')
|
||||
self.AdvancedLayout.addWidget(self.AdvancedVerseLabel, 2, 3, 1, 1)
|
||||
self.AdvancedFromLabel = QtGui.QLabel(self.AdvancedTab)
|
||||
self.AdvancedFromLabel.setObjectName('AdvancedFromLabel')
|
||||
self.AdvancedFromLabel.setText('From:')
|
||||
self.AdvancedLayout.addWidget(self.AdvancedFromLabel, 3, 0, 1, 1)
|
||||
self.AdvancedToLabel = QtGui.QLabel(self.AdvancedTab)
|
||||
self.AdvancedToLabel.setObjectName('AdvancedToLabel')
|
||||
self.AdvancedToLabel.setText('To:')
|
||||
self.AdvancedLayout.addWidget(self.AdvancedToLabel, 4, 0, 1, 1)
|
||||
|
||||
self.AdvancedFromChapter = QtGui.QComboBox(self.AdvancedTab)
|
||||
self.AdvancedFromChapter.setObjectName('AdvancedFromChapter')
|
||||
self.AdvancedLayout.addWidget(self.AdvancedFromChapter, 3, 2, 1, 1)
|
||||
self.AdvancedFromVerse = QtGui.QComboBox(self.AdvancedTab)
|
||||
self.AdvancedFromVerse.setObjectName('AdvancedFromVerse')
|
||||
self.AdvancedLayout.addWidget(self.AdvancedFromVerse, 3, 3, 1, 1)
|
||||
|
||||
self.AdvancedToChapter = QtGui.QComboBox(self.AdvancedTab)
|
||||
self.AdvancedToChapter.setObjectName('AdvancedToChapter')
|
||||
self.AdvancedLayout.addWidget(self.AdvancedToChapter, 4, 2, 1, 1)
|
||||
self.AdvancedToVerse = QtGui.QComboBox(self.AdvancedTab)
|
||||
self.AdvancedToVerse.setObjectName('AdvancedToVerse')
|
||||
self.AdvancedLayout.addWidget(self.AdvancedToVerse, 4, 3, 1, 1)
|
||||
|
||||
self.AdvancedClearLabel = QtGui.QLabel(self.QuickTab)
|
||||
self.AdvancedClearLabel.setObjectName('QuickSearchLabel')
|
||||
self.AdvancedClearLabel.setText('Results:')
|
||||
self.AdvancedLayout.addWidget(self.AdvancedClearLabel, 5, 0, 1, 1)
|
||||
self.ClearAdvancedSearchComboBox = QtGui.QComboBox(self.QuickTab)
|
||||
self.ClearAdvancedSearchComboBox.setObjectName('ClearAdvancedSearchComboBox')
|
||||
self.AdvancedLayout.addWidget(self.ClearAdvancedSearchComboBox, 5, 2, 1, 1)
|
||||
|
||||
self.AdvancedSearchButton = QtGui.QPushButton(self.AdvancedTab)
|
||||
self.AdvancedSearchButton.setObjectName('AdvancedSearchButton')
|
||||
self.AdvancedSearchButton.setText('Search')
|
||||
self.AdvancedLayout.addWidget(self.AdvancedSearchButton, 5, 3, 1, 1)
|
||||
self.SearchTabWidget.addTab(self.AdvancedTab, 'Advanced')
|
||||
|
||||
# Add the search tab widget to the page layout
|
||||
self.MediaManagerItem.PageLayout.addWidget(self.SearchTabWidget)
|
||||
|
||||
self.BibleListView = QtGui.QTableWidget()
|
||||
self.BibleListView.setColumnCount(2)
|
||||
self.BibleListView.setColumnHidden(0, True)
|
||||
self.BibleListView.setColumnWidth(1, 275)
|
||||
self.BibleListView.setShowGrid(False)
|
||||
self.BibleListView.setSortingEnabled(False)
|
||||
self.BibleListView.setAlternatingRowColors(True)
|
||||
self.BibleListView.verticalHeader().setVisible(False)
|
||||
self.BibleListView.horizontalHeader().setVisible(False)
|
||||
|
||||
self.BibleListView.setGeometry(QtCore.QRect(10, 200, 256, 391))
|
||||
self.BibleListView.setObjectName("listView")
|
||||
self.BibleListView.setAlternatingRowColors(True)
|
||||
self.MediaManagerItem.PageLayout.addWidget(self.BibleListView)
|
||||
|
||||
##############Combo Boxes
|
||||
QtCore.QObject.connect(self.AdvancedVersionComboBox, QtCore.SIGNAL("activated(int)"), self.onAdvancedVersionComboBox)
|
||||
QtCore.QObject.connect(self.AdvancedBookComboBox, QtCore.SIGNAL("activated(int)"), self.onAdvancedBookComboBox)
|
||||
QtCore.QObject.connect(self.AdvancedFromChapter, QtCore.SIGNAL("activated(int)"), self.onAdvancedFromChapter)
|
||||
QtCore.QObject.connect(self.AdvancedFromVerse, QtCore.SIGNAL("activated(int)"), self.onAdvancedFromVerse)
|
||||
QtCore.QObject.connect(self.AdvancedToChapter, QtCore.SIGNAL("activated(int)"), self.onAdvancedToChapter)
|
||||
|
||||
##############Buttons
|
||||
QtCore.QObject.connect(self.AdvancedSearchButton, QtCore.SIGNAL("pressed()"), self.onAdvancedSearchButton)
|
||||
QtCore.QObject.connect(self.QuickSearchButton, QtCore.SIGNAL("pressed()"), self.onQuickSearchButton)
|
||||
|
||||
##############Context Menus
|
||||
self.BibleListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
|
||||
|
||||
self.BibleListView.addAction(self.add_to_context_menu(self.BibleListView, ':/system/system_preview.png', "&Preview Verse", self.onBiblePreviewClick))
|
||||
self.BibleListView.addAction(self.add_to_context_menu(self.BibleListView, ':/system/system_live.png', "&Show Live", self.onBibleLiveClick))
|
||||
self.BibleListView.addAction(self.add_to_context_menu(self.BibleListView, ':/system/system_add.png', "&Add to Service", self.onBibleAddClick))
|
||||
return self.MediaManagerItem
|
||||
self.media_item = BibleMediaItem(self.icon, 'Bible Verses',
|
||||
self.biblemanager)
|
||||
return self.media_item
|
||||
|
||||
def add_import_menu_item(self, import_menu):
|
||||
self.ImportBibleItem = QtGui.QAction(import_menu)
|
||||
@ -247,267 +71,13 @@ class BiblePlugin(Plugin, PluginUtils):
|
||||
self.ExportBibleItem.setText(QtGui.QApplication.translate("main_window", "&Bible", None, QtGui.QApplication.UnicodeUTF8))
|
||||
|
||||
def initialise(self):
|
||||
self._initialise_form() # build the form
|
||||
|
||||
def _initialise_form(self):
|
||||
log.debug("_initialise_form")
|
||||
self.QuickSearchComboBox.clear()
|
||||
self.QuickVersionComboBox.clear()
|
||||
self.AdvancedVersionComboBox.clear()
|
||||
self.ClearQuickSearchComboBox.clear()
|
||||
self.ClearAdvancedSearchComboBox.clear()
|
||||
|
||||
self.QuickSearchComboBox.addItem(u"Verse Search")
|
||||
self.QuickSearchComboBox.addItem(u"Text Search")
|
||||
self.ClearQuickSearchComboBox.addItem(u"Clear")
|
||||
self.ClearQuickSearchComboBox.addItem(u"Keep")
|
||||
self.ClearAdvancedSearchComboBox.addItem(u"Clear")
|
||||
self.ClearAdvancedSearchComboBox.addItem(u"Keep")
|
||||
|
||||
|
||||
bibles = self.biblemanager.get_bibles("full")
|
||||
for b in bibles: # load bibles into the combo boxes
|
||||
self.QuickVersionComboBox.addItem(b)
|
||||
|
||||
bibles = self.biblemanager.get_bibles("partial") # Without HTTP
|
||||
first = True
|
||||
for b in bibles: # load bibles into the combo boxes
|
||||
self.AdvancedVersionComboBox.addItem(b)
|
||||
if first:
|
||||
first = False
|
||||
self._initialise_bible_advanced(b) # use the first bible as the trigger
|
||||
|
||||
def onAdvancedVersionComboBox(self):
|
||||
self._initialise_bible_advanced(str(self.AdvancedVersionComboBox.currentText())) # restet the bible info
|
||||
pass
|
||||
|
||||
def onAdvancedBookComboBox(self):
|
||||
self._initialise_bible_advanced(str(self.AdvancedVersionComboBox.currentText())) # restet the bible info
|
||||
|
||||
def onBibleNewClick(self):
|
||||
self.bibleimportform = BibleImportForm(self.config, self.biblemanager, self)
|
||||
self.bibleimportform.exec_()
|
||||
pass
|
||||
|
||||
def onBibleLiveClick(self):
|
||||
pass
|
||||
|
||||
def onBibleAddClick(self):
|
||||
pass
|
||||
|
||||
def onSettingsSaveButton(self):
|
||||
self._save_settings()
|
||||
|
||||
def onSettingsResetButton(self):
|
||||
self._load_reset_settings()
|
||||
|
||||
def onAdvancedFromVerse(self):
|
||||
frm = self.AdvancedFromVerse.currentText()
|
||||
self._adjust_combobox(frm, self.verses, self.AdvancedToVerse)
|
||||
|
||||
def onAdvancedToChapter(self):
|
||||
t1 = self.AdvancedFromChapter.currentText()
|
||||
t2 = self.AdvancedToChapter.currentText()
|
||||
if t1 != t2:
|
||||
bible = str(self.AdvancedVersionComboBox.currentText())
|
||||
book = str(self.AdvancedBookComboBox.currentText())
|
||||
vse = self.biblemanager.get_book_verse_count(bible, book, int(t2))[0] # get the verse count for new chapter
|
||||
self._adjust_combobox(1, vse, self.AdvancedToVerse)
|
||||
|
||||
def onAdvancedSearchButton(self):
|
||||
bible = str(self.AdvancedVersionComboBox.currentText())
|
||||
book = str(self.AdvancedBookComboBox.currentText())
|
||||
chapter_from = int(self.AdvancedFromChapter.currentText())
|
||||
chapter_to = int(self.AdvancedToChapter.currentText())
|
||||
verse_from = int(self.AdvancedFromVerse.currentText())
|
||||
verse_to = int(self.AdvancedToVerse.currentText())
|
||||
self.search_results = self.biblemanager.get_verse_text(bible, book, chapter_from, chapter_to, verse_from, verse_to)
|
||||
if self.ClearAdvancedSearchComboBox.currentText() == u"Clear":
|
||||
self.BibleListView.clear() # clear the results
|
||||
self.BibleListView.setRowCount(0)
|
||||
self._display_results(bible)
|
||||
|
||||
def onAdvancedFromChapter(self):
|
||||
bible = str(self.AdvancedVersionComboBox.currentText())
|
||||
book = str(self.AdvancedBookComboBox.currentText())
|
||||
cf = self.AdvancedFromChapter.currentText()
|
||||
self._adjust_combobox(cf, self.chapters_from, self.AdvancedToChapter)
|
||||
vse = self.biblemanager.get_book_verse_count(bible, book, int(cf))[0] # get the verse count for new chapter
|
||||
self._adjust_combobox(1, vse, self.AdvancedFromVerse)
|
||||
self._adjust_combobox(1, vse, self.AdvancedToVerse)
|
||||
|
||||
def onQuickSearchButton(self):
|
||||
self.log.debug("onQuickSearchButton")
|
||||
bible = str(self.QuickVersionComboBox.currentText())
|
||||
text = str(self.QuickSearchEdit.displayText())
|
||||
|
||||
if self.ClearQuickSearchComboBox.currentText() == u"Clear":
|
||||
self.BibleListView.clear() # clear the results
|
||||
self.BibleListView.setRowCount(0)
|
||||
|
||||
if self.QuickSearchComboBox.currentText() == u"Text Search":
|
||||
self.search_results = self.biblemanager.get_verse_from_text(bible,text)
|
||||
else:
|
||||
self._search_using_bible_reference(bible, text)
|
||||
if not self.search_results == None:
|
||||
self._display_results(bible)
|
||||
|
||||
def onBiblePreviewClick(self):
|
||||
items = self.BibleListView.selectedItems()
|
||||
for item in items:
|
||||
text = str(item.text())
|
||||
verse = text[:text.find("(")]
|
||||
bible = text[text.find("(")+1:text.find(")")]
|
||||
self._search_using_bible_reference(bible, verse)
|
||||
book = self.search_results[0][0]
|
||||
chapter = str(self.search_results[0][1])
|
||||
verse = str(self.search_results[0][2])
|
||||
text = self.search_results[0][3]
|
||||
o = self.SettingsOutputStyleComboBox.currentIndex()
|
||||
v = self.SettingsVerseStyleComboBox.currentIndex()
|
||||
if o == 1: #Paragraph
|
||||
text = text + u"\n"
|
||||
if v == 1: #Paragraph
|
||||
loc = self._format_verse(chapter, verse, u"(", u")")
|
||||
elif v == 2: #Paragraph
|
||||
loc = self._format_verse(chapter, verse, u"{", u"}")
|
||||
elif v == 3: #Paragraph
|
||||
loc = self._format_verse(chapter, verse, u"[", u"]")
|
||||
else:
|
||||
loc = self._format_verse(chapter, verse, u"", u"")
|
||||
print book
|
||||
print loc
|
||||
print text
|
||||
|
||||
def _format_verse(self, chapter, verse, opening, closing):
|
||||
loc = opening
|
||||
if self.SettingsNewChapterCheck.checkState() == 2:
|
||||
loc += chapter+u":"
|
||||
loc += verse
|
||||
loc += closing
|
||||
return loc
|
||||
|
||||
def reload_bibles(self):
|
||||
self.biblemanager.reload_bibles()
|
||||
self._initialise_form()
|
||||
|
||||
def _initialise_bible_advanced(self, bible):
|
||||
log.debug("_initialise_bible_advanced %s ", bible)
|
||||
currentBook = str(self.AdvancedBookComboBox.currentText())
|
||||
cf = self.biblemanager.get_book_chapter_count(bible, currentBook)[0]
|
||||
log.debug("Book change bible %s book %s ChapterCount %s", bible, currentBook, cf)
|
||||
if cf == None: # Only change the search details if the book is missing from the new bible
|
||||
books = self.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._initialise_chapter_verse(bible, book.name)
|
||||
|
||||
def _initialise_chapter_verse(self, bible, book):
|
||||
log.debug("_initialise_chapter_verse %s , %s", bible, book)
|
||||
self.chapters_from = self.biblemanager.get_book_chapter_count(bible, book)[0]
|
||||
self.verses = self.biblemanager.get_book_verse_count(bible, book, 1)[0]
|
||||
self._adjust_combobox(1, self.chapters_from, self.AdvancedFromChapter)
|
||||
self._adjust_combobox(1, self.chapters_from, self.AdvancedToChapter)
|
||||
self._adjust_combobox(1, self.verses, self.AdvancedFromVerse)
|
||||
self._adjust_combobox(1, self.verses, self.AdvancedToVerse)
|
||||
|
||||
def _adjust_combobox(self, frm, to , combo):
|
||||
log.debug("_adjust_combobox %s , %s , %s", combo, frm, to)
|
||||
combo.clear()
|
||||
for i in range(int(frm), int(to) + 1):
|
||||
combo.addItem(str(i))
|
||||
|
||||
def _display_results(self, bible):
|
||||
for book, chap, vse , txt in self.search_results:
|
||||
row_count = self.BibleListView.rowCount()
|
||||
self.BibleListView.setRowCount(row_count+1)
|
||||
table_data = QtGui.QTableWidgetItem(str(bible))
|
||||
self.BibleListView.setItem(row_count , 0, table_data)
|
||||
table_data = QtGui.QTableWidgetItem(str(book + " " +str(chap) + ":"+ str(vse)) + " ("+str(bible)+")")
|
||||
self.BibleListView.setItem(row_count , 1, table_data)
|
||||
self.BibleListView.setRowHeight(row_count, 20)
|
||||
|
||||
def _search_using_bible_reference(self, bible, search):
|
||||
book = ""
|
||||
start_chapter = ""
|
||||
end_chapter = ""
|
||||
start_verse=""
|
||||
end_verse=""
|
||||
search.replace(" ", " ")
|
||||
search = search.strip()
|
||||
original = search
|
||||
message = None
|
||||
# Remove book
|
||||
for i in range (len(search)-1, 0, -1): # 0 index arrays
|
||||
if search[i] == " ":
|
||||
book = search[:i]
|
||||
search = search[i:] # remove book from string
|
||||
break
|
||||
search = search.replace("v", ":") # allow V or v for verse instead of :
|
||||
search = search.replace("V", ":") # allow V or v for verse instead of :
|
||||
search = search.strip()
|
||||
co = search.find(":")
|
||||
if co == -1: # no : found
|
||||
i = search.rfind(" ")
|
||||
if i == -1:
|
||||
chapter = ""
|
||||
else:
|
||||
chapter = search[i:len(search)]
|
||||
hi = chapter.find("-")
|
||||
if hi != -1:
|
||||
start_chapter= chapter[:hi]
|
||||
end_chapter= chapter[hi+1:len(chapter)]
|
||||
else:
|
||||
start_chapter = chapter
|
||||
else: # more complex
|
||||
#print search
|
||||
sp = search.split("-") #find first
|
||||
#print sp, len(sp)
|
||||
sp1 = sp[0].split(":")
|
||||
#print sp1, len(sp1)
|
||||
if len(sp1) == 1:
|
||||
start_chapter = sp1[0]
|
||||
start_verse = 1
|
||||
else:
|
||||
start_chapter = sp1[0]
|
||||
start_verse = sp1[1]
|
||||
if len(sp)== 1:
|
||||
end_chapter = start_chapter
|
||||
end_verse = start_verse
|
||||
else:
|
||||
sp1 = sp[1].split(":")
|
||||
#print sp1, len(sp1)
|
||||
if len(sp1) == 1:
|
||||
end_chapter = sp1[0]
|
||||
end_verse = 1
|
||||
else:
|
||||
end_chapter = sp1[0]
|
||||
end_verse = sp1[1]
|
||||
if end_chapter == "":
|
||||
end_chapter = start_chapter.rstrip()
|
||||
if start_verse == "":
|
||||
if end_verse == "":
|
||||
start_verse = 1
|
||||
else:
|
||||
start_verse = end_verse
|
||||
if end_verse == "":
|
||||
end_verse = 99
|
||||
if start_chapter == "":
|
||||
message = "No chapter found for search"
|
||||
#print "message = " + str(message)
|
||||
#print "search = " + str(original)
|
||||
#print "results = " + str(book) + " @ "+ str(start_chapter)+" @ "+ str(end_chapter)+" @ "+ str(start_verse)+ " @ "+ str(end_verse)
|
||||
|
||||
if message == None:
|
||||
self.search_results = None
|
||||
self.search_results = self.biblemanager.get_verse_text(bible, book,int(start_chapter), int(end_chapter), int(start_verse), int(end_verse))
|
||||
else:
|
||||
reply = QtGui.QMessageBox.information(self.MediaManagerItem,"Information",message)
|
||||
|
||||
def load_settings(self):
|
||||
pass
|
||||
# self.SettingsOutputStyleComboBox.setCurrentIndex(int(self.config.get_config("bible_output_style", 0)))
|
||||
|
@ -21,5 +21,6 @@ Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
from common import BibleCommon
|
||||
from manager import BibleManager
|
||||
from biblestab import BiblesTab
|
||||
from biblemediaitem import BibleMediaItem
|
||||
|
||||
__all__ = ['BibleCommon', 'BibleManager', 'BiblesTab']
|
||||
|
484
openlp/plugins/bibles/lib/biblemediaitem.py
Normal file
484
openlp/plugins/bibles/lib/biblemediaitem.py
Normal file
@ -0,0 +1,484 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
||||
"""
|
||||
OpenLP - Open Source Lyrics Projection
|
||||
Copyright (c) 2008 Raoul Snyman
|
||||
Portions copyright (c) 2008 Martin Thompson, Tim Bentley
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License as published by the Free Software
|
||||
Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with
|
||||
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
||||
Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
"""
|
||||
import logging
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core import translate
|
||||
from openlp.core.lib import MediaManagerItem, Receiver
|
||||
from openlp.core.resources import *
|
||||
|
||||
from openlp.plugins.bibles.forms import BibleImportForm
|
||||
|
||||
class BibleMediaItem(MediaManagerItem):
|
||||
"""
|
||||
This is the custom media manager item for Bibles.
|
||||
"""
|
||||
global log
|
||||
log=logging.getLogger("BibleMediaItem")
|
||||
log.info("Bible Media Item loaded")
|
||||
|
||||
def __init__(self, icon, title, biblemanager):
|
||||
self.biblemanager = biblemanager
|
||||
self.search_results = {} # place to store the search results
|
||||
QtCore.QObject.connect(Receiver().get_receiver(),
|
||||
QtCore.SIGNAL("openlpreloadbibles"), self.reloadBibles)
|
||||
MediaManagerItem.__init__(self, icon, title)
|
||||
|
||||
def setupUi(self):
|
||||
# Add a toolbar
|
||||
self.addToolbar()
|
||||
# Create buttons for the toolbar
|
||||
## New Bible Button ##
|
||||
self.addToolbarButton('New Bible', 'Register a new Bible',
|
||||
':/themes/theme_import.png', self.onBibleNewClick, 'BibleNewItem')
|
||||
## Separator Line ##
|
||||
self.addToolbarSeparator()
|
||||
## Preview Bible Button ##
|
||||
self.addToolbarButton('Preview Bible', 'Preview the selected Bible Verse',
|
||||
':/system/system_preview.png', self.onBiblePreviewClick, 'BiblePreviewItem')
|
||||
## Live Bible Button ##
|
||||
self.addToolbarButton('Go Live', 'Send the selected Bible Verse(s) live',
|
||||
':/system/system_live.png', self.onBibleLiveClick, 'BibleLiveItem')
|
||||
## Add Bible Button ##
|
||||
self.addToolbarButton('Add Bible Verse(s) To Service',
|
||||
'Add the selected Bible(s) to the service', ':/system/system_add.png',
|
||||
self.onBibleAddClick, 'BibleAddItem')
|
||||
|
||||
# Create the tab widget
|
||||
self.SearchTabWidget = QtGui.QTabWidget(self)
|
||||
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(0)
|
||||
sizePolicy.setHeightForWidth(self.SearchTabWidget.sizePolicy().hasHeightForWidth())
|
||||
self.SearchTabWidget.setSizePolicy(sizePolicy)
|
||||
self.SearchTabWidget.setObjectName('SearchTabWidget')
|
||||
|
||||
# Add the Quick Search tab
|
||||
self.QuickTab = QtGui.QWidget()
|
||||
self.QuickTab.setObjectName('QuickTab')
|
||||
self.QuickLayout = QtGui.QGridLayout(self.QuickTab)
|
||||
self.QuickLayout.setObjectName('QuickLayout')
|
||||
self.QuickVersionComboBox = QtGui.QComboBox(self.QuickTab)
|
||||
self.QuickVersionComboBox.setObjectName('VersionComboBox')
|
||||
self.QuickLayout.addWidget(self.QuickVersionComboBox, 0, 1, 1, 2)
|
||||
self.QuickVersionLabel = QtGui.QLabel(self.QuickTab)
|
||||
self.QuickVersionLabel.setObjectName('QuickVersionLabel')
|
||||
self.QuickLayout.addWidget(self.QuickVersionLabel, 0, 0, 1, 1)
|
||||
|
||||
self.QuickSearchComboBox = QtGui.QComboBox(self.QuickTab)
|
||||
self.QuickSearchComboBox.setObjectName('SearchComboBox')
|
||||
self.QuickLayout.addWidget(self.QuickSearchComboBox, 1, 1, 1, 2)
|
||||
self.QuickSearchLabel = QtGui.QLabel(self.QuickTab)
|
||||
self.QuickSearchLabel.setObjectName('QuickSearchLabel')
|
||||
self.QuickLayout.addWidget(self.QuickSearchLabel, 1, 0, 1, 1)
|
||||
|
||||
self.QuickSearchLabel = QtGui.QLabel(self.QuickTab)
|
||||
self.QuickSearchLabel.setObjectName('QuickSearchLabel')
|
||||
self.QuickLayout.addWidget(self.QuickSearchLabel, 2, 0, 1, 1)
|
||||
self.QuickSearchEdit = QtGui.QLineEdit(self.QuickTab)
|
||||
self.QuickSearchEdit.setObjectName('QuickSearchEdit')
|
||||
self.QuickLayout.addWidget(self.QuickSearchEdit, 2, 1, 1, 2)
|
||||
self.QuickSearchButton = QtGui.QPushButton(self.QuickTab)
|
||||
self.QuickSearchButton.setObjectName('QuickSearchButton')
|
||||
self.QuickLayout.addWidget(self.QuickSearchButton, 3, 2, 1, 1)
|
||||
|
||||
self.QuickClearLabel = QtGui.QLabel(self.QuickTab)
|
||||
self.QuickClearLabel.setObjectName('QuickSearchLabel')
|
||||
self.QuickLayout.addWidget(self.QuickClearLabel, 3, 0, 1, 1)
|
||||
self.ClearQuickSearchComboBox = QtGui.QComboBox(self.QuickTab)
|
||||
self.ClearQuickSearchComboBox.setObjectName('ClearQuickSearchComboBox')
|
||||
self.QuickLayout.addWidget(self.ClearQuickSearchComboBox, 3, 1, 1, 1)
|
||||
self.SearchTabWidget.addTab(self.QuickTab, 'Quick')
|
||||
QuickSpacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
|
||||
self.QuickLayout.addItem(QuickSpacerItem, 4, 2, 1, 1)
|
||||
|
||||
# Add the Advanced Search tab
|
||||
self.AdvancedTab = QtGui.QWidget()
|
||||
self.AdvancedTab.setObjectName('AdvancedTab')
|
||||
self.AdvancedLayout = QtGui.QGridLayout(self.AdvancedTab)
|
||||
self.AdvancedLayout.setObjectName('AdvancedLayout')
|
||||
self.AdvancedVersionLabel = QtGui.QLabel(self.AdvancedTab)
|
||||
self.AdvancedVersionLabel.setObjectName('AdvancedVersionLabel')
|
||||
self.AdvancedLayout.addWidget(self.AdvancedVersionLabel, 0, 0, 1, 1)
|
||||
self.AdvancedVersionComboBox = QtGui.QComboBox(self.AdvancedTab)
|
||||
self.AdvancedVersionComboBox.setObjectName('AdvancedVersionComboBox')
|
||||
self.AdvancedLayout.addWidget(self.AdvancedVersionComboBox, 0, 2, 1, 2)
|
||||
self.AdvancedBookLabel = QtGui.QLabel(self.AdvancedTab)
|
||||
self.AdvancedBookLabel.setObjectName('AdvancedBookLabel')
|
||||
self.AdvancedLayout.addWidget(self.AdvancedBookLabel, 1, 0, 1, 1)
|
||||
self.AdvancedBookComboBox = QtGui.QComboBox(self.AdvancedTab)
|
||||
self.AdvancedBookComboBox.setObjectName('AdvancedBookComboBox')
|
||||
self.AdvancedLayout.addWidget(self.AdvancedBookComboBox, 1, 2, 1, 2)
|
||||
self.AdvancedChapterLabel = QtGui.QLabel(self.AdvancedTab)
|
||||
self.AdvancedChapterLabel.setObjectName('AdvancedChapterLabel')
|
||||
self.AdvancedLayout.addWidget(self.AdvancedChapterLabel, 2, 2, 1, 1)
|
||||
self.AdvancedVerseLabel = QtGui.QLabel(self.AdvancedTab)
|
||||
self.AdvancedVerseLabel.setObjectName('AdvancedVerseLabel')
|
||||
self.AdvancedLayout.addWidget(self.AdvancedVerseLabel, 2, 3, 1, 1)
|
||||
self.AdvancedFromLabel = QtGui.QLabel(self.AdvancedTab)
|
||||
self.AdvancedFromLabel.setObjectName('AdvancedFromLabel')
|
||||
self.AdvancedLayout.addWidget(self.AdvancedFromLabel, 3, 0, 1, 1)
|
||||
self.AdvancedToLabel = QtGui.QLabel(self.AdvancedTab)
|
||||
self.AdvancedToLabel.setObjectName('AdvancedToLabel')
|
||||
self.AdvancedLayout.addWidget(self.AdvancedToLabel, 4, 0, 1, 1)
|
||||
|
||||
self.AdvancedFromChapter = QtGui.QComboBox(self.AdvancedTab)
|
||||
self.AdvancedFromChapter.setObjectName('AdvancedFromChapter')
|
||||
self.AdvancedLayout.addWidget(self.AdvancedFromChapter, 3, 2, 1, 1)
|
||||
self.AdvancedFromVerse = QtGui.QComboBox(self.AdvancedTab)
|
||||
self.AdvancedFromVerse.setObjectName('AdvancedFromVerse')
|
||||
self.AdvancedLayout.addWidget(self.AdvancedFromVerse, 3, 3, 1, 1)
|
||||
|
||||
self.AdvancedToChapter = QtGui.QComboBox(self.AdvancedTab)
|
||||
self.AdvancedToChapter.setObjectName('AdvancedToChapter')
|
||||
self.AdvancedLayout.addWidget(self.AdvancedToChapter, 4, 2, 1, 1)
|
||||
self.AdvancedToVerse = QtGui.QComboBox(self.AdvancedTab)
|
||||
self.AdvancedToVerse.setObjectName('AdvancedToVerse')
|
||||
self.AdvancedLayout.addWidget(self.AdvancedToVerse, 4, 3, 1, 1)
|
||||
|
||||
self.AdvancedClearLabel = QtGui.QLabel(self.QuickTab)
|
||||
self.AdvancedClearLabel.setObjectName('QuickSearchLabel')
|
||||
self.AdvancedLayout.addWidget(self.AdvancedClearLabel, 5, 0, 1, 1)
|
||||
self.ClearAdvancedSearchComboBox = QtGui.QComboBox(self.QuickTab)
|
||||
self.ClearAdvancedSearchComboBox.setObjectName('ClearAdvancedSearchComboBox')
|
||||
self.AdvancedLayout.addWidget(self.ClearAdvancedSearchComboBox, 5, 2, 1, 1)
|
||||
|
||||
self.AdvancedSearchButton = QtGui.QPushButton(self.AdvancedTab)
|
||||
self.AdvancedSearchButton.setObjectName('AdvancedSearchButton')
|
||||
self.AdvancedLayout.addWidget(self.AdvancedSearchButton, 5, 3, 1, 1)
|
||||
self.SearchTabWidget.addTab(self.AdvancedTab, 'Advanced')
|
||||
|
||||
# Add the search tab widget to the page layout
|
||||
self.PageLayout.addWidget(self.SearchTabWidget)
|
||||
|
||||
self.BibleListView = QtGui.QTableWidget()
|
||||
self.BibleListView.setColumnCount(2)
|
||||
self.BibleListView.setColumnHidden(0, True)
|
||||
self.BibleListView.setColumnWidth(1, 275)
|
||||
self.BibleListView.setShowGrid(False)
|
||||
self.BibleListView.setSortingEnabled(False)
|
||||
self.BibleListView.setAlternatingRowColors(True)
|
||||
self.BibleListView.verticalHeader().setVisible(False)
|
||||
self.BibleListView.horizontalHeader().setVisible(False)
|
||||
self.BibleListView.setGeometry(QtCore.QRect(10, 200, 256, 391))
|
||||
self.BibleListView.setObjectName(u'BibleListView')
|
||||
self.BibleListView.setAlternatingRowColors(True)
|
||||
self.PageLayout.addWidget(self.BibleListView)
|
||||
# Combo Boxes
|
||||
QtCore.QObject.connect(self.AdvancedVersionComboBox, QtCore.SIGNAL("activated(int)"), self.onAdvancedVersionComboBox)
|
||||
QtCore.QObject.connect(self.AdvancedBookComboBox, QtCore.SIGNAL("activated(int)"), self.onAdvancedBookComboBox)
|
||||
QtCore.QObject.connect(self.AdvancedFromChapter, QtCore.SIGNAL("activated(int)"), self.onAdvancedFromChapter)
|
||||
QtCore.QObject.connect(self.AdvancedFromVerse, QtCore.SIGNAL("activated(int)"), self.onAdvancedFromVerse)
|
||||
QtCore.QObject.connect(self.AdvancedToChapter, QtCore.SIGNAL("activated(int)"), self.onAdvancedToChapter)
|
||||
# Buttons
|
||||
QtCore.QObject.connect(self.AdvancedSearchButton, QtCore.SIGNAL("pressed()"), self.onAdvancedSearchButton)
|
||||
QtCore.QObject.connect(self.QuickSearchButton, QtCore.SIGNAL("pressed()"), self.onQuickSearchButton)
|
||||
# Context Menus
|
||||
self.BibleListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
|
||||
self.BibleListView.addAction(self.contextMenuAction(
|
||||
self.BibleListView, ':/system/system_preview.png',
|
||||
"&Preview Verse", self.onBiblePreviewClick))
|
||||
self.BibleListView.addAction(self.contextMenuAction(
|
||||
self.BibleListView, ':/system/system_live.png',
|
||||
"&Show Live", self.onBibleLiveClick))
|
||||
self.BibleListView.addAction(self.contextMenuAction(
|
||||
self.BibleListView, ':/system/system_add.png',
|
||||
"&Add to Service", self.onBibleAddClick))
|
||||
|
||||
def retranslateUi(self):
|
||||
self.QuickVersionLabel.setText(translate(u'BibleMediaItem', u'Version:'))
|
||||
self.QuickSearchLabel.setText(translate(u'BibleMediaItem', u'Search Type:'))
|
||||
self.QuickSearchLabel.setText(translate(u'BibleMediaItem', u'Find:'))
|
||||
self.QuickSearchButton.setText(translate(u'BibleMediaItem', u'Search'))
|
||||
self.QuickClearLabel.setText(translate(u'BibleMediaItem', u'Results:'))
|
||||
self.AdvancedVersionLabel.setText(translate(u'BibleMediaItem', u'Version:'))
|
||||
self.AdvancedBookLabel.setText(translate(u'BibleMediaItem', u'Book:'))
|
||||
self.AdvancedChapterLabel.setText(translate(u'BibleMediaItem', u'Chapter:'))
|
||||
self.AdvancedVerseLabel.setText(translate(u'BibleMediaItem', u'Verse:'))
|
||||
self.AdvancedFromLabel.setText(translate(u'BibleMediaItem', u'From:'))
|
||||
self.AdvancedToLabel.setText(translate(u'BibleMediaItem', u'To:'))
|
||||
self.AdvancedClearLabel.setText(translate(u'BibleMediaItem', u'Results:'))
|
||||
self.AdvancedSearchButton.setText(translate(u'BibleMediaItem', u'Search'))
|
||||
self.QuickSearchComboBox.addItem(translate(u'BibleMediaItem', u'Verse Search'))
|
||||
self.QuickSearchComboBox.addItem(translate(u'BibleMediaItem', u'Text Search'))
|
||||
self.ClearQuickSearchComboBox.addItem(translate(u'BibleMediaItem', u'Clear'))
|
||||
self.ClearQuickSearchComboBox.addItem(translate(u'BibleMediaItem', u'Keep'))
|
||||
self.ClearAdvancedSearchComboBox.addItem(translate(u'BibleMediaItem', u'Clear'))
|
||||
self.ClearAdvancedSearchComboBox.addItem(translate(u'BibleMediaItem', u'Keep'))
|
||||
|
||||
def initialise(self):
|
||||
self.loadBibles()
|
||||
self.QuickSearchComboBox.clear()
|
||||
self.QuickVersionComboBox.clear()
|
||||
self.AdvancedVersionComboBox.clear()
|
||||
self.ClearQuickSearchComboBox.clear()
|
||||
self.ClearAdvancedSearchComboBox.clear()
|
||||
|
||||
def loadBibles(self):
|
||||
bibles = self.biblemanager.get_bibles('full')
|
||||
for bible in bibles: # load bibles into the combo boxes
|
||||
self.QuickVersionComboBox.addItem(bible)
|
||||
bibles = self.biblemanager.get_bibles('partial') # Without HTTP
|
||||
first = True
|
||||
for bible in bibles: # load bibles into the combo boxes
|
||||
self.AdvancedVersionComboBox.addItem(bible)
|
||||
if first:
|
||||
first = False
|
||||
self.initialiseBible(bible) # use the first bible as the trigger
|
||||
|
||||
def onAdvancedVersionComboBox(self):
|
||||
self.initialiseBible(str(self.AdvancedVersionComboBox.currentText())) # restet the bible info
|
||||
pass
|
||||
|
||||
def onAdvancedBookComboBox(self):
|
||||
self.initialiseBible(str(self.AdvancedVersionComboBox.currentText())) # restet the bible info
|
||||
|
||||
def onBibleNewClick(self):
|
||||
self.bibleimportform = BibleImportForm(self.config, self.biblemanager, self)
|
||||
self.bibleimportform.exec_()
|
||||
pass
|
||||
|
||||
def onBibleLiveClick(self):
|
||||
pass
|
||||
|
||||
def onBibleAddClick(self):
|
||||
pass
|
||||
|
||||
def onSettingsSaveButton(self):
|
||||
pass
|
||||
|
||||
def onSettingsResetButton(self):
|
||||
pass
|
||||
|
||||
def onAdvancedFromVerse(self):
|
||||
frm = self.AdvancedFromVerse.currentText()
|
||||
self.adjustComboBox(frm, self.verses, self.AdvancedToVerse)
|
||||
|
||||
def onAdvancedToChapter(self):
|
||||
t1 = self.AdvancedFromChapter.currentText()
|
||||
t2 = self.AdvancedToChapter.currentText()
|
||||
if t1 != t2:
|
||||
bible = str(self.AdvancedVersionComboBox.currentText())
|
||||
book = str(self.AdvancedBookComboBox.currentText())
|
||||
vse = self.biblemanager.get_book_verse_count(bible, book, int(t2))[0] # get the verse count for new chapter
|
||||
self.adjustComboBox(1, vse, self.AdvancedToVerse)
|
||||
|
||||
def onAdvancedSearchButton(self):
|
||||
bible = str(self.AdvancedVersionComboBox.currentText())
|
||||
book = str(self.AdvancedBookComboBox.currentText())
|
||||
chapter_from = int(self.AdvancedFromChapter.currentText())
|
||||
chapter_to = int(self.AdvancedToChapter.currentText())
|
||||
verse_from = int(self.AdvancedFromVerse.currentText())
|
||||
verse_to = int(self.AdvancedToVerse.currentText())
|
||||
self.search_results = self.biblemanager.get_verse_text(bible, book,
|
||||
chapter_from, chapter_to, verse_from, verse_to)
|
||||
if self.ClearAdvancedSearchComboBox.currentIndex() == 0:
|
||||
self.BibleListView.clear() # clear the results
|
||||
self.BibleListView.setRowCount(0)
|
||||
self.displayResults(bible)
|
||||
|
||||
def onAdvancedFromChapter(self):
|
||||
bible = str(self.AdvancedVersionComboBox.currentText())
|
||||
book = str(self.AdvancedBookComboBox.currentText())
|
||||
cf = self.AdvancedFromChapter.currentText()
|
||||
self._adjust_combobox(cf, self.chapters_from, self.AdvancedToChapter)
|
||||
vse = self.biblemanager.get_book_verse_count(bible, book, int(cf))[0] # get the verse count for new chapter
|
||||
self._adjust_combobox(1, vse, self.AdvancedFromVerse)
|
||||
self._adjust_combobox(1, vse, self.AdvancedToVerse)
|
||||
|
||||
def onQuickSearchButton(self):
|
||||
self.log.debug("onQuickSearchButton")
|
||||
bible = str(self.QuickVersionComboBox.currentText())
|
||||
text = str(self.QuickSearchEdit.displayText())
|
||||
if self.ClearQuickSearchComboBox.currentIndex() == 0:
|
||||
self.BibleListView.clear() # clear the results
|
||||
self.BibleListView.setRowCount(0)
|
||||
elif self.QuickSearchComboBox.currentIndex() == 1:
|
||||
self.search_results = self.biblemanager.get_verse_from_text(bible, text)
|
||||
else:
|
||||
self.searchByReference(bible, text)
|
||||
if not self.search_results == None:
|
||||
self.displayResults(bible)
|
||||
|
||||
def onBiblePreviewClick(self):
|
||||
items = self.BibleListView.selectedItems()
|
||||
for item in items:
|
||||
text = str(item.text())
|
||||
verse = text[:text.find("(")]
|
||||
bible = text[text.find("(") + 1:text.find(")")]
|
||||
self.searchByReference(bible, verse)
|
||||
book = self.search_results[0][0]
|
||||
chapter = str(self.search_results[0][1])
|
||||
verse = str(self.search_results[0][2])
|
||||
text = self.search_results[0][3]
|
||||
o = self.SettingsOutputStyleComboBox.currentIndex()
|
||||
v = self.SettingsVerseStyleComboBox.currentIndex()
|
||||
if o == 1: #Paragraph
|
||||
text = text + u"\n"
|
||||
if v == 1: #Paragraph
|
||||
loc = self._format_verse(chapter, verse, u"(", u")")
|
||||
elif v == 2: #Paragraph
|
||||
loc = self._format_verse(chapter, verse, u"{", u"}")
|
||||
elif v == 3: #Paragraph
|
||||
loc = self._format_verse(chapter, verse, u"[", u"]")
|
||||
else:
|
||||
loc = self._format_verse(chapter, verse, u"", u"")
|
||||
print book
|
||||
print loc
|
||||
print text
|
||||
|
||||
def formatVerse(self, chapter, verse, opening, closing):
|
||||
loc = opening
|
||||
if self.SettingsNewChapterCheck.checkState() == 2:
|
||||
loc += chapter + u':'
|
||||
loc += verse
|
||||
loc += closing
|
||||
return loc
|
||||
|
||||
def reloadBibles(self):
|
||||
self.biblemanager.reload_bibles()
|
||||
self._initialise_form()
|
||||
|
||||
def initialiseBible(self, bible):
|
||||
log.debug('initialiseBible %s', bible)
|
||||
current_book = str(self.AdvancedBookComboBox.currentText())
|
||||
chapter_count = self.biblemanager.get_book_chapter_count(bible,
|
||||
current_book)[0]
|
||||
log.debug('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.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)
|
||||
|
||||
def initialiseChapterVerse(self, bible, book):
|
||||
log.debug("initialiseChapterVerse %s , %s", bible, book)
|
||||
self.chapters_from = self.biblemanager.get_book_chapter_count(bible, book)[0]
|
||||
self.verses = self.biblemanager.get_book_verse_count(bible, book, 1)[0]
|
||||
self.adjustComboBox(1, self.chapters_from, self.AdvancedFromChapter)
|
||||
self.adjustComboBox(1, self.chapters_from, self.AdvancedToChapter)
|
||||
self.adjustComboBox(1, self.verses, self.AdvancedFromVerse)
|
||||
self.adjustComboBox(1, self.verses, self.AdvancedToVerse)
|
||||
|
||||
def adjustComboBox(self, frm, to , combo):
|
||||
log.debug("adjustComboBox %s , %s , %s", combo, frm, to)
|
||||
combo.clear()
|
||||
for i in range(int(frm), int(to) + 1):
|
||||
combo.addItem(str(i))
|
||||
|
||||
def displayResults(self, bible):
|
||||
for book, chap, vse , txt in self.search_results:
|
||||
row_count = self.BibleListView.rowCount()
|
||||
self.BibleListView.setRowCount(row_count+1)
|
||||
table_data = QtGui.QTableWidgetItem(str(bible))
|
||||
self.BibleListView.setItem(row_count , 0, table_data)
|
||||
table_data = QtGui.QTableWidgetItem(str(book + " " +str(chap) + ":"+ str(vse)) + " ("+str(bible)+")")
|
||||
self.BibleListView.setItem(row_count , 1, table_data)
|
||||
self.BibleListView.setRowHeight(row_count, 20)
|
||||
|
||||
def searchByReference(self, bible, search):
|
||||
book = ''
|
||||
start_chapter = ''
|
||||
end_chapter = ''
|
||||
start_verse = ''
|
||||
end_verse = ''
|
||||
search = search.replace(' ', ' ').strip()
|
||||
original = search
|
||||
message = None
|
||||
# Remove book
|
||||
for i in range (len(search)-1, 0, -1): # 0 index arrays
|
||||
if search[i] == ' ':
|
||||
book = search[:i]
|
||||
search = search[i:] # remove book from string
|
||||
break
|
||||
search = search.replace('v', ':') # allow V or v for verse instead of :
|
||||
search = search.replace('V', ':') # allow V or v for verse instead of :
|
||||
search = search.strip()
|
||||
colon = search.find(':')
|
||||
if colon == -1:
|
||||
# number : found
|
||||
i = search.rfind(' ')
|
||||
if i == -1:
|
||||
chapter = ''
|
||||
else:
|
||||
chapter = search[i:len(search)]
|
||||
hyphen = chapter.find('-')
|
||||
if hyphen != -1:
|
||||
start_chapter= chapter[:hyphen]
|
||||
end_chapter= chapter[hyphen + 1:len(chapter)]
|
||||
else:
|
||||
start_chapter = chapter
|
||||
else:
|
||||
# more complex
|
||||
#print search
|
||||
sp = search.split('-') #find first
|
||||
#print sp, len(sp)
|
||||
sp1 = sp[0].split(':')
|
||||
#print sp1, len(sp1)
|
||||
if len(sp1) == 1:
|
||||
start_chapter = sp1[0]
|
||||
start_verse = 1
|
||||
else:
|
||||
start_chapter = sp1[0]
|
||||
start_verse = sp1[1]
|
||||
if len(sp)== 1:
|
||||
end_chapter = start_chapter
|
||||
end_verse = start_verse
|
||||
else:
|
||||
sp1 = sp[1].split(':')
|
||||
#print sp1, len(sp1)
|
||||
if len(sp1) == 1:
|
||||
end_chapter = sp1[0]
|
||||
end_verse = 1
|
||||
else:
|
||||
end_chapter = sp1[0]
|
||||
end_verse = sp1[1]
|
||||
if end_chapter == '':
|
||||
end_chapter = start_chapter.rstrip()
|
||||
if start_verse == '':
|
||||
if end_verse == '':
|
||||
start_verse = 1
|
||||
else:
|
||||
start_verse = end_verse
|
||||
if end_verse == '':
|
||||
end_verse = 99
|
||||
if start_chapter == '':
|
||||
message = u'No chapter found for search'
|
||||
#print "message = " + str(message)
|
||||
#print "search = " + str(original)
|
||||
#print "results = " + str(book) + " @ "+ str(start_chapter)+" @ "+ str(end_chapter)+" @ "+ str(start_verse)+ " @ "+ str(end_verse)
|
||||
|
||||
if message == None:
|
||||
self.search_results = None
|
||||
self.search_results = self.biblemanager.get_verse_text(bible, book,
|
||||
int(start_chapter), int(end_chapter), int(start_verse),
|
||||
int(end_verse))
|
||||
else:
|
||||
reply = QtGui.QMessageBox.information(self.MediaManagerItem,
|
||||
translate(u'BibleMediaItem', u'Information'),
|
||||
translate(u'BibleMediaItem', message))
|
@ -123,14 +123,10 @@ class BiblesTab(SettingsTab):
|
||||
self.DisplayStyleComboBox.setItemText(1, translate("SettingsForm", "( and )"))
|
||||
self.DisplayStyleComboBox.setItemText(2, translate("SettingsForm", "{ and }"))
|
||||
self.DisplayStyleComboBox.setItemText(3, translate("SettingsForm", "[ and ]"))
|
||||
self.ChangeNoteLabel.setText(translate("SettingsForm", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
|
||||
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
|
||||
"p, li { white-space: pre-wrap; }\n"
|
||||
"</style></head><body style=\" font-family:\'DejaVu Sans\'; font-size:10pt; font-weight:400; font-style:normal;\">\n"
|
||||
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-style:italic;\">Changes don\'t affect verses already in the service</span></p></body></html>"))
|
||||
self.ChangeNoteLabel.setText(translate("SettingsForm", "Note:\nChanges don\'t affect verses already in the service"))
|
||||
self.BibleSearchGroupBox.setTitle(translate("SettingsForm", "Search"))
|
||||
self.BibleSearchCheckBox.setText(translate("SettingsForm", "Search-as-you-type"))
|
||||
|
||||
|
||||
def load(self):
|
||||
bible_output_style = self.config.get_config("bible_output_style", "Paragraph")
|
||||
if bible_output_style == "Paragraph":
|
||||
@ -150,7 +146,7 @@ class BiblesTab(SettingsTab):
|
||||
if self.ParagraphRadioButton.isChecked():
|
||||
self.config.set_config("bible_output_style", "Paragraph")
|
||||
else:
|
||||
self.config.set_config("bible_output_style", "Verse")
|
||||
self.config.set_config("bible_output_style", "Verse")
|
||||
print "NCCB =- ", self.NewChaptersCheckBox.checkState()
|
||||
print "DSCB =- ", self.DisplayStyleComboBox.currentIndex()
|
||||
print "BSCB =- ",self.BibleSearchCheckBox.checkState()
|
||||
|
Loading…
Reference in New Issue
Block a user