Merge lp:~trb143/openlp/bugfixes into lp:openlp

Proposed by Tim Bentley
Status: Merged
Merged at revision: not available
Proposed branch: lp:~trb143/openlp/bugfixes
Merge into: lp:openlp
Diff against target: None lines
To merge this branch: bzr merge lp:~trb143/openlp/bugfixes
Reviewer Review Type Date Requested Status
Raoul Snyman Approve
Review via email: mp+9708@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Tim Bentley (trb143) wrote :

Fix italic handling xml error
Fix screen refresh issue
Fix renderer where word is bigger than line!

Revision history for this message
Raoul Snyman (raoul-snyman) wrote :

Looks fine, though there are a few more comments that I feel are necessary ;-)

review: Approve
lp:~trb143/openlp/bugfixes updated
500. By Tim Bentley

Bug fixes from last merge

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'openlp/core/lib/renderer.py'
2--- openlp/core/lib/renderer.py 2009-08-03 19:49:21 +0000
3+++ openlp/core/lib/renderer.py 2009-08-05 17:59:37 +0000
4@@ -167,32 +167,37 @@
5 #take the width work out approx how many characters and add 50%
6 line_width = self._rect.width() - self._right_margin
7 #number of lines on a page - adjust for rounding up.
8+ #print self._rect.height() , metrics.height(), int(self._rect.height() / metrics.height())
9 page_length = int(self._rect.height() / metrics.height()) - 1
10 ave_line_width = line_width / metrics.averageCharWidth()
11- #print ave_line_width
12+# print "A", ave_line_width
13 ave_line_width = int(ave_line_width + (ave_line_width * 0.5))
14- #print ave_line_width
15+# print "B", ave_line_width
16 split_pages = []
17 page = []
18 split_lines = []
19 count = 0
20 for line in text:
21- #print line , len(line)
22+# print "C", line , len(line)
23 if len(line) > ave_line_width:
24 while len(line) > 0:
25 pos = line.find(u' ', ave_line_width)
26- #print ave_line_width, pos, line[:pos]
27+# print "D2", len(line), ave_line_width, pos, line[:pos]
28 split_text = line[:pos]
29- #print metrics.width(split_text, -1), line_width
30+# print "E", metrics.width(split_text, -1), line_width
31 while metrics.width(split_text, -1) > line_width:
32 #Find the next space to the left
33 pos = line[:pos].rfind(u' ')
34- #print ave_line_width, pos, line[:pos]
35+# print "F", ave_line_width, pos, line[:pos]
36 #no more spaces found
37- if pos == -1:
38+ if pos == 0:
39 split_text = line
40+ while metrics.width(split_text, -1) > line_width:
41+ split_text = split_text[:-1]
42+ pos = len(split_text)
43 else:
44 split_text = line[:pos]
45+# print "F1", split_text, line, pos
46 split_lines.append(split_text)
47 line = line[pos:]
48 #Text fits in a line now
49@@ -200,13 +205,14 @@
50 split_lines.append(line)
51 line = u''
52 # count += 1
53-# if count == 50:
54+# if count == 15:
55 # a = c
56- #print split_lines
57- #print line
58+# print "G", split_lines
59+# print "H", line
60 else:
61 split_lines.append(line)
62 line = u''
63+ #print "I", split_lines, page_length
64 for line in split_lines:
65 page.append(line)
66 if len(page) == page_length:
67@@ -306,72 +312,72 @@
68 QtCore.Qt.SmoothTransformation)
69 log.debug(u'render background End')
70
71- def _split_set_of_lines(self, lines, footer):
72- """
73- Given a list of lines, decide how to split them best if they don't all
74- fit on the screen. This is done by splitting at 1/2, 1/3 or 1/4 of the
75- set. If it doesn't fit, even at this size, just split at each
76- opportunity. We'll do this by getting the bounding box of each line,
77- and then summing them appropriately.
78-
79- Returns a list of [lists of lines], one set for each screenful.
80-
81- ``lines``
82- The lines of text to split.
83-
84- ``footer``
85- The footer text.
86- """
87- bboxes = []
88- for line in lines:
89- bboxes.append(self._render_and_wrap_single_line(line, footer))
90- numlines = len(lines)
91- bottom = self._rect.bottom()
92- for ratio in (numlines, numlines/2, numlines/3, numlines/4):
93- good = 1
94- startline = 0
95- endline = startline + ratio
96- while (endline <= numlines and endline != 0):
97- by = 0
98- for (x,y) in bboxes[startline:endline]:
99- by += y
100- if by > bottom:
101- good = 0
102- break
103- startline += ratio
104- endline = startline + ratio
105- if good == 1:
106- break
107- retval = []
108- numlines_per_page = ratio
109- if good:
110- c = 0
111- thislines = []
112- while c < numlines:
113- thislines.append(lines[c])
114- c += 1
115- if len(thislines) == numlines_per_page:
116- retval.append(thislines)
117- thislines = []
118- if len(thislines) > 0:
119- retval.append(thislines)
120- else:
121- # print "Just split where you can"
122- retval = []
123- startline = 0
124- endline = startline + 1
125- while (endline <= numlines):
126- by = 0
127- for (x,y) in bboxes[startline:endline]:
128- by += y
129- if by > bottom:
130- retval.append(lines[startline:endline-1])
131- startline = endline-1
132- # gets incremented below
133- endline = startline
134- by = 0
135- endline += 1
136- return retval
137+# def _split_set_of_lines(self, lines, footer):
138+# """
139+# Given a list of lines, decide how to split them best if they don't all
140+# fit on the screen. This is done by splitting at 1/2, 1/3 or 1/4 of the
141+# set. If it doesn't fit, even at this size, just split at each
142+# opportunity. We'll do this by getting the bounding box of each line,
143+# and then summing them appropriately.
144+#
145+# Returns a list of [lists of lines], one set for each screenful.
146+#
147+# ``lines``
148+# The lines of text to split.
149+#
150+# ``footer``
151+# The footer text.
152+# """
153+# bboxes = []
154+# for line in lines:
155+# bboxes.append(self._render_and_wrap_single_line(line, footer))
156+# numlines = len(lines)
157+# bottom = self._rect.bottom()
158+# for ratio in (numlines, numlines/2, numlines/3, numlines/4):
159+# good = 1
160+# startline = 0
161+# endline = startline + ratio
162+# while (endline <= numlines and endline != 0):
163+# by = 0
164+# for (x,y) in bboxes[startline:endline]:
165+# by += y
166+# if by > bottom:
167+# good = 0
168+# break
169+# startline += ratio
170+# endline = startline + ratio
171+# if good == 1:
172+# break
173+# retval = []
174+# numlines_per_page = ratio
175+# if good:
176+# c = 0
177+# thislines = []
178+# while c < numlines:
179+# thislines.append(lines[c])
180+# c += 1
181+# if len(thislines) == numlines_per_page:
182+# retval.append(thislines)
183+# thislines = []
184+# if len(thislines) > 0:
185+# retval.append(thislines)
186+# else:
187+# # print "Just split where you can"
188+# retval = []
189+# startline = 0
190+# endline = startline + 1
191+# while (endline <= numlines):
192+# by = 0
193+# for (x,y) in bboxes[startline:endline]:
194+# by += y
195+# if by > bottom:
196+# retval.append(lines[startline:endline-1])
197+# startline = endline-1
198+# # gets incremented below
199+# endline = startline
200+# by = 0
201+# endline += 1
202+# return retval
203
204 def _correctAlignment(self, rect, bbox):
205 """
206
207=== modified file 'openlp/core/lib/themexmlhandler.py'
208--- openlp/core/lib/themexmlhandler.py 2009-08-03 19:49:21 +0000
209+++ openlp/core/lib/themexmlhandler.py 2009-08-05 17:59:37 +0000
210@@ -161,7 +161,7 @@
211 #Create Filename element
212 self.child_element(background, u'filename', filename)
213
214- def add_font(self, name, color, proportion, override, fonttype=u'main', weight=u'Bold', italics=False,
215+ def add_font(self, name, color, proportion, override, fonttype=u'main', weight=u'Normal', italics=u'False',
216 xpos=0, ypos=0, width=0, height=0):
217 """
218 Add a Font.
219
220=== modified file 'openlp/plugins/bibles/lib/mediaitem.py'
221--- openlp/plugins/bibles/lib/mediaitem.py 2009-08-02 13:44:41 +0000
222+++ openlp/plugins/bibles/lib/mediaitem.py 2009-08-05 17:59:37 +0000
223@@ -20,6 +20,7 @@
224 Place, Suite 330, Boston, MA 02111-1307 USA
225 """
226 import logging
227+import time
228
229 from PyQt4 import QtCore, QtGui
230
231@@ -268,6 +269,8 @@
232 def setQuickMsg2(self, text):
233 self.QuickMsg2.setText(translate(u'BibleMediaItem', unicode(text)))
234 Receiver().send_message(u'openlpprocessevents')
235+ #minor delay to get the events processed
236+ time.sleep(0.5)
237
238 def loadBibles(self):
239 log.debug(u'Loading Bibles')