2008-11-28 20:30:59 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
2008-11-30 18:36:13 +00:00
|
|
|
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
2008-11-28 20:30:59 +00:00
|
|
|
"""
|
|
|
|
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
|
|
|
|
"""
|
|
|
|
|
2008-12-14 15:49:54 +00:00
|
|
|
import logging
|
|
|
|
|
2008-11-28 20:30:59 +00:00
|
|
|
from PyQt4 import QtCore, QtGui
|
2008-12-14 15:49:54 +00:00
|
|
|
|
2008-11-29 05:36:16 +00:00
|
|
|
from openlp.core.resources import *
|
2008-12-01 18:36:53 +00:00
|
|
|
from openlp.core.lib import Plugin, MediaManagerItem
|
2008-12-14 15:49:54 +00:00
|
|
|
from openlp.plugins.bibles.lib import BibleManager
|
|
|
|
from openlp.plugins.bibles.forms import BibleImportForm
|
2008-12-07 20:04:07 +00:00
|
|
|
|
2008-11-28 20:30:59 +00:00
|
|
|
class BiblePlugin(Plugin):
|
2008-12-07 20:04:07 +00:00
|
|
|
global log
|
|
|
|
log=logging.getLogger("BiblePlugin")
|
2008-12-14 15:49:54 +00:00
|
|
|
log.info("Bible Plugin loaded")
|
2008-11-28 20:30:59 +00:00
|
|
|
def __init__(self):
|
|
|
|
# Call the parent constructor
|
2008-11-29 05:36:16 +00:00
|
|
|
Plugin.__init__(self, 'Bible', '1.9.0')
|
2008-12-14 15:49:54 +00:00
|
|
|
self.weight = -9
|
|
|
|
# Create the plugin icon
|
|
|
|
self.icon = QtGui.QIcon()
|
|
|
|
self.icon.addPixmap(QtGui.QPixmap(':/media/media_verse.png'),
|
|
|
|
QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
2008-11-29 07:56:21 +00:00
|
|
|
#Register the bible Manager
|
2008-12-07 20:04:07 +00:00
|
|
|
self.biblemanager = BibleManager(self.config)
|
2008-12-10 20:36:45 +00:00
|
|
|
self.searchresults = {} # place to store the search results
|
2008-11-29 07:56:21 +00:00
|
|
|
|
2008-12-14 15:49:54 +00:00
|
|
|
def get_media_manager_item(self):
|
2008-11-28 20:30:59 +00:00
|
|
|
# Create the MediaManagerItem object
|
2008-12-14 15:49:54 +00:00
|
|
|
self.MediaManagerItem = MediaManagerItem(self.icon, 'Bible Verses')
|
2008-11-28 20:30:59 +00:00
|
|
|
# Add a toolbar
|
|
|
|
self.MediaManagerItem.addToolbar()
|
|
|
|
# Create buttons for the toolbar
|
|
|
|
## New Bible Button ##
|
2008-12-01 20:25:47 +00:00
|
|
|
self.MediaManagerItem.addToolbarButton('New Bible', 'Register a new Bible',
|
2008-12-14 15:49:54 +00:00
|
|
|
':/themes/theme_import.png', self.onBibleNewClick, 'BibleNewItem')
|
2008-12-01 18:36:53 +00:00
|
|
|
## Separator Line ##
|
2008-12-01 20:25:47 +00:00
|
|
|
self.MediaManagerItem.addToolbarSeparator()
|
2008-11-28 20:30:59 +00:00
|
|
|
## 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')
|
2008-12-05 22:03:28 +00:00
|
|
|
## Separator Line ##
|
|
|
|
#self.MediaManagerItem.addToolbarSeparator()
|
2008-12-02 20:34:51 +00:00
|
|
|
## Add Bible Button ##
|
2008-12-05 22:03:28 +00:00
|
|
|
|
|
|
|
# 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:')
|
2008-12-14 15:49:54 +00:00
|
|
|
self.QuickLayout.addWidget(self.QuickVersionLabel, 0, 0, 1, 1)
|
|
|
|
|
2008-12-11 21:07:12 +00:00
|
|
|
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:')
|
2008-12-14 15:49:54 +00:00
|
|
|
self.QuickLayout.addWidget(self.QuickSearchLabel, 1, 0, 1, 1)
|
2008-12-11 21:07:12 +00:00
|
|
|
|
2008-12-05 22:03:28 +00:00
|
|
|
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)
|
|
|
|
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')
|
|
|
|
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)
|
2008-12-14 15:49:54 +00:00
|
|
|
|
2008-12-05 22:03:28 +00:00
|
|
|
self.AdvancedFromChapter = QtGui.QComboBox(self.AdvancedTab)
|
|
|
|
self.AdvancedFromChapter.setObjectName('AdvancedFromChapter')
|
2008-12-06 07:47:01 +00:00
|
|
|
self.AdvancedLayout.addWidget(self.AdvancedFromChapter, 3, 2, 1, 1)
|
2008-12-05 22:03:28 +00:00
|
|
|
self.AdvancedFromVerse = QtGui.QComboBox(self.AdvancedTab)
|
|
|
|
self.AdvancedFromVerse.setObjectName('AdvancedFromVerse')
|
2008-12-06 07:47:01 +00:00
|
|
|
self.AdvancedLayout.addWidget(self.AdvancedFromVerse, 3, 3, 1, 1)
|
2008-12-14 15:49:54 +00:00
|
|
|
|
2008-12-05 22:03:28 +00:00
|
|
|
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)
|
2008-12-14 15:49:54 +00:00
|
|
|
|
2008-12-05 22:03:28 +00:00
|
|
|
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 Search')
|
|
|
|
|
|
|
|
# Add the search tab widget to the page layout
|
|
|
|
self.MediaManagerItem.PageLayout.addWidget(self.SearchTabWidget)
|
|
|
|
|
2008-12-10 20:36:45 +00:00
|
|
|
self.listView = QtGui.QListWidget()
|
2008-12-05 20:06:41 +00:00
|
|
|
self.listView.setGeometry(QtCore.QRect(10, 200, 256, 391))
|
2008-12-01 22:04:45 +00:00
|
|
|
self.listView.setObjectName("listView")
|
2008-12-05 22:03:28 +00:00
|
|
|
self.MediaManagerItem.PageLayout.addWidget(self.listView)
|
2008-12-14 15:49:54 +00:00
|
|
|
|
2008-12-06 19:34:48 +00:00
|
|
|
#QtCore.QObject.connect(self.QuickTab, QtCore.SIGNAL("triggered()"), self.onQuickTabClick)
|
|
|
|
QtCore.QObject.connect( self.SearchTabWidget, QtCore.SIGNAL("currentChanged ( QWidget * )" ), self.onQuickTabClick)
|
|
|
|
QtCore.QObject.connect(self.AdvancedVersionComboBox, QtCore.SIGNAL("activated(int)"), self.onAdvancedVersionComboBox)
|
2008-12-14 15:49:54 +00:00
|
|
|
QtCore.QObject.connect(self.AdvancedBookComboBox, QtCore.SIGNAL("activated(int)"), self.onAdvancedBookComboBox)
|
2008-12-07 20:04:07 +00:00
|
|
|
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)
|
2008-12-14 15:49:54 +00:00
|
|
|
|
2008-12-14 20:43:44 +00:00
|
|
|
self._initialise_form()
|
2008-12-13 09:03:39 +00:00
|
|
|
QtCore.QObject.connect(self.AdvancedSearchButton, QtCore.SIGNAL("pressed()"), self.onAdvancedSearchButton)
|
2008-12-14 15:49:54 +00:00
|
|
|
QtCore.QObject.connect(self.QuickSearchButton, QtCore.SIGNAL("pressed()"), self.onQuickSearchButton)
|
|
|
|
|
2008-12-01 14:25:08 +00:00
|
|
|
return self.MediaManagerItem
|
|
|
|
|
2008-12-14 20:43:44 +00:00
|
|
|
def initialise(self):
|
|
|
|
self._initialise_form()
|
2008-12-13 09:03:39 +00:00
|
|
|
|
2008-12-06 19:34:48 +00:00
|
|
|
def onAdvancedVersionComboBox(self):
|
2008-12-14 20:43:44 +00:00
|
|
|
self._initialise_bible_advanced(str(self.AdvancedVersionComboBox.currentText())) # restet the bible info
|
2008-12-07 20:04:07 +00:00
|
|
|
|
|
|
|
def onAdvancedBookComboBox(self):
|
2008-12-06 19:34:48 +00:00
|
|
|
print self.AdvancedVersionComboBox.currentText()
|
2008-12-14 20:43:44 +00:00
|
|
|
self._initialise_bible_advanced(str(self.AdvancedVersionComboBox.currentText())) # restet the bible info
|
2008-12-14 15:49:54 +00:00
|
|
|
|
2008-12-06 19:34:48 +00:00
|
|
|
def onQuickTabClick(self):
|
|
|
|
print "onQuickTabClick"
|
|
|
|
print self.SearchTabWidget.currentIndex()
|
|
|
|
print self.SearchTabWidget.tabText(self.SearchTabWidget.currentIndex())
|
|
|
|
pass
|
|
|
|
|
2008-11-28 20:30:59 +00:00
|
|
|
def onBibleNewClick(self):
|
2008-12-05 20:06:41 +00:00
|
|
|
self.bibleimportform = BibleImportForm(self.biblemanager)
|
2008-12-13 10:46:07 +00:00
|
|
|
self.bibleimportform.setModal(True)
|
2008-12-05 20:06:41 +00:00
|
|
|
self.bibleimportform.show()
|
2008-12-01 18:36:53 +00:00
|
|
|
pass
|
2008-11-28 20:30:59 +00:00
|
|
|
|
|
|
|
def onBiblePreviewClick(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def onBibleLiveClick(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def onBibleAddClick(self):
|
|
|
|
pass
|
2008-12-03 10:57:34 +00:00
|
|
|
|
2008-12-14 20:43:44 +00:00
|
|
|
def _initialise_form(self):
|
2008-12-15 18:10:47 +00:00
|
|
|
bibles = self.biblemanager.get_bibles()
|
2008-12-11 21:07:12 +00:00
|
|
|
self.QuickSearchComboBox.addItem("Text Search")
|
2008-12-14 15:49:54 +00:00
|
|
|
self.QuickSearchComboBox.addItem("Verse Search")
|
2008-12-07 20:04:07 +00:00
|
|
|
first = True
|
|
|
|
for b in bibles: # load bibles into the combo boxes
|
2008-12-06 09:33:46 +00:00
|
|
|
self.QuickVersionComboBox.addItem(b)
|
2008-12-14 15:49:54 +00:00
|
|
|
self.AdvancedVersionComboBox.addItem(b)
|
2008-12-07 20:04:07 +00:00
|
|
|
if first:
|
|
|
|
first = False
|
2008-12-14 20:43:44 +00:00
|
|
|
self._initialise_bible(b) # use the fist bible as the trigger
|
2008-12-07 20:04:07 +00:00
|
|
|
|
2008-12-14 20:43:44 +00:00
|
|
|
def _initialise_bible(self, bible):
|
|
|
|
log.debug("_initialise_bible %s ", bible)
|
|
|
|
self._initialise_bible_quick(bible)
|
|
|
|
self._initialise_bible_advanced(bible)
|
2008-12-02 20:34:51 +00:00
|
|
|
|
2008-12-14 20:43:44 +00:00
|
|
|
def _initialise_bible_advanced(self, bible):
|
|
|
|
log.debug("_initialise_bible_advanced %s ", bible)
|
2008-12-07 20:04:07 +00:00
|
|
|
currentBook = str(self.AdvancedBookComboBox.currentText())
|
2008-12-15 18:10:47 +00:00
|
|
|
cf = self.biblemanager.get_book_chapter_count(bible, currentBook)[0]
|
2008-12-07 20:04:07 +00:00
|
|
|
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
|
2008-12-16 17:29:39 +00:00
|
|
|
books = self.biblemanager.get_bible_books(str(self.AdvancedVersionComboBox.currentText()))
|
2008-12-07 20:04:07 +00:00
|
|
|
self.AdvancedBookComboBox.clear()
|
|
|
|
first = True
|
|
|
|
for b in books:
|
2008-12-14 15:49:54 +00:00
|
|
|
self.AdvancedBookComboBox.addItem(b[0])
|
2008-12-07 20:04:07 +00:00
|
|
|
if first:
|
|
|
|
book = b
|
|
|
|
first = False
|
2008-12-14 20:43:44 +00:00
|
|
|
self._initialise_chapter_verse(bible, b[0])
|
2008-12-02 20:34:51 +00:00
|
|
|
|
2008-12-14 20:43:44 +00:00
|
|
|
def _initialise_chapter_verse(self, bible, book):
|
|
|
|
log.debug("_initialise_chapter_verse %s , %s", bible, book)
|
2008-12-15 18:10:47 +00:00
|
|
|
self.chaptersfrom = self.biblemanager.get_book_chapter_count(bible, book)[0]
|
|
|
|
self.verses = self.biblemanager.get_book_verse_count(bible, book, 1)[0]
|
2008-12-14 20:43:44 +00:00
|
|
|
self._adjust_combobox(1, self.chaptersfrom, self.AdvancedFromChapter)
|
|
|
|
self._adjust_combobox(1, self.chaptersfrom, self.AdvancedToChapter)
|
|
|
|
self._adjust_combobox(1, self.verses, self.AdvancedFromVerse)
|
|
|
|
self._adjust_combobox(1, self.verses, self.AdvancedToVerse)
|
2008-12-14 15:49:54 +00:00
|
|
|
|
2008-12-07 20:04:07 +00:00
|
|
|
def onAdvancedFromChapter(self):
|
|
|
|
bible = str(self.AdvancedVersionComboBox.currentText())
|
|
|
|
book = str(self.AdvancedBookComboBox.currentText())
|
|
|
|
cf = self.AdvancedFromChapter.currentText()
|
2008-12-14 20:43:44 +00:00
|
|
|
self._adjust_combobox(cf, self.chaptersfrom, self.AdvancedToChapter)
|
2008-12-15 18:10:47 +00:00
|
|
|
vse = self.biblemanager.get_book_verse_count(bible, book, int(cf))[0] # get the verse count for new chapter
|
2008-12-14 20:43:44 +00:00
|
|
|
self._adjust_combobox(1, vse, self.AdvancedFromVerse)
|
|
|
|
self._adjust_combobox(1, vse, self.AdvancedToVerse)
|
2008-12-14 15:49:54 +00:00
|
|
|
|
2008-12-14 20:43:44 +00:00
|
|
|
def _adjust_combobox(self, frm, to , combo):
|
|
|
|
log.debug("_adjust_combobox %s , %s , %s", combo, frm, to)
|
2008-12-07 20:04:07 +00:00
|
|
|
combo.clear()
|
2008-12-14 15:49:54 +00:00
|
|
|
for i in range(int(frm), int(to) + 1):
|
2008-12-07 20:04:07 +00:00
|
|
|
combo.addItem(str(i))
|
2008-12-14 15:49:54 +00:00
|
|
|
|
2008-12-07 20:04:07 +00:00
|
|
|
def onAdvancedFromVerse(self):
|
|
|
|
frm = self.AdvancedFromVerse.currentText()
|
2008-12-14 20:43:44 +00:00
|
|
|
self._adjust_combobox(frm, self.verses, self.AdvancedToVerse)
|
2008-12-14 15:49:54 +00:00
|
|
|
|
|
|
|
def onAdvancedToChapter(self):
|
|
|
|
t1 = self.AdvancedFromChapter.currentText()
|
2008-12-07 20:04:07 +00:00
|
|
|
t2 = self.AdvancedToChapter.currentText()
|
|
|
|
if t1 != t2:
|
|
|
|
bible = str(self.AdvancedVersionComboBox.currentText())
|
2008-12-14 15:49:54 +00:00
|
|
|
book = str(self.AdvancedBookComboBox.currentText())
|
2008-12-15 18:10:47 +00:00
|
|
|
vse = self.biblemanager.get_book_verse_count(bible, book, int(t2))[0] # get the verse count for new chapter
|
2008-12-14 20:43:44 +00:00
|
|
|
self._adjust_combobox(1, vse, self.AdvancedToVerse)
|
2008-12-14 15:49:54 +00:00
|
|
|
|
2008-12-10 20:36:45 +00:00
|
|
|
def onAdvancedSearchButton(self):
|
|
|
|
bible = str(self.AdvancedVersionComboBox.currentText())
|
2008-12-14 15:49:54 +00:00
|
|
|
book = str(self.AdvancedBookComboBox.currentText())
|
2008-12-10 20:36:45 +00:00
|
|
|
chapfrom = int(self.AdvancedFromChapter.currentText())
|
|
|
|
chapto = int(self.AdvancedToChapter.currentText())
|
|
|
|
versefrom = int(self.AdvancedFromVerse.currentText())
|
|
|
|
verseto = int(self.AdvancedToVerse.currentText())
|
2008-12-16 19:13:31 +00:00
|
|
|
self.searchresults = self.biblemanager.get_verse_text(bible, book, chapfrom, chapto, versefrom, verseto)
|
2008-12-15 18:10:47 +00:00
|
|
|
self._display_results()
|
2008-12-14 15:49:54 +00:00
|
|
|
|
2008-12-13 09:03:39 +00:00
|
|
|
def onQuickSearchButton(self):
|
2008-12-16 19:13:31 +00:00
|
|
|
self.log.debug("onQuickSearchButton")
|
2008-12-13 09:03:39 +00:00
|
|
|
bible = str(self.QuickVersionComboBox.currentText())
|
|
|
|
text = str(self.QuickSearchEdit.displayText())
|
2008-12-14 15:49:54 +00:00
|
|
|
|
2008-12-13 09:03:39 +00:00
|
|
|
if self.QuickSearchComboBox.currentText() == "Text Search":
|
2008-12-15 18:10:47 +00:00
|
|
|
self._search_text(bible, text)
|
2008-12-13 09:03:39 +00:00
|
|
|
else:
|
2008-12-15 18:10:47 +00:00
|
|
|
self._verse_search()
|
2008-12-14 15:49:54 +00:00
|
|
|
|
2008-12-14 20:43:44 +00:00
|
|
|
def _search_text(self, bible, text):
|
2008-12-16 19:13:31 +00:00
|
|
|
self.log.debug("_search Text %s,%s", bible, text)
|
2008-12-15 18:10:47 +00:00
|
|
|
self.searchresults = self.biblemanager.get_verse_from_text(bible,text)
|
|
|
|
self._display_results()
|
2008-12-13 09:03:39 +00:00
|
|
|
|
2008-12-14 20:43:44 +00:00
|
|
|
def _verse_search(self):
|
2008-12-15 18:10:47 +00:00
|
|
|
self._display_results()
|
2008-12-14 15:49:54 +00:00
|
|
|
|
2008-12-14 20:43:44 +00:00
|
|
|
def _display_results(self):
|
2008-12-13 09:03:39 +00:00
|
|
|
self.listView.clear() # clear the results
|
|
|
|
for book, chap, vse , txt in self.searchresults:
|
|
|
|
self.listView.addItem(book + " " +str(chap) + ":"+ str(vse))
|
2008-12-14 15:49:54 +00:00
|
|
|
|
2008-12-14 20:43:44 +00:00
|
|
|
def _initialise_bible_quick(self, bible): # not sure if needed yet!
|
2008-12-07 20:04:07 +00:00
|
|
|
a=1
|