Merge lp:~trb143/openlp/bug-772523 into lp:openlp
- bug-772523
- Merge into trunk
Status: | Merged |
---|---|
Merged at revision: | 1833 |
Proposed branch: | lp:~trb143/openlp/bug-772523 |
Merge into: | lp:openlp |
Diff against target: |
349 lines (+91/-21) 11 files modified
openlp/core/lib/db.py (+8/-1) openlp/core/lib/eventreceiver.py (+4/-0) openlp/core/lib/serviceitem.py (+2/-0) openlp/core/ui/maindisplay.py (+2/-2) openlp/core/ui/servicemanager.py (+25/-6) openlp/plugins/songs/forms/songexportform.py (+3/-0) openlp/plugins/songs/lib/db.py (+2/-1) openlp/plugins/songs/lib/mediaitem.py (+15/-3) openlp/plugins/songs/lib/upgrade.py (+12/-1) openlp/plugins/songs/lib/xml.py (+6/-7) openlp/plugins/songs/songsplugin.py (+12/-0) |
To merge this branch: | bzr merge lp:~trb143/openlp/bug-772523 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Raoul Snyman | Approve | ||
Andreas Preikschat | Pending | ||
Review via email: mp+85370@code.launchpad.net |
This proposal supersedes a proposal from 2011-12-12.
Commit message
Description of the change
This patch changes your song database so back it up!
When a service is imported at present and we do not wish to save the songs we do not. This prevents the user from editing songs.
This change adds a "temporary" flag on the song database to allow those songs to be save and edited bit not via the plugin as the search will not show them.
On exit the songs will be deleted.
The code works until a service is loaded and then you get sqlalchemy errors.
I have no idea what is wrong but some help would be appreciated.
Amended code to add songs as per my email.
The code does set a correct value on existing databases.
Raoul Snyman (raoul-snyman) wrote : Posted in a previous version of this proposal | # |
Raoul Snyman (raoul-snyman) wrote : Posted in a previous version of this proposal | # |
You will need to set the default of the new column, something like this:
110 Column(
111 .create(
connection = metadata.
Raoul Snyman (raoul-snyman) wrote : Posted in a previous version of this proposal | # |
Are you going to add the setting of the default value of the new column?
Raoul Snyman (raoul-snyman) wrote : Posted in a previous version of this proposal | # |
This looks fine, I'll approve it, but I haven't tested it.
Andreas Preikschat (googol-deactivatedaccount) wrote : Posted in a previous version of this proposal | # |
1) delete your db
2) Open a service file ("Add missing songs ..." + "Update service...." enabled)
3) Disable "Add missing songs ..."
4) Restart OpenLP
5) Open the same service file
6) Edit the song in the media manager.
Result: Song in service manager is not updated.
Raoul Snyman (raoul-snyman) wrote : Posted in a previous version of this proposal | # |
This isn't all your code, but I did just need to point it out...
editId, self.loadItem_uuid, temporary = message.split(u':')
self.
self.
Um, two naming conventions in the same variable? It should either be self.load_
Also, is that first line backwards compatible with existing service files?
Tim Bentley (trb143) wrote : Posted in a previous version of this proposal | # |
Fully backwardly comparable.
I will do a rename tonight and resubmit.
Raoul Snyman (raoul-snyman) wrote : Posted in a previous version of this proposal | # |
158 + self.load_
Sorry, this one still has that "editId" instead of "edit_id".
Preview Diff
1 | === modified file 'openlp/core/lib/db.py' | |||
2 | --- openlp/core/lib/db.py 2011-12-03 12:51:40 +0000 | |||
3 | +++ openlp/core/lib/db.py 2011-12-12 18:05:26 +0000 | |||
4 | @@ -358,10 +358,17 @@ | |||
5 | 358 | 358 | ||
6 | 359 | def delete_all_objects(self, object_class, filter_clause=None): | 359 | def delete_all_objects(self, object_class, filter_clause=None): |
7 | 360 | """ | 360 | """ |
9 | 361 | Delete all object records | 361 | Delete all object records. |
10 | 362 | This method should only be used for simple tables and not ones with | ||
11 | 363 | relationships. The relationships are not deleted from the database and | ||
12 | 364 | this will lead to database corruptions. | ||
13 | 362 | 365 | ||
14 | 363 | ``object_class`` | 366 | ``object_class`` |
15 | 364 | The type of object to delete | 367 | The type of object to delete |
16 | 368 | |||
17 | 369 | ``filter_clause`` | ||
18 | 370 | The filter governing selection of objects to return. Defaults to | ||
19 | 371 | None. | ||
20 | 365 | """ | 372 | """ |
21 | 366 | try: | 373 | try: |
22 | 367 | query = self.session.query(object_class) | 374 | query = self.session.query(object_class) |
23 | 368 | 375 | ||
24 | === modified file 'openlp/core/lib/eventreceiver.py' | |||
25 | --- openlp/core/lib/eventreceiver.py 2011-10-22 11:28:47 +0000 | |||
26 | +++ openlp/core/lib/eventreceiver.py 2011-12-12 18:05:26 +0000 | |||
27 | @@ -115,8 +115,12 @@ | |||
28 | 115 | ``slidecontroller_live_stop_loop`` | 115 | ``slidecontroller_live_stop_loop`` |
29 | 116 | Stop the loop on the main display. | 116 | Stop the loop on the main display. |
30 | 117 | 117 | ||
31 | 118 | |||
32 | 118 | **Servicemanager related signals** | 119 | **Servicemanager related signals** |
33 | 119 | 120 | ||
34 | 121 | ``servicemanager_new_service`` | ||
35 | 122 | A new service is being loaded or created. | ||
36 | 123 | |||
37 | 120 | ``servicemanager_previous_item`` | 124 | ``servicemanager_previous_item`` |
38 | 121 | Display the previous item in the service. | 125 | Display the previous item in the service. |
39 | 122 | 126 | ||
40 | 123 | 127 | ||
41 | === modified file 'openlp/core/lib/serviceitem.py' | |||
42 | --- openlp/core/lib/serviceitem.py 2011-11-13 08:57:29 +0000 | |||
43 | +++ openlp/core/lib/serviceitem.py 2011-12-12 18:05:26 +0000 | |||
44 | @@ -119,6 +119,7 @@ | |||
45 | 119 | self.image_border = u'#000000' | 119 | self.image_border = u'#000000' |
46 | 120 | self.background_audio = [] | 120 | self.background_audio = [] |
47 | 121 | self.theme_overwritten = False | 121 | self.theme_overwritten = False |
48 | 122 | self.temporary_edit = False | ||
49 | 122 | self._new_item() | 123 | self._new_item() |
50 | 123 | 124 | ||
51 | 124 | def _new_item(self): | 125 | def _new_item(self): |
52 | @@ -365,6 +366,7 @@ | |||
53 | 365 | """ | 366 | """ |
54 | 366 | self._uuid = other._uuid | 367 | self._uuid = other._uuid |
55 | 367 | self.notes = other.notes | 368 | self.notes = other.notes |
56 | 369 | self.temporary_edit = other.temporary_edit | ||
57 | 368 | # Copy theme over if present. | 370 | # Copy theme over if present. |
58 | 369 | if other.theme is not None: | 371 | if other.theme is not None: |
59 | 370 | self.theme = other.theme | 372 | self.theme = other.theme |
60 | 371 | 373 | ||
61 | === modified file 'openlp/core/ui/maindisplay.py' | |||
62 | --- openlp/core/ui/maindisplay.py 2011-12-02 20:17:57 +0000 | |||
63 | +++ openlp/core/ui/maindisplay.py 2011-12-12 18:05:26 +0000 | |||
64 | @@ -45,7 +45,7 @@ | |||
65 | 45 | 45 | ||
66 | 46 | class Display(QtGui.QGraphicsView): | 46 | class Display(QtGui.QGraphicsView): |
67 | 47 | """ | 47 | """ |
69 | 48 | This is a general display screen class. Here the general display settings | 48 | This is a general display screen class. Here the general display settings |
70 | 49 | will done. It will be used as specialized classes by Main Display and | 49 | will done. It will be used as specialized classes by Main Display and |
71 | 50 | Preview display. | 50 | Preview display. |
72 | 51 | """ | 51 | """ |
73 | @@ -66,7 +66,7 @@ | |||
74 | 66 | """ | 66 | """ |
75 | 67 | Set up and build the screen base | 67 | Set up and build the screen base |
76 | 68 | """ | 68 | """ |
78 | 69 | log.debug(u'Start Display base setup (live = %s)' % self.isLive) | 69 | log.debug(u'Start Display base setup (live = %s)' % self.isLive) |
79 | 70 | self.setGeometry(self.screen[u'size']) | 70 | self.setGeometry(self.screen[u'size']) |
80 | 71 | log.debug(u'Setup webView') | 71 | log.debug(u'Setup webView') |
81 | 72 | self.webView = QtWebKit.QWebView(self) | 72 | self.webView = QtWebKit.QWebView(self) |
82 | 73 | 73 | ||
83 | === modified file 'openlp/core/ui/servicemanager.py' | |||
84 | --- openlp/core/ui/servicemanager.py 2011-12-09 11:50:25 +0000 | |||
85 | +++ openlp/core/ui/servicemanager.py 2011-12-12 18:05:26 +0000 | |||
86 | @@ -37,7 +37,7 @@ | |||
87 | 37 | from PyQt4 import QtCore, QtGui | 37 | from PyQt4 import QtCore, QtGui |
88 | 38 | 38 | ||
89 | 39 | from openlp.core.lib import OpenLPToolbar, ServiceItem, Receiver, build_icon, \ | 39 | from openlp.core.lib import OpenLPToolbar, ServiceItem, Receiver, build_icon, \ |
91 | 40 | ItemCapabilities, SettingsManager, translate | 40 | ItemCapabilities, SettingsManager, translate, str_to_bool |
92 | 41 | from openlp.core.lib.theme import ThemeLevel | 41 | from openlp.core.lib.theme import ThemeLevel |
93 | 42 | from openlp.core.lib.ui import UiStrings, critical_error_message_box, \ | 42 | from openlp.core.lib.ui import UiStrings, critical_error_message_box, \ |
94 | 43 | context_menu_action, context_menu_separator, find_and_set_in_combo_box | 43 | context_menu_action, context_menu_separator, find_and_set_in_combo_box |
95 | @@ -465,6 +465,7 @@ | |||
96 | 465 | self.setModified(False) | 465 | self.setModified(False) |
97 | 466 | QtCore.QSettings(). \ | 466 | QtCore.QSettings(). \ |
98 | 467 | setValue(u'servicemanager/last file',QtCore.QVariant(u'')) | 467 | setValue(u'servicemanager/last file',QtCore.QVariant(u'')) |
99 | 468 | Receiver.send_message(u'servicemanager_new_service') | ||
100 | 468 | 469 | ||
101 | 469 | def saveFile(self): | 470 | def saveFile(self): |
102 | 470 | """ | 471 | """ |
103 | @@ -663,13 +664,14 @@ | |||
104 | 663 | serviceItem.renderer = self.mainwindow.renderer | 664 | serviceItem.renderer = self.mainwindow.renderer |
105 | 664 | serviceItem.set_from_service(item, self.servicePath) | 665 | serviceItem.set_from_service(item, self.servicePath) |
106 | 665 | self.validateItem(serviceItem) | 666 | self.validateItem(serviceItem) |
108 | 666 | self.loadItem_uuid = 0 | 667 | self.load_item_uuid = 0 |
109 | 667 | if serviceItem.is_capable(ItemCapabilities.OnLoadUpdate): | 668 | if serviceItem.is_capable(ItemCapabilities.OnLoadUpdate): |
110 | 668 | Receiver.send_message(u'%s_service_load' % | 669 | Receiver.send_message(u'%s_service_load' % |
111 | 669 | serviceItem.name.lower(), serviceItem) | 670 | serviceItem.name.lower(), serviceItem) |
112 | 670 | # if the item has been processed | 671 | # if the item has been processed |
115 | 671 | if serviceItem._uuid == self.loadItem_uuid: | 672 | if serviceItem._uuid == self.load_item_uuid: |
116 | 672 | serviceItem.edit_id = int(self.loadItem_editId) | 673 | serviceItem.edit_id = int(self.load_item_edit_id) |
117 | 674 | serviceItem.temporary_edit = self.load_item_temporary | ||
118 | 673 | self.addServiceItem(serviceItem, repaint=False) | 675 | self.addServiceItem(serviceItem, repaint=False) |
119 | 674 | delete_file(p_file) | 676 | delete_file(p_file) |
120 | 675 | self.setFileName(fileName) | 677 | self.setFileName(fileName) |
121 | @@ -999,6 +1001,17 @@ | |||
122 | 999 | painter.drawImage(0, 0, overlay) | 1001 | painter.drawImage(0, 0, overlay) |
123 | 1000 | painter.end() | 1002 | painter.end() |
124 | 1001 | treewidgetitem.setIcon(0, build_icon(icon)) | 1003 | treewidgetitem.setIcon(0, build_icon(icon)) |
125 | 1004 | elif serviceitem.temporary_edit: | ||
126 | 1005 | icon = QtGui.QImage(serviceitem.icon) | ||
127 | 1006 | icon = icon.scaled(80, 80, QtCore.Qt.KeepAspectRatio, | ||
128 | 1007 | QtCore.Qt.SmoothTransformation) | ||
129 | 1008 | overlay = QtGui.QImage(':/general/general_export.png') | ||
130 | 1009 | overlay = overlay.scaled(40, 40, QtCore.Qt.KeepAspectRatio, | ||
131 | 1010 | QtCore.Qt.SmoothTransformation) | ||
132 | 1011 | painter = QtGui.QPainter(icon) | ||
133 | 1012 | painter.drawImage(40, 0, overlay) | ||
134 | 1013 | painter.end() | ||
135 | 1014 | treewidgetitem.setIcon(0, build_icon(icon)) | ||
136 | 1002 | else: | 1015 | else: |
137 | 1003 | treewidgetitem.setIcon(0, serviceitem.iconic_representation) | 1016 | treewidgetitem.setIcon(0, serviceitem.iconic_representation) |
138 | 1004 | else: | 1017 | else: |
139 | @@ -1006,6 +1019,11 @@ | |||
140 | 1006 | build_icon(u':/general/general_delete.png')) | 1019 | build_icon(u':/general/general_delete.png')) |
141 | 1007 | treewidgetitem.setText(0, serviceitem.get_display_title()) | 1020 | treewidgetitem.setText(0, serviceitem.get_display_title()) |
142 | 1008 | tips = [] | 1021 | tips = [] |
143 | 1022 | if serviceitem.temporary_edit: | ||
144 | 1023 | tips.append(u'<strong>%s:</strong> <em>%s</em>' % | ||
145 | 1024 | (unicode(translate('OpenLP.ServiceManager', 'Edit')), | ||
146 | 1025 | (unicode(translate('OpenLP.ServiceManager', | ||
147 | 1026 | 'Service copy only'))))) | ||
148 | 1009 | if serviceitem.theme and serviceitem.theme != -1: | 1027 | if serviceitem.theme and serviceitem.theme != -1: |
149 | 1010 | tips.append(u'<strong>%s:</strong> <em>%s</em>' % | 1028 | tips.append(u'<strong>%s:</strong> <em>%s</em>' % |
150 | 1011 | (unicode(translate('OpenLP.ServiceManager', 'Slide theme')), | 1029 | (unicode(translate('OpenLP.ServiceManager', 'Slide theme')), |
151 | @@ -1127,8 +1145,9 @@ | |||
152 | 1127 | Triggered from plugins to update service items. | 1145 | Triggered from plugins to update service items. |
153 | 1128 | Save the values as they will be used as part of the service load | 1146 | Save the values as they will be used as part of the service load |
154 | 1129 | """ | 1147 | """ |
157 | 1130 | editId, self.loadItem_uuid = message.split(u':') | 1148 | edit_id, self.load_item_uuid, temporary = message.split(u':') |
158 | 1131 | self.loadItem_editId = int(editId) | 1149 | self.load_item_edit_id = int(edit_id) |
159 | 1150 | self.load_item_temporary = str_to_bool(temporary) | ||
160 | 1132 | 1151 | ||
161 | 1133 | def replaceServiceItem(self, newItem): | 1152 | def replaceServiceItem(self, newItem): |
162 | 1134 | """ | 1153 | """ |
163 | 1135 | 1154 | ||
164 | === modified file 'openlp/plugins/songs/forms/songexportform.py' | |||
165 | --- openlp/plugins/songs/forms/songexportform.py 2011-08-26 15:48:58 +0000 | |||
166 | +++ openlp/plugins/songs/forms/songexportform.py 2011-12-12 18:05:26 +0000 | |||
167 | @@ -252,6 +252,9 @@ | |||
168 | 252 | songs = self.plugin.manager.get_all_objects(Song) | 252 | songs = self.plugin.manager.get_all_objects(Song) |
169 | 253 | songs.sort(cmp=locale.strcoll, key=lambda song: song.title.lower()) | 253 | songs.sort(cmp=locale.strcoll, key=lambda song: song.title.lower()) |
170 | 254 | for song in songs: | 254 | for song in songs: |
171 | 255 | # No need to export temporary songs. | ||
172 | 256 | if song.temporary: | ||
173 | 257 | continue | ||
174 | 255 | authors = u', '.join([author.display_name | 258 | authors = u', '.join([author.display_name |
175 | 256 | for author in song.authors]) | 259 | for author in song.authors]) |
176 | 257 | title = u'%s (%s)' % (unicode(song.title), authors) | 260 | title = u'%s (%s)' % (unicode(song.title), authors) |
177 | 258 | 261 | ||
178 | === modified file 'openlp/plugins/songs/lib/db.py' | |||
179 | --- openlp/plugins/songs/lib/db.py 2011-08-26 23:04:54 +0000 | |||
180 | +++ openlp/plugins/songs/lib/db.py 2011-12-12 18:05:26 +0000 | |||
181 | @@ -199,7 +199,8 @@ | |||
182 | 199 | Column(u'search_lyrics', types.UnicodeText, nullable=False), | 199 | Column(u'search_lyrics', types.UnicodeText, nullable=False), |
183 | 200 | Column(u'create_date', types.DateTime(), default=func.now()), | 200 | Column(u'create_date', types.DateTime(), default=func.now()), |
184 | 201 | Column(u'last_modified', types.DateTime(), default=func.now(), | 201 | Column(u'last_modified', types.DateTime(), default=func.now(), |
186 | 202 | onupdate=func.now()) | 202 | onupdate=func.now()), |
187 | 203 | Column(u'temporary', types.Boolean(), default=False) | ||
188 | 203 | ) | 204 | ) |
189 | 204 | 205 | ||
190 | 205 | # Definition of the "topics" table | 206 | # Definition of the "topics" table |
191 | 206 | 207 | ||
192 | === modified file 'openlp/plugins/songs/lib/mediaitem.py' | |||
193 | --- openlp/plugins/songs/lib/mediaitem.py 2011-11-24 22:34:27 +0000 | |||
194 | +++ openlp/plugins/songs/lib/mediaitem.py 2011-12-12 18:05:26 +0000 | |||
195 | @@ -270,6 +270,9 @@ | |||
196 | 270 | searchresults.sort( | 270 | searchresults.sort( |
197 | 271 | cmp=locale.strcoll, key=lambda song: song.title.lower()) | 271 | cmp=locale.strcoll, key=lambda song: song.title.lower()) |
198 | 272 | for song in searchresults: | 272 | for song in searchresults: |
199 | 273 | # Do not display temporary songs | ||
200 | 274 | if song.temporary: | ||
201 | 275 | continue | ||
202 | 273 | author_list = [author.display_name for author in song.authors] | 276 | author_list = [author.display_name for author in song.authors] |
203 | 274 | song_title = unicode(song.title) | 277 | song_title = unicode(song.title) |
204 | 275 | song_detail = u'%s (%s)' % (song_title, u', '.join(author_list)) | 278 | song_detail = u'%s (%s)' % (song_title, u', '.join(author_list)) |
205 | @@ -286,6 +289,9 @@ | |||
206 | 286 | self.listView.clear() | 289 | self.listView.clear() |
207 | 287 | for author in searchresults: | 290 | for author in searchresults: |
208 | 288 | for song in author.songs: | 291 | for song in author.songs: |
209 | 292 | # Do not display temporary songs | ||
210 | 293 | if song.temporary: | ||
211 | 294 | continue | ||
212 | 289 | song_detail = u'%s (%s)' % (author.display_name, song.title) | 295 | song_detail = u'%s (%s)' % (author.display_name, song.title) |
213 | 290 | song_name = QtGui.QListWidgetItem(song_detail) | 296 | song_name = QtGui.QListWidgetItem(song_detail) |
214 | 291 | song_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(song.id)) | 297 | song_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(song.id)) |
215 | @@ -534,6 +540,7 @@ | |||
216 | 534 | Song.search_title.asc()) | 540 | Song.search_title.asc()) |
217 | 535 | editId = 0 | 541 | editId = 0 |
218 | 536 | add_song = True | 542 | add_song = True |
219 | 543 | temporary = False | ||
220 | 537 | if search_results: | 544 | if search_results: |
221 | 538 | for song in search_results: | 545 | for song in search_results: |
222 | 539 | author_list = item.data_string[u'authors'] | 546 | author_list = item.data_string[u'authors'] |
223 | @@ -559,13 +566,18 @@ | |||
224 | 559 | self._updateBackgroundAudio(song, item) | 566 | self._updateBackgroundAudio(song, item) |
225 | 560 | editId = song.id | 567 | editId = song.id |
226 | 561 | self.onSearchTextButtonClick() | 568 | self.onSearchTextButtonClick() |
228 | 562 | else: | 569 | elif add_song and not self.addSongFromService: |
229 | 563 | # Make sure we temporary import formatting tags. | 570 | # Make sure we temporary import formatting tags. |
231 | 564 | self.openLyrics.xml_to_song(item.xml_version, True) | 571 | song = self.openLyrics.xml_to_song(item.xml_version, True) |
232 | 572 | # If there's any backing tracks, copy them over. | ||
233 | 573 | if len(item.background_audio) > 0: | ||
234 | 574 | self._updateBackgroundAudio(song, item) | ||
235 | 575 | editId = song.id | ||
236 | 576 | temporary = True | ||
237 | 565 | # Update service with correct song id. | 577 | # Update service with correct song id. |
238 | 566 | if editId: | 578 | if editId: |
239 | 567 | Receiver.send_message(u'service_item_update', | 579 | Receiver.send_message(u'service_item_update', |
241 | 568 | u'%s:%s' % (editId, item._uuid)) | 580 | u'%s:%s:%s' % (editId, item._uuid, temporary)) |
242 | 569 | 581 | ||
243 | 570 | def search(self, string): | 582 | def search(self, string): |
244 | 571 | """ | 583 | """ |
245 | 572 | 584 | ||
246 | === modified file 'openlp/plugins/songs/lib/upgrade.py' | |||
247 | --- openlp/plugins/songs/lib/upgrade.py 2011-12-02 20:17:57 +0000 | |||
248 | +++ openlp/plugins/songs/lib/upgrade.py 2011-12-12 18:05:26 +0000 | |||
249 | @@ -33,7 +33,9 @@ | |||
250 | 33 | from sqlalchemy.sql.expression import func | 33 | from sqlalchemy.sql.expression import func |
251 | 34 | from migrate.changeset.constraint import ForeignKeyConstraint | 34 | from migrate.changeset.constraint import ForeignKeyConstraint |
252 | 35 | 35 | ||
254 | 36 | __version__ = 2 | 36 | from openlp.plugins.songs.lib.db import Song |
255 | 37 | |||
256 | 38 | __version__ = 3 | ||
257 | 37 | 39 | ||
258 | 38 | def upgrade_setup(metadata): | 40 | def upgrade_setup(metadata): |
259 | 39 | """ | 41 | """ |
260 | @@ -86,3 +88,12 @@ | |||
261 | 86 | Column(u'last_modified', types.DateTime(), default=func.now())\ | 88 | Column(u'last_modified', types.DateTime(), default=func.now())\ |
262 | 87 | .create(table=tables[u'songs']) | 89 | .create(table=tables[u'songs']) |
263 | 88 | 90 | ||
264 | 91 | def upgrade_3(session, metadata, tables): | ||
265 | 92 | """ | ||
266 | 93 | Version 3 upgrade. | ||
267 | 94 | |||
268 | 95 | This upgrade adds a temporary song flag to the songs table | ||
269 | 96 | """ | ||
270 | 97 | Column(u'temporary', types.Boolean(), default=False)\ | ||
271 | 98 | .create(table=tables[u'songs']) | ||
272 | 99 | |||
273 | 89 | 100 | ||
274 | === modified file 'openlp/plugins/songs/lib/xml.py' | |||
275 | --- openlp/plugins/songs/lib/xml.py 2011-10-09 19:51:44 +0000 | |||
276 | +++ openlp/plugins/songs/lib/xml.py 2011-12-12 18:05:26 +0000 | |||
277 | @@ -346,7 +346,7 @@ | |||
278 | 346 | lines_element.set(u'break', u'optional') | 346 | lines_element.set(u'break', u'optional') |
279 | 347 | return self._extract_xml(song_xml) | 347 | return self._extract_xml(song_xml) |
280 | 348 | 348 | ||
282 | 349 | def xml_to_song(self, xml, parse_and_not_save=False): | 349 | def xml_to_song(self, xml, parse_and_temporary_save=False): |
283 | 350 | """ | 350 | """ |
284 | 351 | Create and save a song from OpenLyrics format xml to the database. Since | 351 | Create and save a song from OpenLyrics format xml to the database. Since |
285 | 352 | we also export XML from external sources (e. g. OpenLyrics import), we | 352 | we also export XML from external sources (e. g. OpenLyrics import), we |
286 | @@ -355,9 +355,9 @@ | |||
287 | 355 | ``xml`` | 355 | ``xml`` |
288 | 356 | The XML to parse (unicode). | 356 | The XML to parse (unicode). |
289 | 357 | 357 | ||
293 | 358 | ``parse_and_not_save`` | 358 | ``parse_and_temporary_save`` |
294 | 359 | Switch to skip processing the whole song and to prevent storing the | 359 | Switch to skip processing the whole song and storing the songs in |
295 | 360 | songs to the database. Defaults to ``False``. | 360 | the database with a temporary flag. Defaults to ``False``. |
296 | 361 | """ | 361 | """ |
297 | 362 | # No xml get out of here. | 362 | # No xml get out of here. |
298 | 363 | if not xml: | 363 | if not xml: |
299 | @@ -371,14 +371,13 @@ | |||
300 | 371 | return None | 371 | return None |
301 | 372 | # Formatting tags are new in OpenLyrics 0.8 | 372 | # Formatting tags are new in OpenLyrics 0.8 |
302 | 373 | if float(song_xml.get(u'version')) > 0.7: | 373 | if float(song_xml.get(u'version')) > 0.7: |
306 | 374 | self._process_formatting_tags(song_xml, parse_and_not_save) | 374 | self._process_formatting_tags(song_xml, parse_and_temporary_save) |
304 | 375 | if parse_and_not_save: | ||
305 | 376 | return | ||
307 | 377 | song = Song() | 375 | song = Song() |
308 | 378 | # Values will be set when cleaning the song. | 376 | # Values will be set when cleaning the song. |
309 | 379 | song.search_lyrics = u'' | 377 | song.search_lyrics = u'' |
310 | 380 | song.verse_order = u'' | 378 | song.verse_order = u'' |
311 | 381 | song.search_title = u'' | 379 | song.search_title = u'' |
312 | 380 | song.temporary = parse_and_temporary_save | ||
313 | 382 | self._process_copyright(properties, song) | 381 | self._process_copyright(properties, song) |
314 | 383 | self._process_cclinumber(properties, song) | 382 | self._process_cclinumber(properties, song) |
315 | 384 | self._process_titles(properties, song) | 383 | self._process_titles(properties, song) |
316 | 385 | 384 | ||
317 | === modified file 'openlp/plugins/songs/songsplugin.py' | |||
318 | --- openlp/plugins/songs/songsplugin.py 2011-12-09 12:35:18 +0000 | |||
319 | +++ openlp/plugins/songs/songsplugin.py 2011-12-12 18:05:26 +0000 | |||
320 | @@ -78,6 +78,10 @@ | |||
321 | 78 | action_list.add_action(self.songExportItem, unicode(UiStrings().Export)) | 78 | action_list.add_action(self.songExportItem, unicode(UiStrings().Export)) |
322 | 79 | action_list.add_action(self.toolsReindexItem, | 79 | action_list.add_action(self.toolsReindexItem, |
323 | 80 | unicode(UiStrings().Tools)) | 80 | unicode(UiStrings().Tools)) |
324 | 81 | QtCore.QObject.connect(Receiver.get_receiver(), | ||
325 | 82 | QtCore.SIGNAL(u'servicemanager_new_service'), | ||
326 | 83 | self.clearTemporarySongs) | ||
327 | 84 | |||
328 | 81 | 85 | ||
329 | 82 | def addImportMenuItem(self, import_menu): | 86 | def addImportMenuItem(self, import_menu): |
330 | 83 | """ | 87 | """ |
331 | @@ -265,6 +269,8 @@ | |||
332 | 265 | Time to tidy up on exit | 269 | Time to tidy up on exit |
333 | 266 | """ | 270 | """ |
334 | 267 | log.info(u'Songs Finalising') | 271 | log.info(u'Songs Finalising') |
335 | 272 | self.clearTemporarySongs() | ||
336 | 273 | # Clean up files and connections | ||
337 | 268 | self.manager.finalise() | 274 | self.manager.finalise() |
338 | 269 | self.songImportItem.setVisible(False) | 275 | self.songImportItem.setVisible(False) |
339 | 270 | self.songExportItem.setVisible(False) | 276 | self.songExportItem.setVisible(False) |
340 | @@ -277,3 +283,9 @@ | |||
341 | 277 | action_list.remove_action(self.toolsReindexItem, | 283 | action_list.remove_action(self.toolsReindexItem, |
342 | 278 | unicode(UiStrings().Tools)) | 284 | unicode(UiStrings().Tools)) |
343 | 279 | Plugin.finalise(self) | 285 | Plugin.finalise(self) |
344 | 286 | |||
345 | 287 | def clearTemporarySongs(self): | ||
346 | 288 | # Remove temporary songs | ||
347 | 289 | songs = self.manager.get_all_objects(Song, Song.temporary == True) | ||
348 | 290 | for song in songs: | ||
349 | 291 | self.manager.delete_object(Song, song.id) |
Well, first remove your print statement.