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
=== modified file 'openlp/core/lib/renderer.py'
--- openlp/core/lib/renderer.py 2009-08-03 19:49:21 +0000
+++ openlp/core/lib/renderer.py 2009-08-05 17:59:37 +0000
@@ -167,32 +167,37 @@
167 #take the width work out approx how many characters and add 50%167 #take the width work out approx how many characters and add 50%
168 line_width = self._rect.width() - self._right_margin168 line_width = self._rect.width() - self._right_margin
169 #number of lines on a page - adjust for rounding up.169 #number of lines on a page - adjust for rounding up.
170 #print self._rect.height() , metrics.height(), int(self._rect.height() / metrics.height())
170 page_length = int(self._rect.height() / metrics.height()) - 1171 page_length = int(self._rect.height() / metrics.height()) - 1
171 ave_line_width = line_width / metrics.averageCharWidth()172 ave_line_width = line_width / metrics.averageCharWidth()
172 #print ave_line_width173# print "A", ave_line_width
173 ave_line_width = int(ave_line_width + (ave_line_width * 0.5))174 ave_line_width = int(ave_line_width + (ave_line_width * 0.5))
174 #print ave_line_width175# print "B", ave_line_width
175 split_pages = []176 split_pages = []
176 page = []177 page = []
177 split_lines = []178 split_lines = []
178 count = 0179 count = 0
179 for line in text:180 for line in text:
180 #print line , len(line)181# print "C", line , len(line)
181 if len(line) > ave_line_width:182 if len(line) > ave_line_width:
182 while len(line) > 0:183 while len(line) > 0:
183 pos = line.find(u' ', ave_line_width)184 pos = line.find(u' ', ave_line_width)
184 #print ave_line_width, pos, line[:pos]185# print "D2", len(line), ave_line_width, pos, line[:pos]
185 split_text = line[:pos]186 split_text = line[:pos]
186 #print metrics.width(split_text, -1), line_width187# print "E", metrics.width(split_text, -1), line_width
187 while metrics.width(split_text, -1) > line_width:188 while metrics.width(split_text, -1) > line_width:
188 #Find the next space to the left189 #Find the next space to the left
189 pos = line[:pos].rfind(u' ')190 pos = line[:pos].rfind(u' ')
190 #print ave_line_width, pos, line[:pos]191# print "F", ave_line_width, pos, line[:pos]
191 #no more spaces found192 #no more spaces found
192 if pos == -1:193 if pos == 0:
193 split_text = line194 split_text = line
195 while metrics.width(split_text, -1) > line_width:
196 split_text = split_text[:-1]
197 pos = len(split_text)
194 else:198 else:
195 split_text = line[:pos]199 split_text = line[:pos]
200# print "F1", split_text, line, pos
196 split_lines.append(split_text)201 split_lines.append(split_text)
197 line = line[pos:]202 line = line[pos:]
198 #Text fits in a line now203 #Text fits in a line now
@@ -200,13 +205,14 @@
200 split_lines.append(line)205 split_lines.append(line)
201 line = u''206 line = u''
202# count += 1207# count += 1
203# if count == 50:208# if count == 15:
204# a = c209# a = c
205 #print split_lines210# print "G", split_lines
206 #print line211# print "H", line
207 else:212 else:
208 split_lines.append(line)213 split_lines.append(line)
209 line = u''214 line = u''
215 #print "I", split_lines, page_length
210 for line in split_lines:216 for line in split_lines:
211 page.append(line)217 page.append(line)
212 if len(page) == page_length:218 if len(page) == page_length:
@@ -306,72 +312,72 @@
306 QtCore.Qt.SmoothTransformation)312 QtCore.Qt.SmoothTransformation)
307 log.debug(u'render background End')313 log.debug(u'render background End')
308314
309 def _split_set_of_lines(self, lines, footer):315# def _split_set_of_lines(self, lines, footer):
310 """316# """
311 Given a list of lines, decide how to split them best if they don't all317# Given a list of lines, decide how to split them best if they don't all
312 fit on the screen. This is done by splitting at 1/2, 1/3 or 1/4 of the318# fit on the screen. This is done by splitting at 1/2, 1/3 or 1/4 of the
313 set. If it doesn't fit, even at this size, just split at each319# set. If it doesn't fit, even at this size, just split at each
314 opportunity. We'll do this by getting the bounding box of each line,320# opportunity. We'll do this by getting the bounding box of each line,
315 and then summing them appropriately.321# and then summing them appropriately.
316322#
317 Returns a list of [lists of lines], one set for each screenful.323# Returns a list of [lists of lines], one set for each screenful.
318324#
319 ``lines``325# ``lines``
320 The lines of text to split.326# The lines of text to split.
321327#
322 ``footer``328# ``footer``
323 The footer text.329# The footer text.
324 """330# """
325 bboxes = []331# bboxes = []
326 for line in lines:332# for line in lines:
327 bboxes.append(self._render_and_wrap_single_line(line, footer))333# bboxes.append(self._render_and_wrap_single_line(line, footer))
328 numlines = len(lines)334# numlines = len(lines)
329 bottom = self._rect.bottom()335# bottom = self._rect.bottom()
330 for ratio in (numlines, numlines/2, numlines/3, numlines/4):336# for ratio in (numlines, numlines/2, numlines/3, numlines/4):
331 good = 1337# good = 1
332 startline = 0338# startline = 0
333 endline = startline + ratio339# endline = startline + ratio
334 while (endline <= numlines and endline != 0):340# while (endline <= numlines and endline != 0):
335 by = 0341# by = 0
336 for (x,y) in bboxes[startline:endline]:342# for (x,y) in bboxes[startline:endline]:
337 by += y343# by += y
338 if by > bottom:344# if by > bottom:
339 good = 0345# good = 0
340 break346# break
341 startline += ratio347# startline += ratio
342 endline = startline + ratio348# endline = startline + ratio
343 if good == 1:349# if good == 1:
344 break350# break
345 retval = []351# retval = []
346 numlines_per_page = ratio352# numlines_per_page = ratio
347 if good:353# if good:
348 c = 0354# c = 0
349 thislines = []355# thislines = []
350 while c < numlines:356# while c < numlines:
351 thislines.append(lines[c])357# thislines.append(lines[c])
352 c += 1358# c += 1
353 if len(thislines) == numlines_per_page:359# if len(thislines) == numlines_per_page:
354 retval.append(thislines)360# retval.append(thislines)
355 thislines = []361# thislines = []
356 if len(thislines) > 0:362# if len(thislines) > 0:
357 retval.append(thislines)363# retval.append(thislines)
358 else:364# else:
359 # print "Just split where you can"365# # print "Just split where you can"
360 retval = []366# retval = []
361 startline = 0367# startline = 0
362 endline = startline + 1368# endline = startline + 1
363 while (endline <= numlines):369# while (endline <= numlines):
364 by = 0370# by = 0
365 for (x,y) in bboxes[startline:endline]:371# for (x,y) in bboxes[startline:endline]:
366 by += y372# by += y
367 if by > bottom:373# if by > bottom:
368 retval.append(lines[startline:endline-1])374# retval.append(lines[startline:endline-1])
369 startline = endline-1375# startline = endline-1
370 # gets incremented below376# # gets incremented below
371 endline = startline377# endline = startline
372 by = 0378# by = 0
373 endline += 1379# endline += 1
374 return retval380# return retval
375381
376 def _correctAlignment(self, rect, bbox):382 def _correctAlignment(self, rect, bbox):
377 """383 """
378384
=== modified file 'openlp/core/lib/themexmlhandler.py'
--- openlp/core/lib/themexmlhandler.py 2009-08-03 19:49:21 +0000
+++ openlp/core/lib/themexmlhandler.py 2009-08-05 17:59:37 +0000
@@ -161,7 +161,7 @@
161 #Create Filename element161 #Create Filename element
162 self.child_element(background, u'filename', filename)162 self.child_element(background, u'filename', filename)
163163
164 def add_font(self, name, color, proportion, override, fonttype=u'main', weight=u'Bold', italics=False,164 def add_font(self, name, color, proportion, override, fonttype=u'main', weight=u'Normal', italics=u'False',
165 xpos=0, ypos=0, width=0, height=0):165 xpos=0, ypos=0, width=0, height=0):
166 """166 """
167 Add a Font.167 Add a Font.
168168
=== modified file 'openlp/plugins/bibles/lib/mediaitem.py'
--- openlp/plugins/bibles/lib/mediaitem.py 2009-08-02 13:44:41 +0000
+++ openlp/plugins/bibles/lib/mediaitem.py 2009-08-05 17:59:37 +0000
@@ -20,6 +20,7 @@
20Place, Suite 330, Boston, MA 02111-1307 USA20Place, Suite 330, Boston, MA 02111-1307 USA
21"""21"""
22import logging22import logging
23import time
2324
24from PyQt4 import QtCore, QtGui25from PyQt4 import QtCore, QtGui
2526
@@ -268,6 +269,8 @@
268 def setQuickMsg2(self, text):269 def setQuickMsg2(self, text):
269 self.QuickMsg2.setText(translate(u'BibleMediaItem', unicode(text)))270 self.QuickMsg2.setText(translate(u'BibleMediaItem', unicode(text)))
270 Receiver().send_message(u'openlpprocessevents')271 Receiver().send_message(u'openlpprocessevents')
272 #minor delay to get the events processed
273 time.sleep(0.5)
271274
272 def loadBibles(self):275 def loadBibles(self):
273 log.debug(u'Loading Bibles')276 log.debug(u'Loading Bibles')