Status: | Superseded |
---|---|
Proposed branch: | lp:~trb143/openlp/splitter |
Merge into: | lp:openlp |
Diff against target: |
308 lines (+99/-45) 7 files modified
openlp/core/lib/db.py (+1/-1) openlp/plugins/songs/forms/duplicatesongremovalform.py (+1/-2) openlp/plugins/songs/forms/editversedialog.py (+7/-0) openlp/plugins/songs/forms/editverseform.py (+21/-6) openlp/plugins/songs/lib/__init__.py (+34/-33) openlp/plugins/songs/lib/mediaitem.py (+7/-3) tests/functional/openlp_plugins/songs/test_editverseform.py (+28/-0) |
To merge this branch: | bzr merge lp:~trb143/openlp/splitter |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
OpenLP Core | Pending | ||
Review via email: mp+322053@code.launchpad.net |
This proposal has been superseded by a proposal from 2017-08-11.
Commit message
Description of the change
This is a POC request to show how forced splits can be done.
The split is only done at render time.
Called the split Divide as having 2 splits is confusing.
Will add tests if this idea is fine to progress!
To post a comment you must log in.
lp:~trb143/openlp/splitter
updated
- 2730. By Tim Bentley
-
Head
- 2731. By Tim Bentley
-
fix split to work with chords
- 2732. By Tim Bentley
-
start of the tests
- 2733. By Tim Bentley
-
Finish tests
- 2734. By Tim Bentley
-
remove whitespace
- 2735. By Tim Bentley
-
fixed missed string
- 2736. By Tim Bentley
-
Head
- 2737. By Tim Bentley
-
fix lables and render bug
- 2738. By Tim Bentley
-
Head
- 2739. By Tim Bentley
-
spelling
- 2740. By Tim Bentley
-
head
- 2741. By Tim Bentley
-
Import export
- 2742. By Tim Bentley
-
head
Unmerged revisions
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'openlp/core/lib/db.py' |
2 | --- openlp/core/lib/db.py 2017-08-01 20:59:41 +0000 |
3 | +++ openlp/core/lib/db.py 2017-08-11 16:19:18 +0000 |
4 | @@ -208,7 +208,7 @@ |
5 | :param upgrade: The python module that contains the upgrade instructions. |
6 | """ |
7 | if not database_exists(url): |
8 | - log.warn("Database {db} doesn't exist - skipping upgrade checks".format(db=url)) |
9 | + log.warning("Database {db} doesn't exist - skipping upgrade checks".format(db=url)) |
10 | return (0, 0) |
11 | |
12 | log.debug('Checking upgrades for DB {db}'.format(db=url)) |
13 | |
14 | === modified file 'openlp/plugins/songs/forms/duplicatesongremovalform.py' |
15 | --- openlp/plugins/songs/forms/duplicatesongremovalform.py 2017-06-09 06:06:49 +0000 |
16 | +++ openlp/plugins/songs/forms/duplicatesongremovalform.py 2017-08-11 16:19:18 +0000 |
17 | @@ -25,14 +25,13 @@ |
18 | |
19 | import logging |
20 | import multiprocessing |
21 | -import os |
22 | |
23 | from PyQt5 import QtCore, QtWidgets |
24 | |
25 | from openlp.core.common import Registry, RegistryProperties, translate |
26 | from openlp.core.ui.lib.wizard import OpenLPWizard, WizardStrings |
27 | from openlp.plugins.songs.lib import delete_song |
28 | -from openlp.plugins.songs.lib.db import Song, MediaFile |
29 | +from openlp.plugins.songs.lib.db import Song |
30 | from openlp.plugins.songs.forms.songreviewwidget import SongReviewWidget |
31 | from openlp.plugins.songs.lib.songcompare import songs_probably_equal |
32 | |
33 | |
34 | === modified file 'openlp/plugins/songs/forms/editversedialog.py' |
35 | --- openlp/plugins/songs/forms/editversedialog.py 2017-07-04 23:13:51 +0000 |
36 | +++ openlp/plugins/songs/forms/editversedialog.py 2017-08-11 16:19:18 +0000 |
37 | @@ -42,6 +42,10 @@ |
38 | self.dialog_layout.addWidget(self.verse_text_edit) |
39 | self.verse_type_layout = QtWidgets.QHBoxLayout() |
40 | self.verse_type_layout.setObjectName('verse_type_layout') |
41 | + self.divide_split_button = QtWidgets.QPushButton(edit_verse_dialog) |
42 | + self.divide_split_button.setIcon(build_icon(':/general/general_add.png')) |
43 | + self.divide_split_button.setObjectName('divide_split_button') |
44 | + self.verse_type_layout.addWidget(self.divide_split_button) |
45 | self.split_button = QtWidgets.QPushButton(edit_verse_dialog) |
46 | self.split_button.setIcon(build_icon(':/general/general_add.png')) |
47 | self.split_button.setObjectName('split_button') |
48 | @@ -95,6 +99,9 @@ |
49 | self.verse_type_combo_box.setItemText(VerseType.Other, VerseType.translated_names[VerseType.Other]) |
50 | self.split_button.setText(UiStrings().Split) |
51 | self.split_button.setToolTip(UiStrings().SplitToolTip) |
52 | + self.divide_split_button.setText(translate('SongsPlugin.EditVerseForm', '&Divide')) |
53 | + self.divide_split_button.setToolTip(translate('SongsPlugin.EditVerseForm', 'Divide the verse when displayed ' |
54 | + 'regardless of the screen size.')) |
55 | self.insert_button.setText(translate('SongsPlugin.EditVerseForm', '&Insert')) |
56 | self.insert_button.setToolTip(translate('SongsPlugin.EditVerseForm', |
57 | 'Split a slide into two by inserting a verse splitter.')) |
58 | |
59 | === modified file 'openlp/plugins/songs/forms/editverseform.py' |
60 | --- openlp/plugins/songs/forms/editverseform.py 2017-06-04 12:14:23 +0000 |
61 | +++ openlp/plugins/songs/forms/editverseform.py 2017-08-11 16:19:18 +0000 |
62 | @@ -51,9 +51,10 @@ |
63 | self.split_button.clicked.connect(self.on_split_button_clicked) |
64 | self.verse_text_edit.cursorPositionChanged.connect(self.on_cursor_position_changed) |
65 | self.verse_type_combo_box.currentIndexChanged.connect(self.on_verse_type_combo_box_changed) |
66 | + self.divide_split_button.clicked.connect(self.on_divide_split_button_clicked) |
67 | if Settings().value('songs/enable chords'): |
68 | - self.transpose_down_button.clicked.connect(self.on_transepose_down_button_clicked) |
69 | - self.transpose_up_button.clicked.connect(self.on_transepose_up_button_clicked) |
70 | + self.transpose_down_button.clicked.connect(self.on_transpose_down_button_clicked) |
71 | + self.transpose_up_button.clicked.connect(self.on_transpose_up_button_clicked) |
72 | |
73 | def insert_verse(self, verse_tag, verse_num=1): |
74 | """ |
75 | @@ -70,11 +71,25 @@ |
76 | |
77 | def on_split_button_clicked(self): |
78 | """ |
79 | - The split button has been pressed |
80 | + The optional split button has been pressed so we need add the split |
81 | + """ |
82 | + self._add_splitter_to_text('[---]') |
83 | + |
84 | + def on_divide_split_button_clicked(self): |
85 | + """ |
86 | + The force split button has been pressed so we need add the split |
87 | + """ |
88 | + self._add_splitter_to_text('[--}{--]') |
89 | + |
90 | + def _add_splitter_to_text(self, insert_string): |
91 | + """ |
92 | + Add a custom splitter to the song text |
93 | + |
94 | + :param insert_string: The string to insert |
95 | + :return: |
96 | """ |
97 | text = self.verse_text_edit.toPlainText() |
98 | position = self.verse_text_edit.textCursor().position() |
99 | - insert_string = '[---]' |
100 | if position and text[position - 1] != '\n': |
101 | insert_string = '\n' + insert_string |
102 | if position == len(text) or text[position] != '\n': |
103 | @@ -101,7 +116,7 @@ |
104 | """ |
105 | self.update_suggested_verse_number() |
106 | |
107 | - def on_transepose_up_button_clicked(self): |
108 | + def on_transpose_up_button_clicked(self): |
109 | """ |
110 | The transpose up button clicked |
111 | """ |
112 | @@ -118,7 +133,7 @@ |
113 | self.verse_text_edit.setFocus() |
114 | self.verse_text_edit.moveCursor(QtGui.QTextCursor.End) |
115 | |
116 | - def on_transepose_down_button_clicked(self): |
117 | + def on_transpose_down_button_clicked(self): |
118 | """ |
119 | The transpose down button clicked |
120 | """ |
121 | |
122 | === modified file 'openlp/plugins/songs/lib/__init__.py' |
123 | --- openlp/plugins/songs/lib/__init__.py 2017-08-01 20:59:41 +0000 |
124 | +++ openlp/plugins/songs/lib/__init__.py 2017-08-11 16:19:18 +0000 |
125 | @@ -546,12 +546,12 @@ |
126 | song_plugin.manager.delete_object(Song, song_id) |
127 | |
128 | |
129 | -def transpose_lyrics(lyrics, transepose_value): |
130 | +def transpose_lyrics(lyrics, transpose_value): |
131 | """ |
132 | - Transepose lyrics |
133 | + Transpose lyrics |
134 | |
135 | - :param lyrcs: The lyrics to be transposed |
136 | - :param transepose_value: The value to transpose the lyrics with |
137 | + :param lyrics: The lyrics to be transposed |
138 | + :param transpose_value: The value to transpose the lyrics with |
139 | :return: The transposed lyrics |
140 | """ |
141 | # Split text by verse delimiter - both normal and optional |
142 | @@ -562,16 +562,17 @@ |
143 | if verse.startswith('---[') or verse == '[---]': |
144 | transposed_lyrics += verse |
145 | else: |
146 | - transposed_lyrics += transpose_verse(verse, transepose_value, notation) |
147 | + transposed_lyrics += transpose_verse(verse, transpose_value, notation) |
148 | return transposed_lyrics |
149 | |
150 | |
151 | -def transpose_verse(verse_text, transepose_value, notation): |
152 | +def transpose_verse(verse_text, transpose_value, notation): |
153 | """ |
154 | - Transepose lyrics |
155 | + Transpose Verse |
156 | |
157 | - :param lyrcs: The lyrics to be transposed |
158 | - :param transepose_value: The value to transpose the lyrics with |
159 | + :param verse_text: The lyrics to be transposed |
160 | + :param transpose_value: The value to transpose the lyrics with |
161 | + :param notation: which notation to use |
162 | :return: The transposed lyrics |
163 | """ |
164 | if '[' not in verse_text: |
165 | @@ -589,11 +590,11 @@ |
166 | if word == ']': |
167 | in_tag = False |
168 | transposed_lyrics += word |
169 | - elif word == '/': |
170 | + elif word == '/' or word == '--}{--': |
171 | transposed_lyrics += word |
172 | else: |
173 | # This MUST be a chord |
174 | - transposed_lyrics += transpose_chord(word, transepose_value, notation) |
175 | + transposed_lyrics += transpose_chord(word, transpose_value, notation) |
176 | # If still inside a chord tag something is wrong! |
177 | if in_tag: |
178 | return verse_text |
179 | @@ -629,36 +630,36 @@ |
180 | for i in range(0, len(chord_split)): |
181 | if i > 0: |
182 | transposed_chord += '/' |
183 | - currentchord = chord_split[i] |
184 | - if currentchord and currentchord[0] == '(': |
185 | + current_chord = chord_split[i] |
186 | + if current_chord and current_chord[0] == '(': |
187 | transposed_chord += '(' |
188 | - if len(currentchord) > 1: |
189 | - currentchord = currentchord[1:] |
190 | + if len(current_chord) > 1: |
191 | + current_chord = current_chord[1:] |
192 | else: |
193 | - currentchord = '' |
194 | - if len(currentchord) > 0: |
195 | - if len(currentchord) > 1: |
196 | - if '#b'.find(currentchord[1]) == -1: |
197 | - note = currentchord[0:1] |
198 | - rest = currentchord[1:] |
199 | + current_chord = '' |
200 | + if len(current_chord) > 0: |
201 | + if len(current_chord) > 1: |
202 | + if '#b'.find(current_chord[1]) == -1: |
203 | + note = current_chord[0:1] |
204 | + rest = current_chord[1:] |
205 | else: |
206 | - note = currentchord[0:2] |
207 | - rest = currentchord[2:] |
208 | + note = current_chord[0:2] |
209 | + rest = current_chord[2:] |
210 | else: |
211 | - note = currentchord |
212 | + note = current_chord |
213 | rest = '' |
214 | - notenumber = notes_flat.index(note) if note not in notes_sharp else notes_sharp.index(note) |
215 | - notenumber += transpose_value |
216 | - while notenumber > 11: |
217 | - notenumber -= 12 |
218 | - while notenumber < 0: |
219 | - notenumber += 12 |
220 | + note_number = notes_flat.index(note) if note not in notes_sharp else notes_sharp.index(note) |
221 | + note_number += transpose_value |
222 | + while note_number > 11: |
223 | + note_number -= 12 |
224 | + while note_number < 0: |
225 | + note_number += 12 |
226 | if i == 0: |
227 | - current_chord = notes_sharp[notenumber] if notes_preferred[notenumber] == '#' else notes_flat[ |
228 | - notenumber] |
229 | + current_chord = notes_sharp[note_number] if notes_preferred[note_number] == '#' else notes_flat[ |
230 | + note_number] |
231 | last_chord = current_chord |
232 | else: |
233 | - current_chord = notes_flat[notenumber] if last_chord not in notes_sharp else notes_sharp[notenumber] |
234 | + current_chord = notes_flat[note_number] if last_chord not in notes_sharp else notes_sharp[note_number] |
235 | if not (note not in notes_flat and note not in notes_sharp): |
236 | transposed_chord += current_chord + rest |
237 | else: |
238 | |
239 | === modified file 'openlp/plugins/songs/lib/mediaitem.py' |
240 | --- openlp/plugins/songs/lib/mediaitem.py 2017-08-02 06:09:38 +0000 |
241 | +++ openlp/plugins/songs/lib/mediaitem.py 2017-08-11 16:19:18 +0000 |
242 | @@ -578,7 +578,7 @@ |
243 | if not song.verse_order.strip(): |
244 | for verse in verse_list: |
245 | # We cannot use from_loose_input() here, because database is supposed to contain English lowercase |
246 | - # singlechar tags. |
247 | + # single char tags. |
248 | verse_tag = verse[0]['type'] |
249 | verse_index = None |
250 | if len(verse_tag) > 1: |
251 | @@ -589,7 +589,9 @@ |
252 | verse_index = VerseType.from_tag(verse_tag) |
253 | verse_tag = VerseType.translated_tags[verse_index].upper() |
254 | verse_def = '{tag}{label}'.format(tag=verse_tag, label=verse[0]['label']) |
255 | - service_item.add_from_text(str(verse[1]), verse_def) |
256 | + force_verse = verse[1].split('[--}{--]\n', 2) |
257 | + for split_verse in force_verse: |
258 | + service_item.add_from_text(split_verse, verse_def) |
259 | else: |
260 | # Loop through the verse list and expand the song accordingly. |
261 | for order in song.verse_order.lower().split(): |
262 | @@ -604,7 +606,9 @@ |
263 | verse_index = VerseType.from_tag(verse[0]['type']) |
264 | verse_tag = VerseType.translated_tags[verse_index] |
265 | verse_def = '{tag}{text}'.format(tag=verse_tag, text=verse[0]['label']) |
266 | - service_item.add_from_text(verse[1], verse_def) |
267 | + force_verse = verse[1].split('[##-divide-##]\n', 2) |
268 | + for split_verse in force_verse: |
269 | + service_item.add_from_text(split_verse, verse_def) |
270 | service_item.title = song.title |
271 | author_list = self.generate_footer(service_item, song) |
272 | service_item.data_string = {'title': song.search_title, 'authors': ', '.join(author_list)} |
273 | |
274 | === modified file 'tests/functional/openlp_plugins/songs/test_editverseform.py' |
275 | --- tests/functional/openlp_plugins/songs/test_editverseform.py 2017-05-30 20:06:27 +0000 |
276 | +++ tests/functional/openlp_plugins/songs/test_editverseform.py 2017-08-11 16:19:18 +0000 |
277 | @@ -72,3 +72,31 @@ |
278 | |
279 | # THEN the verse number must not be changed |
280 | self.assertEqual(3, self.edit_verse_form.verse_number_box.value(), 'The verse number should be 3') |
281 | + |
282 | + def test_on_divide_split_button_clicked(self): |
283 | + """ |
284 | + Test that divide adds text at the correct position |
285 | + """ |
286 | + # GIVEN some input values |
287 | + self.edit_verse_form.verse_type_combo_box.currentIndex = MagicMock(return_value=4) |
288 | + self.edit_verse_form.verse_text_edit.setPlainText('Text\n') |
289 | + |
290 | + # WHEN the method is called |
291 | + self.edit_verse_form.on_divide_split_button_clicked() |
292 | + # THEN the verse number must not be changed |
293 | + self.assertEqual('[--}{--]\nText\n', self.edit_verse_form.verse_text_edit.toPlainText(), |
294 | + 'The verse number should be [--}{--]\nText\n') |
295 | + |
296 | + def test_on_split_button_clicked(self): |
297 | + """ |
298 | + Test that divide adds text at the correct position |
299 | + """ |
300 | + # GIVEN some input values |
301 | + self.edit_verse_form.verse_type_combo_box.currentIndex = MagicMock(return_value=4) |
302 | + self.edit_verse_form.verse_text_edit.setPlainText('Text\n') |
303 | + |
304 | + # WHEN the method is called |
305 | + self.edit_verse_form.on_split_button_clicked() |
306 | + # THEN the verse number must not be changed |
307 | + self.assertEqual('[---]\nText\n', self.edit_verse_form.verse_text_edit.toPlainText(), |
308 | + 'The verse number should be [---]\nText\n') |