From 53fbd9efb13167f6ec032f86ef2d2173b41a0967 Mon Sep 17 00:00:00 2001 From: Chris Hill Date: Mon, 26 Jan 2015 12:53:23 +0000 Subject: [PATCH] partial fix bug #1000729 'Support more song fields in the search' - add copyright, CCLI number search, fix topic search, theme list Fixes: https://launchpad.net/bugs/1000729 --- openlp/plugins/songs/lib/mediaitem.py | 71 ++++++++++++++++++++----- resources/images/openlp-2.qrc | 2 + resources/images/song_search_ccli.png | Bin 0 -> 403 bytes resources/images/song_search_copy.png | Bin 0 -> 498 bytes resources/images/song_search_topic.png | Bin 724 -> 993 bytes 5 files changed, 60 insertions(+), 13 deletions(-) create mode 100644 resources/images/song_search_ccli.png create mode 100644 resources/images/song_search_copy.png diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 89092aa92..d2cbad3c1 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -26,7 +26,7 @@ import os import shutil from PyQt4 import QtCore, QtGui -from sqlalchemy.sql import or_ +from sqlalchemy.sql import and_, or_ from openlp.core.common import Registry, AppLocation, Settings, check_directory_exists, UiStrings, translate from openlp.core.lib import MediaManagerItem, ItemCapabilities, PluginStatus, ServiceItemContext, \ @@ -52,9 +52,11 @@ class SongSearch(object): Titles = 2 Lyrics = 3 Authors = 4 - Books = 5 - Topics = 6 + Topics = 5 + Books = 6 Themes = 7 + Copyright = 8 + CCLInumber = 9 class SongMediaItem(MediaManagerItem): @@ -148,11 +150,17 @@ class SongMediaItem(MediaManagerItem): translate('SongsPlugin.MediaItem', 'Search Lyrics...')), (SongSearch.Authors, ':/songs/song_search_author.png', SongStrings.Authors, translate('SongsPlugin.MediaItem', 'Search Authors...')), - (SongSearch.Books, ':/songs/song_book_edit.png', SongStrings.SongBooks, - translate('SongsPlugin.MediaItem', 'Search Song Books...')), (SongSearch.Topics, ':/songs/song_search_topic.png', SongStrings.Topics, translate('SongsPlugin.MediaItem', 'Search Topics...')), - (SongSearch.Themes, ':/slides/slide_theme.png', UiStrings().Themes, UiStrings().SearchThemes) + (SongSearch.Books, ':/songs/song_book_edit.png', SongStrings.SongBooks, + translate('SongsPlugin.MediaItem', 'Search Song Books...')), + (SongSearch.Themes, ':/slides/slide_theme.png', UiStrings().Themes, UiStrings().SearchThemes), + (SongSearch.Copyright, ':/songs/song_search_copy.png', + translate('SongsPlugin.MediaItem', 'Copyright'), + translate('SongsPlugin.MediaItem', 'Search Copyright...')), + (SongSearch.CCLInumber, ':/songs/song_search_ccli.png', + translate('SongsPlugin.MediaItem', 'CCLI number'), + translate('SongsPlugin.MediaItem', 'Search CCLI number...')) ]) self.search_text_edit.set_current_search_type(Settings().value('%s/last search type' % self.settings_section)) self.config_update() @@ -183,6 +191,12 @@ class SongMediaItem(MediaManagerItem): search_results = self.plugin.manager.get_all_objects( Author, Author.display_name.like(search_string), Author.display_name.asc()) self.display_results_author(search_results) + elif search_type == SongSearch.Topics: + log.debug('Topics Search') + search_string = '%' + search_keywords + '%' + search_results = self.plugin.manager.get_all_objects( + Topic, Topic.name.like(search_string), Topic.name.asc()) + self.display_results_topic(search_results) elif search_type == SongSearch.Books: log.debug('Books Search') search_string = '%' + search_keywords + '%' @@ -195,17 +209,24 @@ class SongMediaItem(MediaManagerItem): Book.name.like(search_string), Book.name.asc()) song_number = re.sub(r'[^0-9]', '', search_keywords[2]) self.display_results_book(search_results, song_number) - elif search_type == SongSearch.Topics: - log.debug('Topics Search') - search_string = '%' + search_keywords + '%' - search_results = self.plugin.manager.get_all_objects( - Topic, Topic.name.like(search_string), Topic.name.asc()) - self.display_results_topic(search_results) elif search_type == SongSearch.Themes: log.debug('Theme Search') search_string = '%' + search_keywords + '%' - search_results = self.plugin.manager.get_all_objects(Song, Song.theme_name.like(search_string)) + search_results = self.plugin.manager.get_all_objects( + Song, Song.theme_name.like(search_string), Song.theme_name.asc()) + self.display_results_themes(search_results) + elif search_type == SongSearch.Copyright: + log.debug('Copyright Search') + search_string = '%' + search_keywords + '%' + search_results = self.plugin.manager.get_all_objects( + Song, and_(Song.copyright.like(search_string), Song.copyright != '')) self.display_results_song(search_results) + elif search_type == SongSearch.CCLInumber: + log.debug('CCLI number Search') + search_string = '%' + search_keywords + '%' + search_results = self.plugin.manager.get_all_objects( + Song, and_(Song.ccli_number.like(search_string), Song.ccli_number != ''), Song.ccli_number.asc()) + self.display_results_cclinumber(search_results) self.check_search_result() def search_entire(self, search_keywords): @@ -289,6 +310,30 @@ class SongMediaItem(MediaManagerItem): song_name.setData(QtCore.Qt.UserRole, song.id) self.list_view.addItem(song_name) + def display_results_themes(self, search_results): + log.debug('display results Themes') + self.list_view.clear() + for song in search_results: + # Do not display temporary songs + if song.temporary: + continue + song_detail = '%s (%s)' % (song.theme_name, song.title) + song_name = QtGui.QListWidgetItem(song_detail) + song_name.setData(QtCore.Qt.UserRole, song.id) + self.list_view.addItem(song_name) + + def display_results_cclinumber(self, search_results): + log.debug('display results CCLI number') + self.list_view.clear() + for song in search_results: + # Do not display temporary songs + if song.temporary: + continue + song_detail = '%s (%s)' % (song.ccli_number, song.title) + song_name = QtGui.QListWidgetItem(song_detail) + song_name.setData(QtCore.Qt.UserRole, song.id) + self.list_view.addItem(song_name) + def on_clear_text_button_click(self): """ Clear the search text. diff --git a/resources/images/openlp-2.qrc b/resources/images/openlp-2.qrc index 77a878fc7..30ac036d3 100644 --- a/resources/images/openlp-2.qrc +++ b/resources/images/openlp-2.qrc @@ -2,6 +2,8 @@ song_search_all.png song_search_author.png + song_search_ccli.png + song_search_copy.png song_search_lyrics.png song_search_title.png song_search_topic.png diff --git a/resources/images/song_search_ccli.png b/resources/images/song_search_ccli.png new file mode 100644 index 0000000000000000000000000000000000000000..48be487f9f8b4c704286e93ea27cb4565b00917c GIT binary patch literal 403 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJbFq_W2nPqp?T7vkfLzW3kH}&M z2FBeW%xLxI@gtz1WQl7;NpOBzNqJ&XDnogBxn5>oc5!lIL8@MUQTpt6Hc~)EjR8I( zuK)l42QneRpibFqy;r~C=+UER&z`+}`SRVncb`9h z`S$JGcOdxr{l~8#KY#xG^XJdMfB%5CYwLE*16t2g666=mAY*4A$isCG$S?79aSW-r z)q4K4&_M?YmxuPY@5+P7a@RQ*dL$|@~-@k<0=2{1A*Is1K ja4mIWc!Q71m*RJ<@85~B#;ZvRgM!1;)z4*}Q$iB}T#dk8 literal 0 HcmV?d00001 diff --git a/resources/images/song_search_copy.png b/resources/images/song_search_copy.png new file mode 100644 index 0000000000000000000000000000000000000000..c4ac7d8068032435b062f33016f047fd111de90f GIT binary patch literal 498 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBugD~Uq{1qucL5ULAh?3y^w370~qEv>0#LT=By}Z;C1rt33 zJ=4@yqg0@w$(}BbAr}5iCkuu+2TB~*=V5DhG~j4*lwfIAkYEF1o_(a;P>iVEj{Oec+Rc+jYq6saGm0v6P*7<`YCUS!S-t>g|vFUKh1Q! zy^C9D%J(=doX8N0k6@<@Y69#PB$3#F6v3!%aE(_pYda~N7kxFi8KE>zdmL9 mqWn^8?bPgW*8hHDbqox#TTcmXloJI;34^DrpUXO@geCy#jLX>o literal 0 HcmV?d00001 diff --git a/resources/images/song_search_topic.png b/resources/images/song_search_topic.png index eb1f4c598d2cdc683ec659c397dc353d573e36b7..e506ff408ee65e4d27ab5688e6ea0ecfb72c6b7f 100644 GIT binary patch delta 971 zcmV;+12p{91>pyfB!3BTNLh0L05@C!05@C#%g3a-00006VoOIv0RI600RN!9r;`8x z15-&vK~xwSUBO>Wm1P_U@bB;Uyyt!4z&VFF9YzOGG9^VW+F7As;S{H^+;n5++G<6k zmfE^W*IIwJZi>qG3KQQ2@alD{eb1UFs_QDYIv!^NKe{~m+uWzy_qB}ud}fk9Idn|= zAMMAXzGpykQ?ToeZiomi%#_52w5sLt+RwA~6&saj#ZnBhL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