Strange problems with events firing early.

Fixed bugs to stop errors by chaning initilistion order and defining varables.
Changing method names following last review.
This commit is contained in:
Tim Bentley 2009-06-08 06:04:06 +01:00
parent 47884bc340
commit 7becc9cb56
6 changed files with 29 additions and 38 deletions

View File

@ -64,6 +64,7 @@ class RenderManager:
self.calculate_default(self.screen_list[self.current_display]['size'])
self.theme = u''
self.service_theme = u''
self.global_style = u''
def update_display(self, screen_number):
"""

View File

@ -75,12 +75,12 @@ class MainWindow(object):
# hook methods have to happen after find_plugins. Find plugins needs the
# controllershence the hooks have moved from setupUI() to here
# Find and insert media manager items
log.info(u'hook media')
self.plugin_manager.hook_media_manager(self.MediaToolBox)
# Find and insert settings tabs
log.info(u'hook settings')
self.plugin_manager.hook_settings_tabs(self.settingsForm)
# Find and insert media manager items
log.info(u'hook media')
self.plugin_manager.hook_media_manager(self.MediaToolBox)
# Call the hook method to pull in import menus.
log.info(u'hook menus')
self.plugin_manager.hook_import_menu(self.FileImportMenu)

View File

@ -124,7 +124,7 @@ class BibleImportForm(QtGui.QDialog, Ui_BibleImportDialog):
# Was OSIS and is not any more stops lostFocus running mad
if self.bible_type == u'OSIS':
self.bible_type = None
self.freeAll()
self.resetScreenFieldStates()
def onBooksLocationEditLostFocus(self):
self.checkOsis()
@ -209,9 +209,9 @@ class BibleImportForm(QtGui.QDialog, Ui_BibleImportDialog):
str(self.PermisionEdit.displayText()))
self.bible_type = None
# free the screen state restrictions
self.freeAll()
self.resetScreenFieldStates()
# reset all the screen fields
self.resetAll()
self.resetEntryFields()
def checkOsis(self):
if len(self.BooksLocationEdit.displayText()) > 0 or len(self.VerseLocationEdit.displayText()) > 0:
@ -220,7 +220,7 @@ class BibleImportForm(QtGui.QDialog, Ui_BibleImportDialog):
# Was CSV and is not any more stops lostFocus running mad
if self.bible_type == u'CSV':
self.bible_type = None
self.freeAll()
self.resetScreenFieldStates()
def checkHttp(self):
if self.BibleComboBox.currentIndex() != 0 : # First slot is blank so no bible
@ -229,7 +229,7 @@ class BibleImportForm(QtGui.QDialog, Ui_BibleImportDialog):
# Was HTTP and is not any more stops lostFocus running mad
if self.bible_type == u'HTTP':
self.bible_type = None
self.freeAll()
self.resetScreenFieldStates()
def blockCsv(self):
self.BooksLocationEdit.setReadOnly(True)
@ -247,7 +247,7 @@ class BibleImportForm(QtGui.QDialog, Ui_BibleImportDialog):
self.blockHttp()
def setOsis(self):
self.bible_type = 'OSIS'
self.bible_type = u'OSIS'
self.OSISLocationEdit.setReadOnly(False)
self.OsisFileButton.setEnabled(True)
self.blockCsv()
@ -268,8 +268,9 @@ class BibleImportForm(QtGui.QDialog, Ui_BibleImportDialog):
self.LocationComboBox.setEnabled(False)
self.BibleComboBox.setEnabled(False)
def freeAll(self):
if self.bible_type == None: # only reset if no bible type set.
def resetScreenFieldStates(self):
# only reset if no bible type set.
if self.bible_type == None:
self.BooksLocationEdit.setReadOnly(False)
self.VerseLocationEdit.setReadOnly(False)
self.BooksFileButton.setEnabled(True)
@ -279,7 +280,7 @@ class BibleImportForm(QtGui.QDialog, Ui_BibleImportDialog):
self.LocationComboBox.setEnabled(True)
self.BibleComboBox.setEnabled(True)
def resetAll(self):
def resetEntryFields(self):
self.BooksLocationEdit.setText(u'')
self.VerseLocationEdit.setText(u'')
self.OSISLocationEdit.setText(u'')

View File

@ -17,6 +17,7 @@ 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 Qt, QtCore, QtGui
@ -27,6 +28,10 @@ class BiblesTab(SettingsTab):
"""
BiblesTab is the Bibles settings tab in the settings dialog.
"""
global log
log = logging.getLogger(u'BibleTab')
log.info(u'Bible Tab loaded')
def __init__(self):
self.paragraph_style = True
self.show_new_chapters = False
@ -67,14 +72,12 @@ class BiblesTab(SettingsTab):
self.NewChaptersCheckBox = QtGui.QCheckBox(self.VerseDisplayGroupBox)
self.NewChaptersCheckBox.setObjectName("NewChaptersCheckBox")
self.VerseDisplayLayout.addWidget(self.NewChaptersCheckBox, 1, 0, 1, 1)
self.DisplayStyleWidget = QtGui.QWidget(self.VerseDisplayGroupBox)
self.DisplayStyleWidget.setObjectName(u'DisplayStyleWidget')
self.DisplayStyleLayout = QtGui.QHBoxLayout(self.DisplayStyleWidget)
self.DisplayStyleLayout.setSpacing(8)
self.DisplayStyleLayout.setMargin(0)
self.DisplayStyleLayout.setObjectName(u'DisplayStyleLayout')
self.DisplayStyleLabel = QtGui.QLabel(self.DisplayStyleWidget)
self.DisplayStyleLabel.setObjectName(u'DisplayStyleLabel')
self.DisplayStyleLayout.addWidget(self.DisplayStyleLabel)
@ -86,14 +89,12 @@ class BiblesTab(SettingsTab):
self.DisplayStyleComboBox.addItem(QtCore.QString())
self.DisplayStyleLayout.addWidget(self.DisplayStyleComboBox)
self.VerseDisplayLayout.addWidget(self.DisplayStyleWidget, 2, 0, 1, 1)
self.BibleThemeWidget = QtGui.QWidget(self.VerseDisplayGroupBox)
self.BibleThemeWidget.setObjectName(u'BibleThemeWidget')
self.BibleThemeLayout = QtGui.QHBoxLayout(self.BibleThemeWidget)
self.BibleThemeLayout.setSpacing(8)
self.BibleThemeLayout.setMargin(0)
self.BibleThemeLayout.setObjectName(u'BibleThemeLayout')
self.BibleThemeLabel = QtGui.QLabel(self.BibleThemeWidget)
self.BibleThemeLabel.setObjectName(u'BibleThemeLabel')
self.BibleThemeLayout.addWidget(self.BibleThemeLabel)
@ -102,7 +103,6 @@ class BiblesTab(SettingsTab):
self.BibleThemeComboBox.addItem(QtCore.QString())
self.BibleThemeLayout.addWidget(self.BibleThemeComboBox)
self.VerseDisplayLayout.addWidget(self.BibleThemeWidget, 3, 0, 1, 1)
self.ChangeNoteLabel = QtGui.QLabel(self.VerseDisplayGroupBox)
self.ChangeNoteLabel.setObjectName(u'ChangeNoteLabel')
self.VerseDisplayLayout.addWidget(self.ChangeNoteLabel, 4, 0, 1, 1)
@ -111,7 +111,6 @@ class BiblesTab(SettingsTab):
QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
self.BibleLeftLayout.addItem(self.BibleLeftSpacer)
self.BibleLayout.addWidget(self.BibleLeftWidget)
self.BibleRightWidget = QtGui.QWidget(self)
self.BibleRightWidget.setObjectName(u'BibleRightWidget')
self.BibleRightLayout = QtGui.QVBoxLayout(self.BibleRightWidget)
@ -176,13 +175,15 @@ class BiblesTab(SettingsTab):
def onNewChaptersCheckBoxChanged(self):
check_state = self.NewChaptersCheckBox.checkState()
self.show_new_chapters = False
if check_state == 2: # we have a set value convert to True/False
# we have a set value convert to True/False
if check_state == 2:
self.show_new_chapters = True
def onBibleSearchCheckBoxChanged(self):
check_state = self.BibleSearchCheckBox.checkState()
self.bible_search = False
if check_state == 2: # we have a set value convert to True/False
# we have a set value convert to True/False
if check_state == 2:
self.bible_search = True
def load(self):

View File

@ -42,9 +42,7 @@ class BibleList(QtGui.QListView):
mimeData = QtCore.QMimeData()
drag.setMimeData(mimeData)
mimeData.setText(u'Bibles')
dropAction = drag.start(QtCore.Qt.CopyAction)
if dropAction == QtCore.Qt.CopyAction:
self.close()
@ -90,7 +88,6 @@ class BibleMediaItem(MediaManagerItem):
translate(u'BibleMediaItem',u'Add the selected Bible(s) to the service'),
u':/system/system_add.png',
self.onBibleAddClick, u'BibleAddItem')
# Create the tab widget
self.SearchTabWidget = QtGui.QTabWidget(self)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
@ -99,7 +96,6 @@ class BibleMediaItem(MediaManagerItem):
sizePolicy.setHeightForWidth(self.SearchTabWidget.sizePolicy().hasHeightForWidth())
self.SearchTabWidget.setSizePolicy(sizePolicy)
self.SearchTabWidget.setObjectName(u'SearchTabWidget')
# Add the Quick Search tab
self.QuickTab = QtGui.QWidget()
self.QuickTab.setObjectName(u'QuickTab')
@ -138,7 +134,6 @@ class BibleMediaItem(MediaManagerItem):
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(u'AdvancedTab')
@ -170,45 +165,37 @@ class BibleMediaItem(MediaManagerItem):
self.AdvancedToLabel = QtGui.QLabel(self.AdvancedTab)
self.AdvancedToLabel.setObjectName(u'AdvancedToLabel')
self.AdvancedLayout.addWidget(self.AdvancedToLabel, 4, 0, 1, 1)
self.AdvancedFromChapter = QtGui.QComboBox(self.AdvancedTab)
self.AdvancedFromChapter.setObjectName(u'AdvancedFromChapter')
self.AdvancedLayout.addWidget(self.AdvancedFromChapter, 3, 2, 1, 1)
self.AdvancedFromVerse = QtGui.QComboBox(self.AdvancedTab)
self.AdvancedFromVerse.setObjectName(u'AdvancedFromVerse')
self.AdvancedLayout.addWidget(self.AdvancedFromVerse, 3, 3, 1, 1)
self.AdvancedToChapter = QtGui.QComboBox(self.AdvancedTab)
self.AdvancedToChapter.setObjectName(u'AdvancedToChapter')
self.AdvancedLayout.addWidget(self.AdvancedToChapter, 4, 2, 1, 1)
self.AdvancedToVerse = QtGui.QComboBox(self.AdvancedTab)
self.AdvancedToVerse.setObjectName(u'AdvancedToVerse')
self.AdvancedLayout.addWidget(self.AdvancedToVerse, 4, 3, 1, 1)
self.AdvancedClearLabel = QtGui.QLabel(self.QuickTab)
self.AdvancedClearLabel.setObjectName(u'QuickSearchLabel')
self.AdvancedLayout.addWidget(self.AdvancedClearLabel, 5, 0, 1, 1)
self.ClearAdvancedSearchComboBox = QtGui.QComboBox(self.QuickTab)
self.ClearAdvancedSearchComboBox.setObjectName(u'ClearAdvancedSearchComboBox')
self.AdvancedLayout.addWidget(self.ClearAdvancedSearchComboBox, 5, 2, 1, 1)
self.AdvancedSearchButton = QtGui.QPushButton(self.AdvancedTab)
self.AdvancedSearchButton.setObjectName(u'AdvancedSearchButton')
self.AdvancedLayout.addWidget(self.AdvancedSearchButton, 5, 3, 1, 1)
self.SearchTabWidget.addTab(self.AdvancedTab, u'Advanced')
# Add the search tab widget to the page layout
self.PageLayout.addWidget(self.SearchTabWidget)
self.BibleListView = BibleList()
self.BibleListView.setAlternatingRowColors(True)
self.BibleListData = TextListData()
self.BibleListView.setModel(self.BibleListData)
self.BibleListView.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection)
self.BibleListView.setDragEnabled(True)
self.PageLayout.addWidget(self.BibleListView)
# Combo Boxes
QtCore.QObject.connect(self.AdvancedVersionComboBox,
QtCore.SIGNAL(u'activated(int)'), self.onAdvancedVersionComboBox)
@ -226,7 +213,7 @@ class BibleMediaItem(MediaManagerItem):
QtCore.QObject.connect(self.QuickSearchButton,
QtCore.SIGNAL(u'pressed()'), self.onQuickSearchButton)
QtCore.QObject.connect(self.BibleListView,
QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.onBiblePreviewClick())
QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.onBiblePreviewClick)
# Context Menus
self.BibleListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
self.BibleListView.addAction(self.contextMenuAction(
@ -273,7 +260,8 @@ class BibleMediaItem(MediaManagerItem):
# load bibles into the combo boxes
for bible in bibles:
self.QuickVersionComboBox.addItem(bible)
bibles = self.parent.biblemanager.get_bibles(u'partial') # Without HTTP
# Without HTT
bibles = self.parent.biblemanager.get_bibles(u'partial')
first = True
# load bibles into the combo boxes
for bible in bibles:
@ -363,7 +351,7 @@ class BibleMediaItem(MediaManagerItem):
self.parent.preview_controller.addServiceItem(service_item)
def generateSlideData(self, service_item):
log.debug(u'Bible Preview Button pressed')
log.debug(u'generating slide data')
items = self.BibleListView.selectedIndexes()
old_chapter = u''
raw_slides=[]
@ -455,7 +443,7 @@ class BibleMediaItem(MediaManagerItem):
end_chapter = ''
start_verse = ''
end_verse = ''
search = search.replace(u' ', ' ').strip()
search = search.replace(u' ', u' ').strip()
original = search
message = None
# Remove book beware 0 index arrays

View File

@ -136,7 +136,7 @@ class SongMediaItem(MediaManagerItem):
QtCore.QObject.connect(self.SearchTextEdit,
QtCore.SIGNAL(u'textChanged(const QString&)'), self.onSearchTextEditChanged)
QtCore.QObject.connect(self.SongListView,
QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.onSongPreviewClick)
QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.onSongPreviewClick)
#define and add the context menu
self.SongListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
self.SongListView.addAction(self.contextMenuAction(self.SongListView,