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

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
Reviewer Review Type Date Requested Status
Raoul Snyman Approve
Review via email: mp+7691@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Tim Bentley (trb143) wrote :

Correct oos to become a zip file
bug fixes and code corrections

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

Just watch out for lines 319 and 324 of listwithpreviews.py:
  "rediunicodeibute" should most probably be "redistribute"

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/renderer.py'
2--- openlp/core/lib/renderer.py 2009-06-16 18:21:24 +0000
3+++ openlp/core/lib/renderer.py 2009-06-19 18:41:38 +0000
4@@ -20,9 +20,8 @@
5 import logging
6 import os, os.path
7 import sys
8-#from copy import copy
9
10-from PyQt4 import QtGui, QtCore, Qt
11+from PyQt4 import QtGui, QtCore
12
13 class Renderer:
14 """
15@@ -36,7 +35,6 @@
16 def __init__(self):
17 self._rect = None
18 self._debug = 0
19- #self.words = None
20 self._right_margin = 64 # the amount of right indent
21 self._shadow_offset = 5
22 self._outline_offset = 2
23@@ -140,7 +138,7 @@
24 # reset the frame. first time do not worry about what you paint on.
25 #self._frame = QtGui.QPixmap(self._frame.width(), self._frame.height()) #(self._bg_frame)
26 #self._frame.fill(QtCore.Qt.transparent)
27- # reset the frame. first time do not worrk about what you paint on.
28+ # reset the frame. first time do not worry about what you paint on.
29 self._frame = QtGui.QImage(self._bg_frame)
30 x, y = self._correctAlignment(self._rect, bbox)
31 bbox = self._render_lines_unaligned(lines, False, (x, y), True)
32
33=== modified file 'openlp/core/lib/rendermanager.py'
34--- openlp/core/lib/rendermanager.py 2009-06-17 05:11:16 +0000
35+++ openlp/core/lib/rendermanager.py 2009-06-19 18:41:38 +0000
36@@ -21,9 +21,8 @@
37 import os, os.path
38 import sys
39
40-from datetime import *
41-from PyQt4 import QtGui, QtCore, Qt
42-from renderer import Renderer
43+from PyQt4 import QtGui, QtCore
44+from renderer import Renderer
45
46 import sys
47 import linecache
48
49=== modified file 'openlp/core/ui/servicemanager.py'
50--- openlp/core/ui/servicemanager.py 2009-06-16 18:21:24 +0000
51+++ openlp/core/ui/servicemanager.py 2009-06-19 18:41:38 +0000
52@@ -113,25 +113,47 @@
53 """
54 Move the current ServiceItem to the top of the list
55 """
56- pass
57+ item, count = self.findServiceItem()
58+ if item < len(self.serviceItems) and item is not -1:
59+ temp = self.serviceItems[item]
60+ self.serviceItems.remove(self.serviceItems[item])
61+ self.serviceItems.insert(0, temp)
62+ self.repaintServiceList()
63
64 def onServiceUp(self):
65 """
66 Move the current ServiceItem up in the list
67+ Note move up means move to top of area ie 0.
68 """
69- pass
70+ item, count = self.findServiceItem()
71+ if item > 0:
72+ temp = self.serviceItems[item]
73+ self.serviceItems.remove(self.serviceItems[item])
74+ self.serviceItems.insert(item - 1, temp)
75+ self.repaintServiceList()
76
77 def onServiceDown(self):
78 """
79 Move the current ServiceItem down in the list
80+ Note move down means move to bottom of area i.e len().
81 """
82- pass
83+ item, count = self.findServiceItem()
84+ if item < len(self.serviceItems) and item is not -1:
85+ temp = self.serviceItems[item]
86+ self.serviceItems.remove(self.serviceItems[item])
87+ self.serviceItems.insert(item + 1, temp)
88+ self.repaintServiceList()
89
90 def onServiceEnd(self):
91 """
92 Move the current ServiceItem to the bottom of the list
93 """
94- pass
95+ item, count = self.findServiceItem()
96+ if item < len(self.serviceItems) and item is not -1:
97+ temp = self.serviceItems[item]
98+ self.serviceItems.remove(self.serviceItems[item])
99+ self.serviceItems.insert(len(self.serviceItems), temp)
100+ self.repaintServiceList()
101
102 def onNewService(self):
103 """
104@@ -144,7 +166,32 @@
105 """
106 Remove the current ServiceItem from the list
107 """
108- pass
109+ item, count = self.findServiceItem()
110+ if item is not -1:
111+ self.serviceItems.remove(self.serviceItems[item])
112+ self.repaintServiceList()
113+
114+ def repaintServiceList(self):
115+ #Correct order of idems in array
116+ count = 1
117+ for item in self.serviceItems:
118+ item[u'order'] = count
119+ count += 1
120+ #Repaint the screen
121+ self.ServiceManagerList.clear()
122+ for item in self.serviceItems:
123+ serviceitem = item[u'data']
124+ treewidgetitem = QtGui.QTreeWidgetItem(self.ServiceManagerList)
125+ treewidgetitem.setText(0,serviceitem.title)
126+ treewidgetitem.setIcon(0,serviceitem.iconic_representation)
127+ treewidgetitem.setData(0, QtCore.Qt.UserRole, QtCore.QVariant(item[u'order']))
128+ count = 0
129+ for frame in serviceitem.frames:
130+ treewidgetitem1 = QtGui.QTreeWidgetItem(treewidgetitem)
131+ text = frame[u'title']
132+ treewidgetitem1.setText(0,text[:40])
133+ treewidgetitem1.setData(0, QtCore.Qt.UserRole,QtCore.QVariant(count))
134+ count = count + 1
135
136 def onSaveService(self):
137 """
138@@ -233,11 +280,10 @@
139 pos = 0
140 count = 0
141 for item in items:
142- childCount = item.childCount()
143- if childCount >= 1:
144+ parentitem = item.parent()
145+ if parentitem is None:
146 pos = item.data(0, QtCore.Qt.UserRole).toInt()[0]
147 else:
148- parentitem = item.parent()
149 pos = parentitem.data(0, QtCore.Qt.UserRole).toInt()[0]
150 count = item.data(0, QtCore.Qt.UserRole).toInt()[0]
151 #adjuest for zero based arrays
152@@ -274,4 +320,4 @@
153 id = 0
154 self.service_theme = u''
155 self.ThemeComboBox.setCurrentIndex(id)
156- self.parent.RenderManager.set_service_theme(self.service_theme)
157\ No newline at end of file
158+ self.parent.RenderManager.set_service_theme(self.service_theme)
159
160=== modified file 'openlp/plugins/custom/lib/mediaitem.py'
161--- openlp/plugins/custom/lib/mediaitem.py 2009-06-17 05:11:16 +0000
162+++ openlp/plugins/custom/lib/mediaitem.py 2009-06-19 18:41:38 +0000
163@@ -142,17 +142,20 @@
164
165 def onCustomEditClick(self):
166 item = self.CustomListWidget.currentItem()
167- item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
168- self.parent.edit_custom_form.loadCustom(item_id)
169- self.parent.edit_custom_form.exec_()
170- self.initialise()
171+ item = self.CustomListWidget.currentItem()
172+ if item is not None:
173+ item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
174+ self.parent.edit_custom_form.loadCustom(item_id)
175+ self.parent.edit_custom_form.exec_()
176+ self.initialise()
177
178 def onCustomDeleteClick(self):
179 item = self.CustomListWidget.currentItem()
180- item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
181- self.parent.custommanager.delete_custom(item_id)
182- row = self.CustomListWidget.row(item)
183- self.CustomListWidget.takeItem(row)
184+ if item is not None:
185+ item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
186+ self.parent.custommanager.delete_custom(item_id)
187+ row = self.CustomListWidget.row(item)
188+ self.CustomListWidget.takeItem(row)
189
190 def onCustomPreviewClick(self):
191 log.debug(u'Custom Preview Requested')
192
193=== removed file 'openlp/plugins/images/lib/imageserviceitem.py'
194--- openlp/plugins/images/lib/imageserviceitem.py 2009-06-16 18:21:24 +0000
195+++ openlp/plugins/images/lib/imageserviceitem.py 1970-01-01 00:00:00 +0000
196@@ -1,113 +0,0 @@
197-# -*- coding: utf-8 -*-
198-# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
199-"""
200-OpenLP - Open Source Lyrics Projection
201-Copyright (c) 2008 Raoul Snyman
202-Portions copyright (c) 2008 Martin Thompson, Tim Bentley
203-
204-This program is free software; you can redistribute it and/or modify it under
205-the terms of the GNU General Public License as published by the Free Software
206-Foundation; version 2 of the License.
207-
208-This program is distributed in the hope that it will be useful, but WITHOUT ANY
209-WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
210-PARTICULAR PURPOSE. See the GNU General Public License for more details.
211-
212-You should have received a copy of the GNU General Public License along with
213-this program; if not, write to the Free Software Foundation, Inc., 59 Temple
214-Place, Suite 330, Boston, MA 02111-1307 USA
215-"""
216-import logging
217-from PyQt4 import QtCore, QtGui
218-from openlp.core.lib import ServiceItem
219-from listwithpreviews import ListWithPreviews
220-
221-class ImageServiceItem(ServiceItem):
222- """
223- The service item is a base class for the plugins to use to interact with
224- * the service manager (and hence the OOS disk files),
225- * the slide controller(s - both preview and live)
226- * and the renderer - which produces the
227- main screen
228- the preview preview and
229- the live preview
230-
231- The image plugin passes one of these to the preview/live when requested
232- The preview/live controllers keep hold of it
233- The service manager has one in its service structure for each Image item in the OOS
234- When something goes live/previews -
235- it simply tells the slide controller to use it???
236-
237- It contains 1 or more images
238-
239- """
240- global log
241- log=logging.getLogger(u'ImageServiceItem')
242- log.info(u'ImageServiceItem loaded')
243- def __init__(self, controller):
244- """
245- Init Method
246- """
247- log.info(u'init')
248- self.imgs=ListWithPreviews()
249-# self.slide_controller=controller
250-# self.slide_controller.ControllerContents=QtGui.QListView()
251-# c=self.slide_controller.ControllerContents
252-# c.uniformItemSizes=True
253-# c.setModel(self.imgs)
254-# c.setGeometry(0,0,200,200)
255-
256- def render(self):
257- """
258- The render method is what the plugin uses to render its meda to the
259- screen.
260- """
261- # render the "image chooser first"
262-# for f in self.imgs:
263-# fl , nm = os.path.split(unicode(f))
264-# c = self.slide_controller.rowCount()
265-# self.slide_controller.setRowCount(c+1)
266-# twi = QtGui.QTableWidgetItem(unicode(f))
267-# self.slide_controller.setItem(c , 0, twi)
268-# twi = QtGui.QTableWidgetItem(unicode(nm))
269-# self.slide_controller.setItem(c , 1, twi)
270-# self.slide_controller.setRowHeight(c, 80)
271-
272- # render the preview screen here
273-
274- def get_parent_node(self):
275- """
276- This method returns a parent node to be inserted into the Service
277- Manager.
278- """
279- pass
280- def add(self, data):
281- """
282- append an image to the list
283- """
284- if type(data)==type(u'string'):
285- log.info(u'add filename:'+data)
286- self.imgs.addRow(data)
287- else: # it's another service item to be merged in
288- log.info(u'add Item...'+unicode(data))
289- for filename in data.get_file_list():
290- self.add(filename)
291-
292-
293- def get_oos_text(self):
294- """
295- Turn the image list into a set of filenames for storage in the oos file
296- """
297- log.info(u'Get oos text')
298- log.info(unicode(self.imgs))
299-# log.info(unicode(self.imgs.get_file_list()))
300- return '\n'.join(self.imgs.get_file_list())
301-
302- def set_from_oos(self, text):
303- """
304- get text from the OOS file and setup the internal structure
305- """
306- log.info(u'Set from OOS:'+text)
307- files=text.split(u'\n')
308- for f in files:
309- self.imgs.addRow(f)
310
311=== modified file 'openlp/plugins/images/lib/listwithpreviews.py'
312--- openlp/plugins/images/lib/listwithpreviews.py 2009-06-16 18:21:24 +0000
313+++ openlp/plugins/images/lib/listwithpreviews.py 2009-06-19 18:41:38 +0000
314@@ -5,11 +5,11 @@
315 Copyright (c) 2008 Raoul Snyman
316 Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley
317
318-This program is free software; you can redistribute it and/or modify it under
319+This program is free software; you can rediunicodeibute it and/or modify it under
320 the terms of the GNU General Public License as published by the Free Software
321 Foundation; version 2 of the License.
322
323-This program is distributed in the hope that it will be useful, but WITHOUT ANY
324+This program is diunicodeibuted in the hope that it will be useful, but WITHOUT ANY
325 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
326 PARTICULAR PURPOSE. See the GNU General Public License for more details.
327
328@@ -21,10 +21,9 @@
329 import logging
330 from PyQt4 import QtCore, QtGui
331
332-
333 class ListWithPreviews(QtCore.QAbstractListModel):
334 """
335- An abstract list of strings and the preview icon to go with them
336+ An abstract list of unicodeings and the preview icon to go with them
337 """
338 global log
339 log = logging.getLogger(u'ListWithPreviews')
340@@ -32,7 +31,8 @@
341
342 def __init__(self):
343 QtCore.QAbstractListModel.__init__(self)
344- self.items = [] # will be a list of (full filename, QPixmap, shortname) tuples
345+ # will be a list of (full filename, QPixmap, shortname) tuples
346+ self.items = []
347 self.rowheight = 50
348 self.maximagewidth = self.rowheight*16/9.0;
349
350@@ -41,10 +41,10 @@
351
352 def insertRow(self, row, filename):
353 self.beginInsertRows(QtCore.QModelIndex(),row,row)
354- log.info(u'insert row %d:%s'% (row,filename))
355+ #log.info(u'insert row %d:%s' % (row,filename))
356 # get short filename to display next to image
357 (prefix, shortfilename) = os.path.split(unicode(filename))
358- log.info(u'shortfilename=%s'% (shortfilename))
359+ #log.info(u'shortfilename=%s' % (shortfilename))
360 # create a preview image
361 if os.path.exists(filename):
362 preview = QtGui.QPixmap(unicode(filename))
363
364=== modified file 'openlp/plugins/images/lib/mediaitem.py'
365--- openlp/plugins/images/lib/mediaitem.py 2009-06-16 18:21:24 +0000
366+++ openlp/plugins/images/lib/mediaitem.py 2009-06-19 18:41:38 +0000
367@@ -122,7 +122,7 @@
368 files = QtGui.QFileDialog.getOpenFileNames(None,
369 translate(u'ImageMediaItem', u'Select Image(s)'),
370 self.parent.config.get_last_dir(),
371- u'Images (*.jpg *.gif *.png *.bmp)')
372+ u'Images (*.jpg *jpeg *.gif *.png *.bmp)')
373 log.info(u'New image(s)', unicode(files))
374 if len(files) > 0:
375 self.loadImageList(files)
376@@ -169,4 +169,4 @@
377 service_item = ServiceItem(self.parent)
378 service_item.addIcon(u':/media/media_image.png')
379 self.generateSlideData(service_item)
380- self.parent.service_manager.addServiceItem(service_item)
381\ No newline at end of file
382+ self.parent.service_manager.addServiceItem(service_item)
383
384=== modified file 'openlp/plugins/songs/lib/mediaitem.py'
385--- openlp/plugins/songs/lib/mediaitem.py 2009-06-16 18:21:24 +0000
386+++ openlp/plugins/songs/lib/mediaitem.py 2009-06-19 18:41:38 +0000
387@@ -209,16 +209,18 @@
388
389 def onSongEditClick(self):
390 item = self.SongListWidget.currentItem()
391- item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
392- self.edit_song_form.loadSong(item_id)
393- self.edit_song_form.exec_()
394+ if item is not None:
395+ item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
396+ self.edit_song_form.loadSong(item_id)
397+ self.edit_song_form.exec_()
398
399 def onSongDeleteClick(self):
400 item = self.SongListWidget.currentItem()
401- item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
402- self.parent.songmanager.delete_song(item_id)
403- row = self.SongListWidget.row(item)
404- self.SongListWidget.takeItem(row)
405+ if item is not None:
406+ item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
407+ self.parent.songmanager.delete_song(item_id)
408+ row = self.SongListWidget.row(item)
409+ self.SongListWidget.takeItem(row)
410
411 def onSongPreviewClick(self):
412 service_item = ServiceItem(self.parent)