forked from openlp/openlp
Cleanup, speedup and another UI library component
bzr-revno: 1269
This commit is contained in:
commit
c9491f0085
|
@ -182,3 +182,11 @@ def shortcut_action(parent, text, shortcuts, function):
|
||||||
action.setShortcutContext(QtCore.Qt.WidgetWithChildrenShortcut)
|
action.setShortcutContext(QtCore.Qt.WidgetWithChildrenShortcut)
|
||||||
QtCore.QObject.connect(action, QtCore.SIGNAL(u'triggered()'), function)
|
QtCore.QObject.connect(action, QtCore.SIGNAL(u'triggered()'), function)
|
||||||
return action
|
return action
|
||||||
|
|
||||||
|
def add_widget_completer(cache, widget):
|
||||||
|
"""
|
||||||
|
Add a text autocompleter to a widget.
|
||||||
|
"""
|
||||||
|
completer = QtGui.QCompleter(cache)
|
||||||
|
completer.setCaseSensitivity(QtCore.Qt.CaseInsensitive)
|
||||||
|
widget.setCompleter(completer)
|
||||||
|
|
|
@ -30,7 +30,8 @@ from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
from openlp.core.lib import MediaManagerItem, Receiver, BaseListWithDnD, \
|
from openlp.core.lib import MediaManagerItem, Receiver, BaseListWithDnD, \
|
||||||
ItemCapabilities, translate
|
ItemCapabilities, translate
|
||||||
from openlp.core.lib.ui import critical_error_message_box, media_item_combo_box
|
from openlp.core.lib.ui import add_widget_completer, media_item_combo_box, \
|
||||||
|
critical_error_message_box
|
||||||
from openlp.plugins.bibles.forms import BibleImportForm
|
from openlp.plugins.bibles.forms import BibleImportForm
|
||||||
from openlp.plugins.bibles.lib import get_reference_match
|
from openlp.plugins.bibles.lib import get_reference_match
|
||||||
|
|
||||||
|
@ -379,9 +380,7 @@ class BibleMediaItem(MediaManagerItem):
|
||||||
book_data = bibles[bible].get_books()
|
book_data = bibles[bible].get_books()
|
||||||
books = [book.name for book in book_data]
|
books = [book.name for book in book_data]
|
||||||
books.sort()
|
books.sort()
|
||||||
completer = QtGui.QCompleter(books)
|
add_widget_completer(books, self.quickSearchEdit)
|
||||||
completer.setCaseSensitivity(QtCore.Qt.CaseInsensitive)
|
|
||||||
self.quickSearchEdit.setCompleter(completer)
|
|
||||||
|
|
||||||
def onAdvancedVersionComboBox(self):
|
def onAdvancedVersionComboBox(self):
|
||||||
self.initialiseBible(
|
self.initialiseBible(
|
||||||
|
|
|
@ -38,7 +38,6 @@ class OpenSongBible(BibleDB):
|
||||||
"""
|
"""
|
||||||
OpenSong Bible format importer class.
|
OpenSong Bible format importer class.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, parent, **kwargs):
|
def __init__(self, parent, **kwargs):
|
||||||
"""
|
"""
|
||||||
Constructor to create and set up an instance of the OpenSongBible
|
Constructor to create and set up an instance of the OpenSongBible
|
||||||
|
@ -81,14 +80,13 @@ class OpenSongBible(BibleDB):
|
||||||
db_book.id,
|
db_book.id,
|
||||||
int(chapter.attrib[u'n'].split()[-1]),
|
int(chapter.attrib[u'n'].split()[-1]),
|
||||||
int(verse.attrib[u'n']),
|
int(verse.attrib[u'n']),
|
||||||
unicode(verse.text)
|
unicode(verse.text))
|
||||||
)
|
|
||||||
Receiver.send_message(u'openlp_process_events')
|
|
||||||
self.wizard.incrementProgressBar(unicode(translate(
|
self.wizard.incrementProgressBar(unicode(translate(
|
||||||
'BiblesPlugin.Opensong', 'Importing %s %s...',
|
'BiblesPlugin.Opensong', 'Importing %s %s...',
|
||||||
'Importing <book name> <chapter>...')) %
|
'Importing <book name> <chapter>...')) %
|
||||||
(db_book.name, int(chapter.attrib[u'n'].split()[-1])))
|
(db_book.name, int(chapter.attrib[u'n'].split()[-1])))
|
||||||
self.session.commit()
|
self.session.commit()
|
||||||
|
Receiver.send_message(u'openlp_process_events')
|
||||||
except (IOError, AttributeError):
|
except (IOError, AttributeError):
|
||||||
log.exception(u'Loading bible from OpenSong file failed')
|
log.exception(u'Loading bible from OpenSong file failed')
|
||||||
success = False
|
success = False
|
||||||
|
|
|
@ -69,7 +69,7 @@ class CustomMediaItem(MediaManagerItem):
|
||||||
QtCore.SIGNAL(u'custom_preview'), self.onPreviewClick)
|
QtCore.SIGNAL(u'custom_preview'), self.onPreviewClick)
|
||||||
|
|
||||||
def initialise(self):
|
def initialise(self):
|
||||||
self.loadCustomListView(self.manager.get_all_objects(
|
self.loadList(self.manager.get_all_objects(
|
||||||
CustomSlide, order_by_ref=CustomSlide.title))
|
CustomSlide, order_by_ref=CustomSlide.title))
|
||||||
# Called to redisplay the custom list screen edith from a search
|
# Called to redisplay the custom list screen edith from a search
|
||||||
# or from the exit of the Custom edit dialog. If remote editing is
|
# or from the exit of the Custom edit dialog. If remote editing is
|
||||||
|
@ -80,7 +80,7 @@ class CustomMediaItem(MediaManagerItem):
|
||||||
self.onPreviewClick()
|
self.onPreviewClick()
|
||||||
self.onRemoteEditClear()
|
self.onRemoteEditClear()
|
||||||
|
|
||||||
def loadCustomListView(self, list):
|
def loadList(self, list):
|
||||||
self.listView.clear()
|
self.listView.clear()
|
||||||
for customSlide in list:
|
for customSlide in list:
|
||||||
custom_name = QtGui.QListWidgetItem(customSlide.title)
|
custom_name = QtGui.QListWidgetItem(customSlide.title)
|
||||||
|
|
|
@ -30,7 +30,7 @@ import re
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
from openlp.core.lib import Receiver, translate
|
from openlp.core.lib import Receiver, translate
|
||||||
from openlp.core.lib.ui import critical_error_message_box
|
from openlp.core.lib.ui import add_widget_completer, critical_error_message_box
|
||||||
from openlp.plugins.songs.forms import EditVerseForm
|
from openlp.plugins.songs.forms import EditVerseForm
|
||||||
from openlp.plugins.songs.lib import SongXML, VerseType
|
from openlp.plugins.songs.lib import SongXML, VerseType
|
||||||
from openlp.plugins.songs.lib.db import Book, Song, Author, Topic
|
from openlp.plugins.songs.lib.db import Book, Song, Author, Topic
|
||||||
|
@ -129,37 +129,26 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||||
self.authorsComboBox.setItemData(
|
self.authorsComboBox.setItemData(
|
||||||
row, QtCore.QVariant(author.id))
|
row, QtCore.QVariant(author.id))
|
||||||
self.authors.append(author.display_name)
|
self.authors.append(author.display_name)
|
||||||
completer = QtGui.QCompleter(self.authors)
|
add_widget_completer(self.authors, self.authorsComboBox)
|
||||||
completer.setCaseSensitivity(QtCore.Qt.CaseInsensitive)
|
|
||||||
self.authorsComboBox.setCompleter(completer)
|
|
||||||
|
|
||||||
def loadTopics(self):
|
def loadTopics(self):
|
||||||
topics = self.manager.get_all_objects(Topic, order_by_ref=Topic.name)
|
|
||||||
self.topicsComboBox.clear()
|
|
||||||
self.topicsComboBox.addItem(u'')
|
|
||||||
self.topics = []
|
self.topics = []
|
||||||
for topic in topics:
|
self.__loadObjects(Topic, self.topicsComboBox, self.topics)
|
||||||
row = self.topicsComboBox.count()
|
|
||||||
self.topicsComboBox.addItem(topic.name)
|
|
||||||
self.topics.append(topic.name)
|
|
||||||
self.topicsComboBox.setItemData(row, QtCore.QVariant(topic.id))
|
|
||||||
completer = QtGui.QCompleter(self.topics)
|
|
||||||
completer.setCaseSensitivity(QtCore.Qt.CaseInsensitive)
|
|
||||||
self.topicsComboBox.setCompleter(completer)
|
|
||||||
|
|
||||||
def loadBooks(self):
|
def loadBooks(self):
|
||||||
books = self.manager.get_all_objects(Book, order_by_ref=Book.name)
|
|
||||||
self.songBookComboBox.clear()
|
|
||||||
self.songBookComboBox.addItem(u'')
|
|
||||||
self.books = []
|
self.books = []
|
||||||
for book in books:
|
self.__loadObjects(Book, self.songBookComboBox, self.books)
|
||||||
row = self.songBookComboBox.count()
|
|
||||||
self.songBookComboBox.addItem(book.name)
|
def __loadObjects(self, cls, combo, cache):
|
||||||
self.books.append(book.name)
|
objects = self.manager.get_all_objects(cls, order_by_ref=cls.name)
|
||||||
self.songBookComboBox.setItemData(row, QtCore.QVariant(book.id))
|
combo.clear()
|
||||||
completer = QtGui.QCompleter(self.books)
|
combo.addItem(u'')
|
||||||
completer.setCaseSensitivity(QtCore.Qt.CaseInsensitive)
|
for object in objects:
|
||||||
self.songBookComboBox.setCompleter(completer)
|
row = combo.count()
|
||||||
|
combo.addItem(object.name)
|
||||||
|
cache.append(object.name)
|
||||||
|
combo.setItemData(row, QtCore.QVariant(object.id))
|
||||||
|
add_widget_completer(cache, combo)
|
||||||
|
|
||||||
def loadThemes(self, theme_list):
|
def loadThemes(self, theme_list):
|
||||||
self.themeComboBox.clear()
|
self.themeComboBox.clear()
|
||||||
|
@ -168,9 +157,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||||
for theme in theme_list:
|
for theme in theme_list:
|
||||||
self.themeComboBox.addItem(theme)
|
self.themeComboBox.addItem(theme)
|
||||||
self.themes.append(theme)
|
self.themes.append(theme)
|
||||||
completer = QtGui.QCompleter(self.themes)
|
add_widget_completer(self.themes, self.themeComboBox)
|
||||||
completer.setCaseSensitivity(QtCore.Qt.CaseInsensitive)
|
|
||||||
self.themeComboBox.setCompleter(completer)
|
|
||||||
|
|
||||||
def newSong(self):
|
def newSong(self):
|
||||||
log.debug(u'New Song')
|
log.debug(u'New Song')
|
||||||
|
|
Loading…
Reference in New Issue