Enable auto-select for all searches when item previously selected

This commit is contained in:
Chris Hill 2016-04-12 21:17:12 +01:00
parent 743a916292
commit dfb34a5156

View File

@ -284,6 +284,7 @@ class SongMediaItem(MediaManagerItem):
:return: None
"""
log.debug('display results Author')
self.save_auto_select_id()
self.list_view.clear()
search_results.sort(key=lambda author: get_natural_key(author.display_name))
for author in search_results:
@ -296,6 +297,10 @@ class SongMediaItem(MediaManagerItem):
song_name = QtWidgets.QListWidgetItem(song_detail)
song_name.setData(QtCore.Qt.UserRole, song.id)
self.list_view.addItem(song_name)
# Auto-select the item if name has been set
if song.id == self.auto_select_id:
self.list_view.setCurrentItem(song_name)
self.auto_select_id = -1
def display_results_book(self, search_results):
"""
@ -305,6 +310,7 @@ class SongMediaItem(MediaManagerItem):
:return: None
"""
log.debug('display results Book')
self.save_auto_select_id()
self.list_view.clear()
search_results.sort(key=lambda songbook_entry:
(get_natural_key(songbook_entry.songbook.name), get_natural_key(songbook_entry.entry)))
@ -315,6 +321,10 @@ class SongMediaItem(MediaManagerItem):
song_name = QtWidgets.QListWidgetItem(song_detail)
song_name.setData(QtCore.Qt.UserRole, songbook_entry.song.id)
self.list_view.addItem(song_name)
# Auto-select the item if name has been set
if songbook_entry.song.id == self.auto_select_id:
self.list_view.setCurrentItem(song_name)
self.auto_select_id = -1
def display_results_topic(self, search_results):
"""
@ -324,6 +334,7 @@ class SongMediaItem(MediaManagerItem):
:return: None
"""
log.debug('display results Topic')
self.save_auto_select_id()
self.list_view.clear()
search_results.sort(key=lambda topic: get_natural_key(topic.name))
for topic in search_results:
@ -336,6 +347,10 @@ class SongMediaItem(MediaManagerItem):
song_name = QtWidgets.QListWidgetItem(song_detail)
song_name.setData(QtCore.Qt.UserRole, song.id)
self.list_view.addItem(song_name)
# Auto-select the item if name has been set
if song.id == self.auto_select_id:
self.list_view.setCurrentItem(song_name)
self.auto_select_id = -1
def display_results_themes(self, search_results):
"""
@ -345,6 +360,7 @@ class SongMediaItem(MediaManagerItem):
:return: None
"""
log.debug('display results Themes')
self.save_auto_select_id()
self.list_view.clear()
search_results.sort(key=lambda song: (get_natural_key(song.theme_name),
song.sort_key))
@ -356,6 +372,10 @@ class SongMediaItem(MediaManagerItem):
song_name = QtWidgets.QListWidgetItem(song_detail)
song_name.setData(QtCore.Qt.UserRole, song.id)
self.list_view.addItem(song_name)
# Auto-select the item if name has been set
if song.id == self.auto_select_id:
self.list_view.setCurrentItem(song_name)
self.auto_select_id = -1
def display_results_cclinumber(self, search_results):
"""
@ -365,6 +385,7 @@ class SongMediaItem(MediaManagerItem):
:return: None
"""
log.debug('display results CCLI number')
self.save_auto_select_id()
self.list_view.clear()
search_results.sort(key=lambda song: (get_natural_key(song.ccli_number),
song.sort_key))
@ -376,6 +397,10 @@ class SongMediaItem(MediaManagerItem):
song_name = QtWidgets.QListWidgetItem(song_detail)
song_name.setData(QtCore.Qt.UserRole, song.id)
self.list_view.addItem(song_name)
# Auto-select the item if name has been set
if song.id == self.auto_select_id:
self.list_view.setCurrentItem(song_name)
self.auto_select_id = -1
def on_clear_text_button_click(self):
"""