forked from openlp/openlp
Add Autocompletion for Authors and Themes
This commit is contained in:
parent
9d1eabe2a2
commit
bc0ca88af5
@ -61,6 +61,14 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||||||
QtCore.QObject.connect(self.AuthorsListView,
|
QtCore.QObject.connect(self.AuthorsListView,
|
||||||
QtCore.SIGNAL(u'itemClicked(QListWidgetItem*)'),
|
QtCore.SIGNAL(u'itemClicked(QListWidgetItem*)'),
|
||||||
self.onAuthorsListViewPressed)
|
self.onAuthorsListViewPressed)
|
||||||
|
QtCore.QObject.connect(self.AuthorsSelectionComboItem,
|
||||||
|
QtCore.SIGNAL(u'activated(int)'), self.updateAuthorAutoCompleter)
|
||||||
|
QtCore.QObject.connect(self.AuthorsSelectionComboItem,
|
||||||
|
QtCore.SIGNAL(u'activated(int)'), self.updateAuthorAutoCompleter)#
|
||||||
|
QtCore.QObject.connect(self.ThemeSelectionComboItem,
|
||||||
|
QtCore.SIGNAL(u'activated(int)'), self.updateAuthorAutoCompleter)
|
||||||
|
QtCore.QObject.connect(self.ThemeSelectionComboItem,
|
||||||
|
QtCore.SIGNAL(u'activated(int)'), self.updateThemeAutoCompleter)
|
||||||
QtCore.QObject.connect(self.TopicAddButton,
|
QtCore.QObject.connect(self.TopicAddButton,
|
||||||
QtCore.SIGNAL(u'clicked()'), self.onTopicAddButtonClicked)
|
QtCore.SIGNAL(u'clicked()'), self.onTopicAddButtonClicked)
|
||||||
QtCore.QObject.connect(self.TopicRemoveButton,
|
QtCore.QObject.connect(self.TopicRemoveButton,
|
||||||
@ -119,12 +127,23 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||||||
authors = self.manager.get_all_objects(Author,
|
authors = self.manager.get_all_objects(Author,
|
||||||
order_by_ref=Author.display_name)
|
order_by_ref=Author.display_name)
|
||||||
self.AuthorsSelectionComboItem.clear()
|
self.AuthorsSelectionComboItem.clear()
|
||||||
self.AuthorsSelectionComboItem.addItem(u'')
|
self.AuthorsSelectionComboItem.addItem(u'')#
|
||||||
|
self.authors = []
|
||||||
for author in authors:
|
for author in authors:
|
||||||
row = self.AuthorsSelectionComboItem.count()
|
row = self.AuthorsSelectionComboItem.count()
|
||||||
self.AuthorsSelectionComboItem.addItem(author.display_name)
|
self.AuthorsSelectionComboItem.addItem(author.display_name)
|
||||||
self.AuthorsSelectionComboItem.setItemData(
|
self.AuthorsSelectionComboItem.setItemData(
|
||||||
row, QtCore.QVariant(author.id))
|
row, QtCore.QVariant(author.id))
|
||||||
|
self.authors.append(author.display_name)
|
||||||
|
self.updateAuthorAutoCompleter()
|
||||||
|
|
||||||
|
def updateAuthorAutoCompleter(self):
|
||||||
|
"""
|
||||||
|
This updates the author completion list for the search field.
|
||||||
|
"""
|
||||||
|
completer = QtGui.QCompleter(self.authors)
|
||||||
|
completer.setCaseSensitivity(QtCore.Qt.CaseInsensitive)
|
||||||
|
self.AuthorsSelectionComboItem.setCompleter(completer)
|
||||||
|
|
||||||
def loadTopics(self):
|
def loadTopics(self):
|
||||||
topics = self.manager.get_all_objects(Topic, order_by_ref=Topic.name)
|
topics = self.manager.get_all_objects(Topic, order_by_ref=Topic.name)
|
||||||
@ -147,8 +166,19 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||||||
def loadThemes(self, theme_list):
|
def loadThemes(self, theme_list):
|
||||||
self.ThemeSelectionComboItem.clear()
|
self.ThemeSelectionComboItem.clear()
|
||||||
self.ThemeSelectionComboItem.addItem(u'')
|
self.ThemeSelectionComboItem.addItem(u'')
|
||||||
|
self.themes = []
|
||||||
for theme in theme_list:
|
for theme in theme_list:
|
||||||
self.ThemeSelectionComboItem.addItem(theme)
|
self.ThemeSelectionComboItem.addItem(theme)
|
||||||
|
self.themes.append(theme)
|
||||||
|
self.updateThemeAutoCompleter()
|
||||||
|
|
||||||
|
def updateThemeAutoCompleter(self):
|
||||||
|
"""
|
||||||
|
This updates the theme completion list for the search field.
|
||||||
|
"""
|
||||||
|
completer = QtGui.QCompleter(self.themes)
|
||||||
|
completer.setCaseSensitivity(QtCore.Qt.CaseInsensitive)
|
||||||
|
self.ThemeSelectionComboItem.setCompleter(completer)
|
||||||
|
|
||||||
def newSong(self):
|
def newSong(self):
|
||||||
log.debug(u'New Song')
|
log.debug(u'New Song')
|
||||||
|
Loading…
Reference in New Issue
Block a user