openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #19857
[Merge] lp:~martin-hosken/openlp/subsearch into lp:openlp
mhosken has proposed merging lp:~martin-hosken/openlp/subsearch into lp:openlp.
Requested reviews:
OpenLP Core (openlp-core)
For more details, see:
https://code.launchpad.net/~martin-hosken/openlp/subsearch/+merge/152301
This adds a feature whereby a user can constrain their search of songs in the song database to those already in the search results list. This allows for a user to slowly refine their search, homing in on what they want to find. It is a feature I have often desired while preparing services and trying to track down the perfect song ;)
--
https://code.launchpad.net/~martin-hosken/openlp/subsearch/+merge/152301
Your team OpenLP Core is requested to review the proposed merge of lp:~martin-hosken/openlp/subsearch into lp:openlp.
=== modified file 'openlp/.version'
--- openlp/.version 2013-01-08 20:44:56 +0000
+++ openlp/.version 2013-03-07 22:45:38 +0000
@@ -1,1 +1,1 @@
-2.1.0-bzr2141
+2.1.0-bzr2201
\ No newline at end of file
=== modified file 'openlp/plugins/songs/lib/mediaitem.py'
--- openlp/plugins/songs/lib/mediaitem.py 2013-02-24 18:13:50 +0000
+++ openlp/plugins/songs/lib/mediaitem.py 2013-03-07 22:45:38 +0000
@@ -78,6 +78,7 @@
self.editItem = None
self.quickPreviewAllowed = True
self.hasSearch = True
+ self.searchResults = []
def _updateBackgroundAudio(self, song, item):
song.media_files = []
@@ -98,6 +99,9 @@
icon=':/songs/song_maintenance.png',
triggers=self.onSongMaintenanceClick)
self.addSearchToToolBar()
+ self.searchSubCheck = QtGui.QCheckBox()
+ self.searchSubCheck.setObjectName(u'searchSubCheckBox')
+ self.searchButtonLayout.insertWidget(0, self.searchSubCheck)
# Signals and slots
Registry().register_function(u'songs_load_list', self.on_song_list_load)
Registry().register_function(u'config_updated', self.config_update)
@@ -123,6 +127,7 @@
def retranslateUi(self):
self.searchTextLabel.setText(u'%s:' % UiStrings().Search)
self.searchTextButton.setText(UiStrings().Search)
+ self.searchSubCheck.setText(SongStrings.SubSearch)
self.maintenanceAction.setText(SongStrings.SongMaintenance)
self.maintenanceAction.setToolTip(translate('SongsPlugin.MediaItem',
'Maintain the lists of authors, topics and books.'))
@@ -151,6 +156,7 @@
def onSearchTextButtonClicked(self):
# Save the current search type to the configuration.
Settings().setValue(u'%s/last search type' % self.settingsSection, self.searchTextEdit.currentSearchType())
+ subSearch = self.searchSubCheck.isChecked()
# Reload the list considering the new search type.
search_keywords = unicode(self.searchTextEdit.displayText())
search_results = []
@@ -158,26 +164,31 @@
if search_type == SongSearch.Entire:
log.debug(u'Entire Song Search')
search_results = self.searchEntire(search_keywords)
+ if subSearch : search_results = self.constrainSearch(search_results)
self.displayResultsSong(search_results)
elif search_type == SongSearch.Titles:
log.debug(u'Titles Search')
search_results = self.plugin.manager.get_all_objects(Song,
Song.search_title.like(u'%' + clean_string(search_keywords) + u'%'))
+ if subSearch : search_results = self.constrainSearch(search_results)
self.displayResultsSong(search_results)
elif search_type == SongSearch.Lyrics:
log.debug(u'Lyrics Search')
search_results = self.plugin.manager.get_all_objects(Song,
Song.search_lyrics.like(u'%' + clean_string(search_keywords) + u'%'))
+ if subSearch : search_results = self.constrainSearch(search_results)
self.displayResultsSong(search_results)
elif search_type == SongSearch.Authors:
log.debug(u'Authors Search')
search_results = self.plugin.manager.get_all_objects(Author,
Author.display_name.like(u'%' + search_keywords + u'%'), Author.display_name.asc())
+ if subSearch : search_results = self.constrainSearch(search_results)
self.displayResultsAuthor(search_results)
elif search_type == SongSearch.Books:
log.debug(u'Books Search')
search_results = self.plugin.manager.get_all_objects(Book,
Book.name.like(u'%' + search_keywords + u'%'), Book.name.asc())
+ if subSearch : search_results = self.constrainSearch(search_results)
song_number = False
if not search_results:
search_keywords = search_keywords.rpartition(' ')
@@ -189,8 +200,11 @@
log.debug(u'Theme Search')
search_results = self.plugin.manager.get_all_objects(Song,
Song.theme_name.like(u'%' + search_keywords + u'%'))
+ if subSearch : search_results = self.constrainSearch(search_results)
self.displayResultsSong(search_results)
+ self.searchResults = search_results
self.checkSearchResult()
+ self.searchSubCheck.setChecked(False)
def searchEntire(self, search_keywords):
return self.plugin.manager.get_all_objects(Song,
@@ -198,6 +212,11 @@
Song.search_lyrics.like(u'%' + clean_string(search_keywords) + u'%'),
Song.comments.like(u'%' + search_keywords.lower() + u'%')))
+ def constrainSearch(self, search_results) :
+ testset = set(self.searchResults)
+ res = [x for x in search_results if x in testset]
+ return res
+
def on_song_list_load(self):
"""
Handle the exit from the edit dialog and trigger remote updates
=== modified file 'openlp/plugins/songs/lib/ui.py'
--- openlp/plugins/songs/lib/ui.py 2013-01-06 17:25:49 +0000
+++ openlp/plugins/songs/lib/ui.py 2013-03-07 22:45:38 +0000
@@ -45,6 +45,7 @@
SongBooks = translate('OpenLP.Ui', 'Song Books', 'Plural')
SongIncomplete = translate('OpenLP.Ui','Title and/or verses not found')
SongMaintenance = translate('OpenLP.Ui', 'Song Maintenance')
+ SubSearch = translate('OpenLP.Ui', 'Search existing results')
Topic = translate('OpenLP.Ui', 'Topic', 'Singular')
Topics = translate('OpenLP.Ui', 'Topics', 'Plural')
XMLSyntaxError = translate('OpenLP.Ui', 'XML syntax error')
Follow ups