Merge lp:~trb143/openlp/servicing2 into lp:openlp
- servicing2
- Merge into trunk
Proposed by
Tim Bentley
Status: | Merged |
---|---|
Merged at revision: | not available |
Proposed branch: | lp:~trb143/openlp/servicing2 |
Merge into: | lp:openlp |
Diff against target: | None lines |
To merge this branch: | bzr merge lp:~trb143/openlp/servicing2 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Raoul Snyman | Approve | ||
Review via email: mp+7735@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message
Tim Bentley (trb143) wrote : | # |
Revision history for this message
Raoul Snyman (raoul-snyman) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'openlp/core/lib/songxmlhandler.py' | |||
2 | --- openlp/core/lib/songxmlhandler.py 2009-06-16 18:21:24 +0000 | |||
3 | +++ openlp/core/lib/songxmlhandler.py 2009-06-21 16:26:33 +0000 | |||
4 | @@ -29,6 +29,7 @@ | |||
5 | 29 | </song> | 29 | </song> |
6 | 30 | 30 | ||
7 | 31 | """ | 31 | """ |
8 | 32 | import logging | ||
9 | 32 | from xml.dom.minidom import Document | 33 | from xml.dom.minidom import Document |
10 | 33 | from xml.etree.ElementTree import ElementTree, XML, dump | 34 | from xml.etree.ElementTree import ElementTree, XML, dump |
11 | 34 | 35 | ||
12 | @@ -70,11 +71,20 @@ | |||
13 | 70 | 71 | ||
14 | 71 | def extract_xml(self): | 72 | def extract_xml(self): |
15 | 72 | # Print our newly created XML | 73 | # Print our newly created XML |
17 | 73 | return self.song_xml.toxml() | 74 | return self.song_xml.toxml(u'utf-8') |
18 | 74 | 75 | ||
19 | 75 | class SongXMLParser(): | 76 | class SongXMLParser(): |
20 | 77 | global log | ||
21 | 78 | log = logging.getLogger(u'SongXMLParser') | ||
22 | 79 | log.info(u'SongXMLParser Loaded') | ||
23 | 80 | |||
24 | 76 | def __init__(self, xml): | 81 | def __init__(self, xml): |
26 | 77 | self.song_xml = ElementTree(element=XML(xml)) | 82 | #print xml |
27 | 83 | try: | ||
28 | 84 | self.song_xml = ElementTree(element=XML(xml)) | ||
29 | 85 | except: | ||
30 | 86 | #print "invalid xml ", xml | ||
31 | 87 | log.debug(u'invalid xml %s', xml) | ||
32 | 78 | 88 | ||
33 | 79 | def get_verses(self): | 89 | def get_verses(self): |
34 | 80 | #return a list of verse's and attributes | 90 | #return a list of verse's and attributes |
35 | 81 | 91 | ||
36 | === modified file 'openlp/core/ui/slidecontroller.py' | |||
37 | --- openlp/core/ui/slidecontroller.py 2009-06-20 10:44:12 +0000 | |||
38 | +++ openlp/core/ui/slidecontroller.py 2009-06-21 16:26:33 +0000 | |||
39 | @@ -21,14 +21,11 @@ | |||
40 | 21 | import os | 21 | import os |
41 | 22 | 22 | ||
42 | 23 | from PyQt4 import QtCore, QtGui | 23 | from PyQt4 import QtCore, QtGui |
43 | 24 | |||
44 | 25 | from openlp.core.lib import OpenLPToolbar, translate | 24 | from openlp.core.lib import OpenLPToolbar, translate |
45 | 26 | 25 | ||
46 | 27 | class SlideData(QtCore.QAbstractListModel): | 26 | class SlideData(QtCore.QAbstractListModel): |
47 | 28 | """ | 27 | """ |
51 | 29 | Tree of items for an order of Theme. | 28 | List of frames to be displayed on the list and the main display. |
49 | 30 | Includes methods for reading and writing the contents to an OOS file | ||
50 | 31 | Root contains a list of ThemeItems | ||
52 | 32 | """ | 29 | """ |
53 | 33 | global log | 30 | global log |
54 | 34 | log = logging.getLogger(u'SlideData') | 31 | log = logging.getLogger(u'SlideData') |
55 | @@ -98,6 +95,24 @@ | |||
56 | 98 | filelist = [item[3] for item in self.items]; | 95 | filelist = [item[3] for item in self.items]; |
57 | 99 | return filelist | 96 | return filelist |
58 | 100 | 97 | ||
59 | 98 | class SlideList(QtGui.QListView): | ||
60 | 99 | |||
61 | 100 | def __init__(self,parent=None,name=None): | ||
62 | 101 | QtGui.QListView.__init__(self,parent.Controller) | ||
63 | 102 | self.parent = parent | ||
64 | 103 | |||
65 | 104 | def keyPressEvent(self, event): | ||
66 | 105 | if type(event) == QtGui.QKeyEvent: | ||
67 | 106 | #here accept the event and do something | ||
68 | 107 | if event.key() == QtCore.Qt.Key_PageUp: | ||
69 | 108 | self.parent.onSlideSelectedPrevious() | ||
70 | 109 | event.accept() | ||
71 | 110 | elif event.key() == QtCore.Qt.Key_PageDown: | ||
72 | 111 | self.parent.onSlideSelectedNext() | ||
73 | 112 | event.accept() | ||
74 | 113 | event.ignore() | ||
75 | 114 | else: | ||
76 | 115 | event.ignore() | ||
77 | 101 | 116 | ||
78 | 102 | class SlideController(QtGui.QWidget): | 117 | class SlideController(QtGui.QWidget): |
79 | 103 | """ | 118 | """ |
80 | @@ -132,7 +147,7 @@ | |||
81 | 132 | self.ControllerLayout.setSpacing(0) | 147 | self.ControllerLayout.setSpacing(0) |
82 | 133 | self.ControllerLayout.setMargin(0) | 148 | self.ControllerLayout.setMargin(0) |
83 | 134 | # Controller list view | 149 | # Controller list view |
85 | 135 | self.PreviewListView = QtGui.QListView(self.Controller) | 150 | self.PreviewListView = SlideList(self) |
86 | 136 | self.PreviewListView.setUniformItemSizes(True) | 151 | self.PreviewListView.setUniformItemSizes(True) |
87 | 137 | self.PreviewListView.setIconSize(QtCore.QSize(250, 190)) | 152 | self.PreviewListView.setIconSize(QtCore.QSize(250, 190)) |
88 | 138 | self.PreviewListData = SlideData() | 153 | self.PreviewListData = SlideData() |
89 | @@ -210,6 +225,11 @@ | |||
90 | 210 | QtCore.SIGNAL(u'clicked(QModelIndex)'), self.onSlideSelected) | 225 | QtCore.SIGNAL(u'clicked(QModelIndex)'), self.onSlideSelected) |
91 | 211 | QtCore.QObject.connect(self.PreviewListView, | 226 | QtCore.QObject.connect(self.PreviewListView, |
92 | 212 | QtCore.SIGNAL(u'activated(QModelIndex)'), self.onSlideSelected) | 227 | QtCore.SIGNAL(u'activated(QModelIndex)'), self.onSlideSelected) |
93 | 228 | QtCore.QObject.connect(self.PreviewListView, | ||
94 | 229 | QtCore.SIGNAL(u'entered(QModelIndex)'), self.onTest) | ||
95 | 230 | |||
96 | 231 | def onTest(self , item): | ||
97 | 232 | print "found", item | ||
98 | 213 | 233 | ||
99 | 214 | def onSlideSelectedFirst(self): | 234 | def onSlideSelectedFirst(self): |
100 | 215 | """ | 235 | """ |
101 | 216 | 236 | ||
102 | === modified file 'openlp/plugins/songs/lib/manager.py' | |||
103 | --- openlp/plugins/songs/lib/manager.py 2009-06-14 13:50:56 +0000 | |||
104 | +++ openlp/plugins/songs/lib/manager.py 2009-06-21 17:45:59 +0000 | |||
105 | @@ -60,8 +60,8 @@ | |||
106 | 60 | metadata.create_all() | 60 | metadata.create_all() |
107 | 61 | log.debug(u'Song Initialised') | 61 | log.debug(u'Song Initialised') |
108 | 62 | 62 | ||
111 | 63 | def process_dialog(self, dialogobject): | 63 | # def process_dialog(self, dialogobject): |
112 | 64 | self.dialogobject = dialogobject | 64 | # self.dialogobject = dialogobject |
113 | 65 | 65 | ||
114 | 66 | def get_songs(self): | 66 | def get_songs(self): |
115 | 67 | """ | 67 | """ |
116 | @@ -81,6 +81,12 @@ | |||
117 | 81 | """ | 81 | """ |
118 | 82 | return self.session.query(Song).filter(Song.search_lyrics.like(u'%' + keywords + u'%')).order_by(Song.search_lyrics.asc()).all() | 82 | return self.session.query(Song).filter(Song.search_lyrics.like(u'%' + keywords + u'%')).order_by(Song.search_lyrics.asc()).all() |
119 | 83 | 83 | ||
120 | 84 | def get_song_from_author(self, keywords): | ||
121 | 85 | """ | ||
122 | 86 | Searches the song authors for keywords. | ||
123 | 87 | """ | ||
124 | 88 | return self.session.query(Author).filter(Author.display_name.like(u'%' + keywords + u'%')).order_by(Author.display_name.asc()).all() | ||
125 | 89 | |||
126 | 84 | def get_song(self, id=None): | 90 | def get_song(self, id=None): |
127 | 85 | """ | 91 | """ |
128 | 86 | Returns the details of a song | 92 | Returns the details of a song |
129 | 87 | 93 | ||
130 | === modified file 'openlp/plugins/songs/lib/mediaitem.py' | |||
131 | --- openlp/plugins/songs/lib/mediaitem.py 2009-06-19 18:41:38 +0000 | |||
132 | +++ openlp/plugins/songs/lib/mediaitem.py 2009-06-21 17:45:59 +0000 | |||
133 | @@ -160,8 +160,25 @@ | |||
134 | 160 | self.SearchTypeComboBox.addItem(translate(u'SongMediaItem', u'Lyrics')) | 160 | self.SearchTypeComboBox.addItem(translate(u'SongMediaItem', u'Lyrics')) |
135 | 161 | self.SearchTypeComboBox.addItem(translate(u'SongMediaItem', u'Authors')) | 161 | self.SearchTypeComboBox.addItem(translate(u'SongMediaItem', u'Authors')) |
136 | 162 | 162 | ||
139 | 163 | def displayResults(self, searchresults): | 163 | def onSearchTextButtonClick(self): |
140 | 164 | log.debug(u'display results') | 164 | search_keywords = unicode(self.SearchTextEdit.displayText()) |
141 | 165 | search_results = [] | ||
142 | 166 | search_type = self.SearchTypeComboBox.currentIndex() | ||
143 | 167 | if search_type == 0: | ||
144 | 168 | log.debug(u'Titles Search') | ||
145 | 169 | search_results = self.parent.songmanager.search_song_title(search_keywords) | ||
146 | 170 | self.displayResultsSong(search_results) | ||
147 | 171 | elif search_type == 1: | ||
148 | 172 | log.debug(u'Lyrics Search') | ||
149 | 173 | search_results = self.parent.songmanager.search_song_lyrics(search_keywords) | ||
150 | 174 | self.displayResultsSong(search_results) | ||
151 | 175 | elif search_type == 2: | ||
152 | 176 | log.debug(u'Authors Search') | ||
153 | 177 | search_results = self.parent.songmanager.get_song_from_author(search_keywords) | ||
154 | 178 | self.displayResultsAuthor(search_results) | ||
155 | 179 | |||
156 | 180 | def displayResultsSong(self, searchresults): | ||
157 | 181 | log.debug(u'display results Song') | ||
158 | 165 | self.SongListWidget.clear() | 182 | self.SongListWidget.clear() |
159 | 166 | #log.debug(u'Records returned from search %s", len(searchresults)) | 183 | #log.debug(u'Records returned from search %s", len(searchresults)) |
160 | 167 | for song in searchresults: | 184 | for song in searchresults: |
161 | @@ -175,6 +192,16 @@ | |||
162 | 175 | song_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(song.id)) | 192 | song_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(song.id)) |
163 | 176 | self.SongListWidget.addItem(song_name) | 193 | self.SongListWidget.addItem(song_name) |
164 | 177 | 194 | ||
165 | 195 | def displayResultsAuthor(self, searchresults): | ||
166 | 196 | log.debug(u'display results Author') | ||
167 | 197 | self.SongListWidget.clear() | ||
168 | 198 | for author in searchresults: | ||
169 | 199 | for song in author.songs: | ||
170 | 200 | song_detail = unicode(u'%s (%s)' % (unicode(author.display_name), unicode(song.title))) | ||
171 | 201 | song_name = QtGui.QListWidgetItem(song_detail) | ||
172 | 202 | song_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(song.id)) | ||
173 | 203 | self.SongListWidget.addItem(song_name) | ||
174 | 204 | |||
175 | 178 | def onClearTextButtonClick(self): | 205 | def onClearTextButtonClick(self): |
176 | 179 | """ | 206 | """ |
177 | 180 | Clear the search text. | 207 | Clear the search text. |
178 | @@ -188,21 +215,6 @@ | |||
179 | 188 | if len(text) > search_length: | 215 | if len(text) > search_length: |
180 | 189 | self.onSearchTextButtonClick() | 216 | self.onSearchTextButtonClick() |
181 | 190 | 217 | ||
182 | 191 | def onSearchTextButtonClick(self): | ||
183 | 192 | search_keywords = unicode(self.SearchTextEdit.displayText()) | ||
184 | 193 | search_results = [] | ||
185 | 194 | search_type = self.SearchTypeComboBox.currentIndex() | ||
186 | 195 | if search_type == 0: | ||
187 | 196 | log.debug(u'Titles Search') | ||
188 | 197 | search_results = self.parent.songmanager.search_song_title(search_keywords) | ||
189 | 198 | elif search_type == 1: | ||
190 | 199 | log.debug(u'Lyrics Search') | ||
191 | 200 | search_results = self.parent.songmanager.search_song_lyrics(search_keywords) | ||
192 | 201 | elif search_type == 2: | ||
193 | 202 | log.debug(u'Authors Search') | ||
194 | 203 | #searchresults = self.songmanager.get_song_from_author(searchtext) | ||
195 | 204 | self.displayResults(search_results) | ||
196 | 205 | |||
197 | 206 | def onSongNewClick(self): | 218 | def onSongNewClick(self): |
198 | 207 | self.edit_song_form.newSong() | 219 | self.edit_song_form.newSong() |
199 | 208 | self.edit_song_form.exec_() | 220 | self.edit_song_form.exec_() |
200 | 209 | 221 | ||
201 | === modified file 'openlp/plugins/songs/songsplugin.py' | |||
202 | --- openlp/plugins/songs/songsplugin.py 2009-06-16 18:21:24 +0000 | |||
203 | +++ openlp/plugins/songs/songsplugin.py 2009-06-21 17:45:59 +0000 | |||
204 | @@ -103,7 +103,7 @@ | |||
205 | 103 | QtCore.QObject.connect(self.ExportOpenSongItem, QtCore.SIGNAL(u'triggered()'), self.onExportOpenSongItemClicked) | 103 | QtCore.QObject.connect(self.ExportOpenSongItem, QtCore.SIGNAL(u'triggered()'), self.onExportOpenSongItemClicked) |
206 | 104 | 104 | ||
207 | 105 | def initialise(self): | 105 | def initialise(self): |
209 | 106 | self.media_item.displayResults(self.songmanager.get_songs()) | 106 | self.media_item.displayResultsSong(self.songmanager.get_songs()) |
210 | 107 | 107 | ||
211 | 108 | def onImportOpenlp1ItemClick(self): | 108 | def onImportOpenlp1ItemClick(self): |
212 | 109 | self.openlp_import_form.show() | 109 | self.openlp_import_form.show() |
213 | @@ -136,4 +136,4 @@ | |||
214 | 136 | self.media_item.onSongLiveClick() | 136 | self.media_item.onSongLiveClick() |
215 | 137 | if event.event_type == EventType.LoadSongList : | 137 | if event.event_type == EventType.LoadSongList : |
216 | 138 | log.debug(u'Load Load Song List Item received') | 138 | log.debug(u'Load Load Song List Item received') |
217 | 139 | self.media_item.displayResults(self.songmanager.get_songs()) | ||
218 | 140 | \ No newline at end of file | 139 | \ No newline at end of file |
219 | 140 | self.media_item.displayResults(self.songmanager.get_songs()) |
Add Author Search to Songs plugin
Add Page_up/Down to SlideController