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

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

Tested with new Config code and still works.
Songs now have Authors / Topics and SongBook tabs working and attached (issue with deleting last row though)
Bible bug fixes and cleanups following initial testing.
Songs now talk to ServiceManager so can be rendered.
Songs plugin much more standard than before but much more to do.

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

Looks fine. Just 2 things though.

Firstly, coding standards - but I understand that this is "legacy" code, so that's fine.

Secondly, if you're working on the songs plugin, rather create a new branch off trunk with an appropriate name (like "songsplugin"). It's the reason we went with Bazaar :-)

review: Approve
lp:~trb143/openlp/servicing updated
486. By Tim Bentley

From Head

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'openlp/core/lib/eventreceiver.py'
2--- openlp/core/lib/eventreceiver.py 2009-05-20 20:17:20 +0000
3+++ openlp/core/lib/eventreceiver.py 2009-06-04 16:14:10 +0000
4@@ -28,7 +28,7 @@
5 QtCore.QObject.__init__(self)
6
7 def send_message(self, event, msg=None):
8- self.emit(SIGNAL(event), msg)
9+ self.emit(QtCore.SIGNAL(event), msg)
10
11 def received(self, msg=None):
12 print msg
13
14=== modified file 'openlp/core/lib/renderer.py'
15--- openlp/core/lib/renderer.py 2009-06-02 16:25:36 +0000
16+++ openlp/core/lib/renderer.py 2009-06-03 15:38:14 +0000
17@@ -109,7 +109,7 @@
18 """
19 External API to sort out the text to pe placed on the frame
20 """
21- #print "########## Format Slide ##################"
22+ print "########## Format Slide ##################"
23 log.debug(u'format_slide %s', words)
24 verses = []
25 words = words.replace("\r\n", "\n")
26@@ -121,8 +121,8 @@
27 text.append(line)
28
29 split_text = self._split_set_of_lines(text, False)
30- #print "split text ", split_text
31- #print "text ", text
32+ print "split text ", split_text
33+ print "text ", text
34 return split_text
35
36 # def render_screen(self, screennum):
37
38=== modified file 'openlp/core/lib/serviceitem.py'
39--- openlp/core/lib/serviceitem.py 2009-06-02 16:25:36 +0000
40+++ openlp/core/lib/serviceitem.py 2009-06-04 16:14:10 +0000
41@@ -65,7 +65,6 @@
42 if len(self.frames) == 0 and len(self.raw_slides) > 0 :
43 for slide in self.raw_slides:
44 formated = self.plugin.render_manager.format_slide(slide)
45- #print formated
46 for format in formated:
47 frame = self.plugin.render_manager.generate_slide(format, self.raw_footer)
48 self.frames.append({u'title': format, u'image': frame})
49
50=== modified file 'openlp/core/ui/servicemanager.py'
51--- openlp/core/ui/servicemanager.py 2009-06-01 17:50:37 +0000
52+++ openlp/core/ui/servicemanager.py 2009-06-04 16:14:10 +0000
53@@ -132,7 +132,7 @@
54 def addServiceItem(self, item):
55 self.serviceItems.append({u'data': item, u'order': len(self.serviceItems)+1})
56 treewidgetitem = QtGui.QTreeWidgetItem(self.ServiceManagerList)
57- treewidgetitem.setText(0,item.title + u':' + item.shortname)
58+ treewidgetitem.setText(0,item.title) # + u':' + item.shortname)
59 treewidgetitem.setIcon(0,item.iconic_representation)
60 treewidgetitem.setData(0, QtCore.Qt.UserRole, QtCore.QVariant(len(self.serviceItems)))
61 treewidgetitem.setExpanded(True)
62
63=== modified file 'openlp/core/ui/slidecontroller.py'
64--- openlp/core/ui/slidecontroller.py 2009-06-02 19:02:12 +0000
65+++ openlp/core/ui/slidecontroller.py 2009-06-04 19:00:41 +0000
66@@ -53,7 +53,7 @@
67 self.beginInsertRows(QtCore.QModelIndex(), row, row)
68 log.info(u'insert row %d' % row)
69 # create a preview image
70- frame1 = frame.scaled(QtCore.QSize(300, 225), QtCore.Qt.KeepAspectRatio,
71+ frame1 = frame.scaled(QtCore.QSize(280, 210), QtCore.Qt.KeepAspectRatio,
72 QtCore.Qt.SmoothTransformation)
73 self.items.insert(row, (frame1, framenumber))
74 log.info(u'Items: %s' % self.items)
75@@ -196,7 +196,7 @@
76 sizePolicy.setHeightForWidth(
77 self.SlidePreview.sizePolicy().hasHeightForWidth())
78 self.SlidePreview.setSizePolicy(sizePolicy)
79- self.SlidePreview.setMinimumSize(QtCore.QSize(250, 190))
80+ self.SlidePreview.setMinimumSize(QtCore.QSize(280, 210))
81 self.SlidePreview.setFrameShape(QtGui.QFrame.Box)
82 self.SlidePreview.setFrameShadow(QtGui.QFrame.Plain)
83 self.SlidePreview.setLineWidth(1)
84
85=== modified file 'openlp/plugins/bibles/forms/bibleimportform.py'
86--- openlp/plugins/bibles/forms/bibleimportform.py 2009-03-19 17:31:33 +0000
87+++ openlp/plugins/bibles/forms/bibleimportform.py 2009-06-05 05:00:26 +0000
88@@ -23,19 +23,16 @@
89 import time
90 import logging
91
92-from openlp.core.resources import *
93-
94 from PyQt4 import QtCore, QtGui
95-from PyQt4.QtGui import QDialog
96
97 from bibleimportdialog import Ui_BibleImportDialog
98-from openlp.core.lib import Receiver
99-
100-
101-class BibleImportForm(QDialog, Ui_BibleImportDialog):
102+from openlp.core.lib import Receiver, translate
103+
104+
105+class BibleImportForm(QtGui.QDialog, Ui_BibleImportDialog):
106 global log
107 log=logging.getLogger("BibleImportForm")
108- log.info("BibleImportForm loaded")
109+ log.info("BibleImportForm loaded")
110 """
111 Class documentation goes here.
112 """
113@@ -43,7 +40,7 @@
114 """
115 Constructor
116 """
117- QDialog.__init__(self, parent)
118+ QtGui.QDialog.__init__(self, parent)
119 self.setupUi(self)
120 self.biblemanager = biblemanager
121 self.config = config
122@@ -53,9 +50,9 @@
123 self.AddressEdit.setText(self.config.get_config("proxy_address", ""))
124 self.UsernameEdit.setText(self.config.get_config("proxy_username", ""))
125 self.PasswordEdit.setText(self.config.get_config("proxy_password",""))
126-
127+
128 filepath = os.path.split(os.path.abspath(__file__))[0]
129- filepath = os.path.abspath(os.path.join(filepath, '..', 'resources','crosswalkbooks.csv'))
130+ filepath = os.path.abspath(os.path.join(filepath, '..', 'resources','crosswalkbooks.csv'))
131 fbibles=open(filepath, 'r')
132 self.bible_versions = {}
133 self.BibleComboBox.clear()
134@@ -64,125 +61,136 @@
135 p = line.split(",")
136 self.bible_versions[p[0]] = p[1].replace('\n', '')
137 self.BibleComboBox.addItem(str(p[0]))
138-
139+
140 #Combo Boxes
141 QtCore.QObject.connect(self.LocationComboBox, QtCore.SIGNAL("activated(int)"), self.onLocationComboBoxSelected)
142 QtCore.QObject.connect(self.BibleComboBox, QtCore.SIGNAL("activated(int)"), self.onBibleComboBoxSelected)
143
144- #Buttons
145- QtCore.QObject.connect(self.ImportButton, QtCore.SIGNAL("pressed()"), self.onImportButtonClicked)
146+ #Buttons
147+ QtCore.QObject.connect(self.ImportButton, QtCore.SIGNAL("pressed()"), self.onImportButtonClicked)
148 QtCore.QObject.connect(self.CancelButton, QtCore.SIGNAL("pressed()"), self.onCancelButtonClicked)
149 QtCore.QObject.connect(self.VersesFileButton, QtCore.SIGNAL("pressed()"), self.onVersesFileButtonClicked)
150 QtCore.QObject.connect(self.BooksFileButton, QtCore.SIGNAL("pressed()"), self.onBooksFileButtonClicked)
151- QtCore.QObject.connect(self.OsisFileButton, QtCore.SIGNAL("pressed()"), self.onOsisFileButtonClicked)
152-
153+ QtCore.QObject.connect(self.OsisFileButton, QtCore.SIGNAL("pressed()"), self.onOsisFileButtonClicked)
154+
155 #Lost Focus
156 QtCore.QObject.connect(self.OSISLocationEdit, QtCore.SIGNAL("lostFocus()"), self.onOSISLocationEditLostFocus)
157 QtCore.QObject.connect(self.BooksLocationEdit, QtCore.SIGNAL("lostFocus()"),self.onBooksLocationEditLostFocus)
158 QtCore.QObject.connect(self.VerseLocationEdit, QtCore.SIGNAL("lostFocus()"), self.onVerseLocationEditLostFocus)
159 QtCore.QObject.connect(self.AddressEdit, QtCore.SIGNAL("lostFocus()"), self.onProxyAddressEditLostFocus)
160 QtCore.QObject.connect(self.UsernameEdit, QtCore.SIGNAL("lostFocus()"), self.onProxyUsernameEditLostFocus)
161- QtCore.QObject.connect(self.PasswordEdit, QtCore.SIGNAL("lostFocus()"), self.onProxyPasswordEditLostFocus)
162+ QtCore.QObject.connect(self.PasswordEdit, QtCore.SIGNAL("lostFocus()"), self.onProxyPasswordEditLostFocus)
163
164
165 def onVersesFileButtonClicked(self):
166 filename = QtGui.QFileDialog.getOpenFileName(self, 'Open file',self.config.get_last_dir(1))
167 if filename != "":
168- self.VerseLocationEdit.setText(filename)
169+ self.VerseLocationEdit.setText(filename)
170 self.config.set_last_dir(filename, 1)
171- self.setCsv()
172-
173+ self.setCsv()
174+
175 def onBooksFileButtonClicked(self):
176 filename = QtGui.QFileDialog.getOpenFileName(self, 'Open file',self.config.get_last_dir(2))
177- if filename != "":
178- self.BooksLocationEdit.setText(filename)
179+ if filename != "":
180+ self.BooksLocationEdit.setText(filename)
181 self.config.set_last_dir(filename, 2)
182- self.setCsv()
183-
184+ self.setCsv()
185+
186 def onOsisFileButtonClicked(self):
187 filename = QtGui.QFileDialog.getOpenFileName(self, 'Open file',self.config.get_last_dir(3))
188- if filename != "":
189+ if filename != "":
190 self.OSISLocationEdit.setText(filename)
191 self.config.set_last_dir(filename, 3)
192 self.setOsis()
193-
194+
195 def onOSISLocationEditLostFocus(self):
196 if len(self.OSISLocationEdit.displayText() ) > 0:
197 self.setOsis()
198 else:
199- if self.bible_type == "OSIS": # Was OSIS and is not any more stops lostFocus running mad
200- self.bible_type = None
201+ # Was OSIS and is not any more stops lostFocus running mad
202+ if self.bible_type == "OSIS":
203+ self.bible_type = None
204 self.freeAll()
205-
206+
207 def onBooksLocationEditLostFocus(self):
208 self.checkOsis()
209-
210+
211 def onVerseLocationEditLostFocus(self):
212 self.checkOsis()
213-
214+
215 def onProxyAddressEditLostFocus(self):
216 self.config.set_config("proxy_address", str(self.AddressEdit.displayText()))
217
218 def onProxyUsernameEditLostFocus(self):
219 self.config.set_config("proxy_username", str(self.UsernameEdit.displayText()))
220-
221+
222 def onProxyPasswordEditLostFocus(self):
223 self.config.set_config("proxy_password", str(self.PasswordEdit.displayText()))
224-
225+
226 def onLocationComboBoxSelected(self):
227- self.checkHttp()
228-
229+ self.checkHttp()
230+
231 def onBibleComboBoxSelected(self):
232 self.checkHttp()
233 self.BibleNameEdit.setText(str(self.BibleComboBox.currentText()))
234-
235+
236 def onCancelButtonClicked(self):
237 # tell import to stop
238- Receiver().send_message("openlpstopimport")
239+ Receiver().send_message("openlpstopimport")
240 # tell bibleplugin to reload the bibles
241 Receiver().send_message("openlpreloadbibles")
242- self.close()
243-
244+ self.close()
245+
246 def onImportButtonClicked(self):
247 if self.biblemanager != None:
248 if not self.bible_type == None and len(self.BibleNameEdit.displayText()) > 0:
249 self.MessageLabel.setText("Import Started")
250- self.ProgressBar.setMinimum(0)
251+ self.ProgressBar.setMinimum(0)
252 self.setMax(65)
253 self.ProgressBar.setValue(0)
254 self.biblemanager.process_dialog(self)
255 self.importBible()
256 self.MessageLabel.setText("Import Complete")
257- self.ProgressBar.setValue(self.barmax)
258+ self.ProgressBar.setValue(self.barmax)
259 # tell bibleplugin to reload the bibles
260- Receiver().send_message("openlpreloadbibles")
261+ Receiver().send_message("openlpreloadbibles")
262+ message = u'Bible import completered'
263+ reply = QtGui.QMessageBox.information(self,
264+ translate(u'BibleMediaItem', u'Information'),
265+ translate(u'BibleMediaItem', message))
266
267 def setMax(self, max):
268- log.debug("set Max %s", max)
269+ log.debug("set Max %s", max)
270 self.barmax = max
271- self.ProgressBar.setMaximum(max)
272+ self.ProgressBar.setMaximum(max)
273
274 def incrementProgressBar(self, text ):
275 log.debug("IncrementBar %s", text)
276 self.MessageLabel.setText("Import processing " + text)
277 self.ProgressBar.setValue(self.ProgressBar.value()+1)
278-
279+
280 def importBible(self):
281 log.debug("Import Bible ")
282 if self.bible_type == "OSIS":
283- self.biblemanager.register_osis_file_bible(str(self.BibleNameEdit.displayText()), self.OSISLocationEdit.displayText())
284+ loaded = self.biblemanager.register_osis_file_bible(str(self.BibleNameEdit.displayText()),
285+ self.OSISLocationEdit.displayText())
286 elif self.bible_type == "CSV":
287- self.biblemanager.register_csv_file_bible(str(self.BibleNameEdit.displayText()), self.BooksLocationEdit.displayText(), self.VerseLocationEdit.displayText())
288+ loaded = self.biblemanager.register_csv_file_bible(str(self.BibleNameEdit.displayText()),
289+ self.BooksLocationEdit.displayText(), self.VerseLocationEdit.displayText())
290 else:
291 self.setMax(1) # set a value as it will not be needed
292 bible = self.bible_versions[str(self.BibleComboBox.currentText())]
293- self.biblemanager.register_http_bible(str(self.BibleComboBox.currentText()), \
294+ loaded = self.biblemanager.register_http_bible(str(self.BibleComboBox.currentText()), \
295 str(self.LocationComboBox.currentText()), \
296 str(bible), \
297 str(self.AddressEdit.displayText()), \
298 str(self.UsernameEdit .displayText()), \
299- str(self.PasswordEdit.displayText()))
300- self.biblemanager.save_meta_data(str(self.BibleNameEdit.displayText()), str(self.VersionNameEdit.displayText()), str(self.CopyrightEdit.displayText()), str(self.PermisionEdit.displayText()))
301+ str(self.PasswordEdit.displayText()))
302+ if loaded:
303+ self.biblemanager.save_meta_data(str(self.BibleNameEdit.displayText()),
304+ str(self.VersionNameEdit.displayText()),
305+ str(self.CopyrightEdit.displayText()),
306+ str(self.PermisionEdit.displayText()))
307 self.bible_type = None
308 self.freeAll() # free the screen state restrictions
309 self.resetAll() # reset all the screen fields
310@@ -191,16 +199,18 @@
311 if len(self.BooksLocationEdit.displayText()) > 0 or len(self.VerseLocationEdit.displayText()) > 0:
312 self.setCsv()
313 else:
314- if self.bible_type == "CSV": # Was CSV and is not any more stops lostFocus running mad
315- self.bible_type = None
316+ # Was CSV and is not any more stops lostFocus running mad
317+ if self.bible_type == "CSV":
318+ self.bible_type = None
319 self.freeAll()
320-
321+
322 def checkHttp(self):
323 if self.BibleComboBox.currentIndex() != 0 : # First slot is blank so no bible
324 self.setHttp()
325 else:
326- if self.bible_type == "HTTP": # Was HTTP and is not any more stops lostFocus running mad
327- self.bible_type = None
328+ # Was HTTP and is not any more stops lostFocus running mad
329+ if self.bible_type == "HTTP":
330+ self.bible_type = None
331 self.freeAll()
332
333 def blockCsv(self):
334@@ -208,48 +218,48 @@
335 self.VerseLocationEdit.setReadOnly(True)
336 self.BooksFileButton.setEnabled(False)
337 self.VersesFileButton.setEnabled(False)
338-
339+
340 def setCsv(self):
341- self.bible_type = "CSV"
342+ self.bible_type = "CSV"
343 self.BooksLocationEdit.setReadOnly(False)
344- self.VerseLocationEdit.setReadOnly(False)
345+ self.VerseLocationEdit.setReadOnly(False)
346 self.BooksFileButton.setEnabled(True)
347 self.VersesFileButton.setEnabled(True)
348 self.blockOsis()
349- self.blockHttp()
350-
351+ self.blockHttp()
352+
353 def setOsis(self):
354- self.bible_type = "OSIS"
355+ self.bible_type = "OSIS"
356 self.OSISLocationEdit.setReadOnly(False)
357- self.OsisFileButton.setEnabled(True)
358+ self.OsisFileButton.setEnabled(True)
359 self.blockCsv()
360- self.blockHttp()
361-
362+ self.blockHttp()
363+
364 def blockOsis(self):
365 self.OSISLocationEdit.setReadOnly(True)
366 self.OsisFileButton.setEnabled(False)
367-
368+
369 def setHttp(self):
370- self.bible_type = "HTTP"
371+ self.bible_type = "HTTP"
372 self.LocationComboBox.setEnabled(True)
373- self.BibleComboBox.setEnabled(True)
374+ self.BibleComboBox.setEnabled(True)
375 self.blockCsv()
376- self.blockOsis()
377-
378+ self.blockOsis()
379+
380 def blockHttp(self):
381- self.LocationComboBox.setEnabled(False)
382- self.BibleComboBox.setEnabled(False)
383-
384+ self.LocationComboBox.setEnabled(False)
385+ self.BibleComboBox.setEnabled(False)
386+
387 def freeAll(self):
388- if self.bible_type == None: # only reset if no bible type set.
389+ if self.bible_type == None: # only reset if no bible type set.
390 self.BooksLocationEdit.setReadOnly(False)
391- self.VerseLocationEdit.setReadOnly(False)
392+ self.VerseLocationEdit.setReadOnly(False)
393 self.BooksFileButton.setEnabled(True)
394 self.VersesFileButton.setEnabled(True)
395 self.OSISLocationEdit.setReadOnly(False)
396- self.OsisFileButton.setEnabled(True)
397+ self.OsisFileButton.setEnabled(True)
398 self.LocationComboBox.setEnabled(True)
399- self.BibleComboBox.setEnabled(True)
400+ self.BibleComboBox.setEnabled(True)
401
402 def resetAll(self):
403 self.BooksLocationEdit.setText("")
404
405=== modified file 'openlp/plugins/bibles/lib/bibleDBimpl.py'
406--- openlp/plugins/bibles/lib/bibleDBimpl.py 2009-05-01 22:26:43 +0000
407+++ openlp/plugins/bibles/lib/bibleDBimpl.py 2009-06-05 05:00:26 +0000
408@@ -38,7 +38,7 @@
409 self.config = config
410 self.biblefile = os.path.join(biblepath, biblename+u'.sqlite')
411 log.debug( "Load bible %s on path %s", biblename, self.biblefile)
412- db_type = self.config.get_config(u'db type')
413+ db_type = self.config.get_config(u'db type', u'sqlite')
414 if db_type == u'sqlite':
415 self.db = create_engine("sqlite:///" + self.biblefile)
416 else:
417@@ -101,6 +101,7 @@
418 return book
419
420 def save_meta(self, key, value):
421+ log.debug( "save_meta %s/%s", key, value)
422 metadata.bind.echo = False
423 session = self.session()
424 bmeta= BibleMeta()
425
426=== modified file 'openlp/plugins/bibles/lib/bibleOSISimpl.py'
427--- openlp/plugins/bibles/lib/bibleOSISimpl.py 2009-03-16 17:33:51 +0000
428+++ openlp/plugins/bibles/lib/bibleOSISimpl.py 2009-06-04 20:06:32 +0000
429@@ -15,7 +15,7 @@
430 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
431 Place, Suite 330, Boston, MA 02111-1307 USA
432 """
433-import os
434+import os
435 import os.path
436 import logging
437 from openlp.plugins.bibles.lib.bibleDBimpl import BibleDBImpl
438@@ -23,28 +23,28 @@
439 from PyQt4 import QtCore
440
441 class BibleOSISImpl():
442- global log
443+ global log
444 log=logging.getLogger(u'BibleOSISImpl')
445 log.info(u'BibleOSISImpl loaded')
446-
447+
448 def __init__(self, biblepath, bibledb):
449 self.bibledb = bibledb
450 self.booksOfBible = {} # books of the bible linked to bibleid {osis , name}
451 self.abbrevOfBible = {} # books of the bible linked to bibleid {osis ,Abbrev }
452-
453+
454 filepath = os.path.split(os.path.abspath(__file__))[0]
455- filepath = os.path.abspath(os.path.join(filepath, '..', 'resources','osisbooks.csv'))
456+ filepath = os.path.abspath(os.path.join(filepath, '..', 'resources','osisbooks.csv'))
457 fbibles=open(filepath, 'r')
458 for line in fbibles:
459 p = line.split(",")
460 self.booksOfBible[p[0]] = p[1].replace('\n', '')
461- self.abbrevOfBible[p[0]] = p[2].replace('\n', '')
462+ self.abbrevOfBible[p[0]] = p[2].replace('\n', '')
463 self.loadbible = True
464 QtCore.QObject.connect(Receiver().get_receiver(),QtCore.SIGNAL("openlpstopimport"),self.stop_import)
465-
466+
467 def stop_import(self):
468 self.loadbible= False
469-
470+
471 def load_data(self, osisfile, dialogobject=None):
472 osis=open(osisfile, 'r')
473
474@@ -61,27 +61,27 @@
475 pos = file.find(verseText)
476 if pos > -1: # we have a verse
477 epos= file.find(">", pos)
478- ref = file[pos+15:epos-1] # Book Reference
479-
480+ ref = file[pos+15:epos-1] # Book Reference
481+
482 #lets find the bible text only
483 pos = epos + 1 # find start of text
484 epos = file.find("</verse>", pos) # end of text
485- text = file[pos : epos]
486+ text = unicode(file[pos : epos], u'utf8')
487 #print pos, e, f[pos:e] # Found Basic Text
488
489 #remove tags of extra information
490 text = self.remove_block(u'<title',u'</title>', text)
491- text = self.remove_block(u'<note',u'</note>', text)
492- text = self.remove_block(u'<divineName',u'</divineName>', text)
493-
494- text = self.remove_tag(u'<lb', text)
495- text = self.remove_tag(u'<q', text)
496- text = self.remove_tag(u'<l', text)
497- text = self.remove_tag(u'<lg', text)
498+ text = self.remove_block(u'<note',u'</note>', text)
499+ text = self.remove_block(u'<divineName',u'</divineName>', text)
500+
501+ text = self.remove_tag(u'<lb', text)
502+ text = self.remove_tag(u'<q', text)
503+ text = self.remove_tag(u'<l', text)
504+ text = self.remove_tag(u'<lg', text)
505
506 # Strange tags where the end is not the same as the start
507 # The must be in this order as at least one bible has them
508- # crossing and the removal does not work.
509+ # crossing and the removal does not work.
510 pos = text.find(u'<FI>')
511 while pos > -1:
512 epos = text.find(u'<Fi>', pos)
513@@ -90,7 +90,7 @@
514 pos = -1
515 else:
516 text = text[:pos] + text[epos + 4: ]
517- pos = text.find(u'<FI>')
518+ pos = text.find(u'<FI>')
519
520 pos = text.find(u'<RF>')
521 while pos > -1:
522@@ -98,9 +98,9 @@
523 text = text[:pos] + text[epos + 4: ]
524 #print "X", pos, epos, text
525 pos = text.find(u'<RF>')
526-
527+
528 p = ref.split(u'.', 3) # split up the reference
529- #print p, ">>>", text
530+ #print p, ">>>", text
531
532 if book_ptr != p[0]:
533 if book_ptr == None: # first time through
534@@ -113,14 +113,14 @@
535 book_ptr = p[0]
536 book = self.bibledb.create_book(self.booksOfBible[p[0]] , self.abbrevOfBible[p[0]], testament)
537 dialogobject.incrementProgressBar(self.booksOfBible[p[0]] )
538- Receiver().send_message("openlpprocessevents")
539+ Receiver().send_message("openlpprocessevents")
540 count = 0
541 self.bibledb.add_verse(book.id, p[1], p[2], text)
542 count += 1
543 if count % 3 == 0: #Every 3 verses repaint the screen
544- Receiver().send_message("openlpprocessevents")
545+ Receiver().send_message("openlpprocessevents")
546 count = 0
547-
548+
549 def remove_block(self, start_tag, end_tag, text):
550 """
551 removes a block of text between two tags
552@@ -134,9 +134,9 @@
553 pos = -1
554 else:
555 text = text[:pos] + text[epos + len(end_tag): ]
556- pos = text.find(start_tag)
557+ pos = text.find(start_tag)
558 return text
559-
560+
561 def remove_tag(self, start_tag, text):
562 """
563 removes a single tag
564@@ -146,5 +146,5 @@
565 while pos > -1:
566 epos = text.find(u'/>', pos)
567 text = text[:pos] + text[epos + 2: ]
568- pos = text.find(start_tag)
569+ pos = text.find(start_tag)
570 return text
571
572=== modified file 'openlp/plugins/bibles/lib/manager.py'
573--- openlp/plugins/bibles/lib/manager.py 2009-04-25 06:09:47 +0000
574+++ openlp/plugins/bibles/lib/manager.py 2009-06-05 05:00:26 +0000
575@@ -128,7 +128,10 @@
576 nbible.save_meta("proxyid", proxyid) # store the proxy userid
577 if proxypass != None and proxypass != "":
578 nbible.save_meta("proxypass", proxypass) # store the proxy password
579-
580+ return True
581+ else:
582+ log.debug( "register_http_file_bible %s not created already exists", biblename)
583+ return False
584
585 def register_csv_file_bible(self, biblename, booksfile, versefile):
586 """
587@@ -143,6 +146,10 @@
588 self.bible_db_cache[biblename] = nbible # cache the database for use later
589 bcsv = BibleCSVImpl(nbible) # create the loader and pass in the database
590 bcsv.load_data(booksfile, versefile, self.dialogobject)
591+ return True
592+ else:
593+ log.debug( "register_csv_file_bible %s not created already exists", biblename)
594+ return False
595
596 def register_osis_file_bible(self, biblename, osisfile):
597 """
598@@ -157,6 +164,10 @@
599 self.bible_db_cache[biblename] = nbible # cache the database for use later
600 bcsv = BibleOSISImpl(self.biblePath, nbible) # create the loader and pass in the database
601 bcsv.load_data(osisfile, self.dialogobject)
602+ return True
603+ else:
604+ log.debug( "register_OSIS_file_bible %s , %s not created already exists", biblename, osisfile)
605+ return False
606
607 def get_bibles(self, mode="full"):
608 log.debug("get_bibles")
609
610=== modified file 'openlp/plugins/bibles/lib/mediaitem.py'
611--- openlp/plugins/bibles/lib/mediaitem.py 2009-06-01 17:50:37 +0000
612+++ openlp/plugins/bibles/lib/mediaitem.py 2009-06-05 05:00:26 +0000
613@@ -283,7 +283,7 @@
614 self.initialiseBible(bible) # use the first bible as the trigger
615
616 def onAdvancedVersionComboBox(self):
617- self.initialiseBible(str(self.AdvancedVersionComboBox.currentText())) # restet the bible info
618+ self.initialiseBible(str(self.AdvancedVersionComboBox.currentText())) # reset the bible info
619
620 def onAdvancedBookComboBox(self):
621 self.initialiseBible(str(self.AdvancedVersionComboBox.currentText())) # reset the bible info
622@@ -291,7 +291,7 @@
623 def onBibleNewClick(self):
624 self.bibleimportform = BibleImportForm(self.parent.config, self.parent.biblemanager, self)
625 self.bibleimportform.exec_()
626- pass
627+ self.reloadBibles()
628
629 def onAdvancedFromVerse(self):
630 frm = self.AdvancedFromVerse.currentText()
631@@ -417,22 +417,14 @@
632
633 def initialiseBible(self, bible):
634 log.debug(u"initialiseBible %s", bible)
635- current_book = str(self.AdvancedBookComboBox.currentText())
636- chapter_count = self.parent.biblemanager.get_book_chapter_count(bible,
637- current_book)[0]
638- log.debug(u'Book change bible %s book %s ChapterCount %s', bible,
639- current_book, chapter_count)
640- if chapter_count == None:
641- # Only change the search details if the book is missing from the new bible
642- books = self.parent.biblemanager.get_bible_books(str(
643- self.AdvancedVersionComboBox.currentText()))
644- self.AdvancedBookComboBox.clear()
645- first = True
646- for book in books:
647- self.AdvancedBookComboBox.addItem(book.name)
648- if first:
649- first = False
650- self.initialiseChapterVerse(bible, book.name)
651+ books = self.parent.biblemanager.get_bible_books(str(bible))
652+ self.AdvancedBookComboBox.clear()
653+ first = True
654+ for book in books:
655+ self.AdvancedBookComboBox.addItem(book.name)
656+ if first:
657+ first = False
658+ self.initialiseChapterVerse(bible, book.name)
659
660 def initialiseChapterVerse(self, bible, book):
661 log.debug(u"initialiseChapterVerse %s , %s", bible, book)
662
663=== modified file 'openlp/plugins/custom/lib/__init__.py'
664--- openlp/plugins/custom/lib/__init__.py 2009-03-17 05:05:04 +0000
665+++ openlp/plugins/custom/lib/__init__.py 2009-06-03 15:38:14 +0000
666@@ -3,7 +3,7 @@
667 """
668 OpenLP - Open Source Lyrics Projection
669 Copyright (c) 2008 Raoul Snyman
670-Portions copyright (c) 2008 Martin Thompson, Tim Bentley
671+Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley
672
673 This program is free software; you can redistribute it and/or modify it under
674 the terms of the GNU General Public License as published by the Free Software
675@@ -23,6 +23,3 @@
676 from manager import CustomManager
677 from customtab import CustomTab
678 from mediaitem import CustomMediaItem
679-
680-__all__ = ['CustomManager', 'CustomTab', 'CustomMediaItem', 'CustomServiceItem','TextListData']
681-
682
683=== modified file 'openlp/plugins/custom/lib/mediaitem.py'
684--- openlp/plugins/custom/lib/mediaitem.py 2009-06-01 17:50:37 +0000
685+++ openlp/plugins/custom/lib/mediaitem.py 2009-06-03 15:38:14 +0000
686@@ -228,11 +228,11 @@
687 self.parent.service_manager.addServiceItem(service_item)
688
689 def generateSlideData(self, service_item):
690- indexes = self.CustomListView.selectedIndexes()
691 raw_slides =[]
692 raw_footer = []
693 slide = None
694 theme = None
695+ indexes = self.CustomListView.selectedIndexes()
696 for index in indexes:
697 id = self.CustomListData.getId(index)
698 customSlide = self.parent.custommanager.get_custom(id)
699
700=== modified file 'openlp/plugins/custom/lib/textlistdata.py'
701--- openlp/plugins/custom/lib/textlistdata.py 2009-05-21 16:07:01 +0000
702+++ openlp/plugins/custom/lib/textlistdata.py 2009-06-03 15:38:14 +0000
703@@ -1,3 +1,22 @@
704+# -*- coding: utf-8 -*-
705+# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
706+"""
707+OpenLP - Open Source Lyrics Projection
708+Copyright (c) 2008 Raoul Snyman
709+Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley
710+
711+This program is free software; you can redistribute it and/or modify it under
712+the terms of the GNU General Public License as published by the Free Software
713+Foundation; version 2 of the License.
714+
715+This program is distributed in the hope that it will be useful, but WITHOUT ANY
716+WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
717+PARTICULAR PURPOSE. See the GNU General Public License for more details.
718+
719+You should have received a copy of the GNU General Public License along with
720+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
721+Place, Suite 330, Boston, MA 02111-1307 USA
722+"""
723 import logging
724
725 from PyQt4 import QtCore, QtGui
726@@ -7,16 +26,16 @@
727 An abstract list of strings
728 """
729 global log
730- log=logging.getLogger(u'TextListData')
731+ log = logging.getLogger(u'TextListData')
732 log.info(u'started')
733
734 def __init__(self):
735 QtCore.QAbstractListModel.__init__(self)
736- self.items=[] # will be a list of (database id , title) tuples
737+ self.items = [] # will be a list of (database id , title) tuples
738
739 def resetStore(self):
740 #reset list so can be reloaded
741- self.items=[]
742+ self.items = []
743
744 def rowCount(self, parent):
745 return len(self.items)
746@@ -36,7 +55,7 @@
747 self.insertRow(len(self.items), id, title)
748
749 def data(self, index, role):
750- row=index.row()
751+ row = index.row()
752 if row > len(self.items): # if the last row is selected and deleted, we then get called with an empty row!
753 return QtCore.QVariant()
754 if role == QtCore.Qt.DisplayRole:
755
756=== modified file 'openlp/plugins/presentations/lib/mediaitem.py'
757--- openlp/plugins/presentations/lib/mediaitem.py 2009-05-22 18:30:25 +0000
758+++ openlp/plugins/presentations/lib/mediaitem.py 2009-06-04 16:14:10 +0000
759@@ -119,7 +119,7 @@
760 def onPresentationNewClick(self):
761 files = QtGui.QFileDialog.getOpenFileNames(None,
762 translate('PresentationsMediaItem', u'Select presentations(s)'),
763- self.parent.config.get_last_dir(), u'Presentations (*.ppt *.pps *.odi)')
764+ self.parent.config.get_last_dir(), u'Presentations (*.ppt *.pps *.odp)')
765 if len(files) > 0:
766 self.loadPresentationList(files)
767 dir, filename = os.path.split(str(files[0]))
768
769=== modified file 'openlp/plugins/songs/forms/__init__.py'
770--- openlp/plugins/songs/forms/__init__.py 2009-03-09 12:49:55 +0000
771+++ openlp/plugins/songs/forms/__init__.py 2009-06-03 17:32:53 +0000
772@@ -3,7 +3,7 @@
773 """
774 OpenLP - Open Source Lyrics Projection
775 Copyright (c) 2008 Raoul Snyman
776-Portions copyright (c) 2008 Martin Thompson, Tim Bentley,
777+Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley,
778
779 This program is free software; you can redistribute it and/or modify it under
780 the terms of the GNU General Public License as published by the Free Software
781
782=== modified file 'openlp/plugins/songs/forms/authorsdialog.py'
783--- openlp/plugins/songs/forms/authorsdialog.py 2009-03-09 18:47:37 +0000
784+++ openlp/plugins/songs/forms/authorsdialog.py 2009-06-04 19:00:41 +0000
785@@ -8,6 +8,7 @@
786 # WARNING! All changes made in this file will be lost!
787
788 from PyQt4 import QtCore, QtGui
789+from openlp.plugins.songs.lib import TextListData
790
791 class Ui_AuthorsDialog(object):
792 def setupUi(self, AuthorsDialog):
793@@ -17,14 +18,13 @@
794 self.DialogLayout.setSpacing(8)
795 self.DialogLayout.setMargin(8)
796 self.DialogLayout.setObjectName("DialogLayout")
797- self.AuthorListView = QtGui.QTableWidget(AuthorsDialog)
798- self.AuthorListView.setDragEnabled(True)
799+
800+ self.AuthorListView = QtGui.QListView()
801 self.AuthorListView.setAlternatingRowColors(True)
802- self.AuthorListView.setColumnCount(0)
803- self.AuthorListView.setObjectName("AuthorListView")
804- self.AuthorListView.setColumnCount(0)
805- self.AuthorListView.setRowCount(0)
806+ self.AuthorListData = TextListData()
807+ self.AuthorListView.setModel(self.AuthorListData)
808 self.DialogLayout.addWidget(self.AuthorListView)
809+
810 self.AuthorDetails = QtGui.QGroupBox(AuthorsDialog)
811 self.AuthorDetails.setMinimumSize(QtCore.QSize(0, 0))
812 self.AuthorDetails.setObjectName("AuthorDetails")
813@@ -107,7 +107,7 @@
814 self.FirstNameLabel.setText(QtGui.QApplication.translate("AuthorsDialog", "First Name:", None, QtGui.QApplication.UnicodeUTF8))
815 self.LastNameLabel.setText(QtGui.QApplication.translate("AuthorsDialog", "Last Name:", None, QtGui.QApplication.UnicodeUTF8))
816 self.ClearButton.setToolTip(QtGui.QApplication.translate("AuthorsDialog", "Clear Selection", None, QtGui.QApplication.UnicodeUTF8))
817- self.ClearButton.setText(QtGui.QApplication.translate("AuthorsDialog", "New", None, QtGui.QApplication.UnicodeUTF8))
818+ self.ClearButton.setText(QtGui.QApplication.translate("AuthorsDialog", "Clear", None, QtGui.QApplication.UnicodeUTF8))
819 self.AddUpdateButton.setToolTip(QtGui.QApplication.translate("AuthorsDialog", "Add Update Author", None, QtGui.QApplication.UnicodeUTF8))
820 self.AddUpdateButton.setText(QtGui.QApplication.translate("AuthorsDialog", "Save", None, QtGui.QApplication.UnicodeUTF8))
821 self.DeleteButton.setToolTip(QtGui.QApplication.translate("AuthorsDialog", "Delete Author", None, QtGui.QApplication.UnicodeUTF8))
822
823=== modified file 'openlp/plugins/songs/forms/authorsform.py'
824--- openlp/plugins/songs/forms/authorsform.py 2009-03-09 12:49:55 +0000
825+++ openlp/plugins/songs/forms/authorsform.py 2009-06-05 05:00:26 +0000
826@@ -2,7 +2,7 @@
827 """
828 OpenLP - Open Source Lyrics Projection
829 Copyright (c) 2008 Raoul Snyman
830-Portions copyright (c) 2008 Martin Thompson, Tim Bentley, Carsten Tinggaard
831+Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley, Carsten Tinggaard
832
833 This program is free software; you can redistribute it and/or modify it under
834 the terms of the GNU General Public License as published by the Free Software
835@@ -17,12 +17,9 @@
836 Place, Suite 330, Boston, MA 02111-1307 USA
837 """
838 from PyQt4 import QtGui, QtCore
839-from PyQt4.QtCore import pyqtSignature
840-
841-from openlp.core.resources import *
842-from openlp.plugins.songs.lib.classes import *
843
844 from openlp.plugins.songs.forms.authorsdialog import Ui_AuthorsDialog
845+from openlp.plugins.songs.lib import TextListData
846
847 class AuthorsForm(QtGui.QDialog, Ui_AuthorsDialog):
848 """
849@@ -35,57 +32,51 @@
850 QtGui.QDialog.__init__(self, parent)
851 self.setupUi(self)
852 self.songmanager = songmanager
853- self.AuthorListView.setColumnCount(2)
854- self.AuthorListView.setColumnHidden(0, True)
855- self.AuthorListView.setColumnWidth(1, 300)
856- #self.AuthorListView.setHorizontalHeaderLabels(QtCore.QStringList([" ","Author"]))
857- self.AuthorListView.horizontalHeader().setVisible(False)
858- self.AuthorListView.verticalHeader().setVisible(False)
859- self.currentrow = 0
860+ self.currentRow = 0
861 self.author = None
862
863+ QtCore.QObject.connect(self.DeleteButton,
864+ QtCore.SIGNAL('pressed()'), self.onDeleteButtonClick)
865+ QtCore.QObject.connect(self.ClearButton,
866+ QtCore.SIGNAL('pressed()'), self.onClearButtonClick)
867+ QtCore.QObject.connect(self.AddUpdateButton,
868+ QtCore.SIGNAL('pressed()'), self.onAddUpdateButtonClick)
869+ QtCore.QObject.connect(self.DisplayEdit,
870+ QtCore.SIGNAL('lostFocus()'), self.onDisplayEditLostFocus)
871+ QtCore.QObject.connect(self.AuthorListView,
872+ QtCore.SIGNAL(u'clicked(QModelIndex)'), self.onAuthorListViewItemClicked)
873+
874 def load_form(self):
875 """
876 Refresh the screen and rest fields
877 """
878- self.on_ClearButton_clicked() # tidy up screen
879+ self.AuthorListData.resetStore()
880+ self.onClearButtonClick() # tidy up screen
881 authors = self.songmanager.get_authors()
882- self.AuthorListView.clear() # clear the results
883- #self.AuthorListView.setHorizontalHeaderLabels(QtCore.QStringList([" ","Author"]))
884- self.AuthorListView.horizontalHeader().setVisible(False)
885- self.AuthorListView.verticalHeader().setVisible(False)
886- self.AuthorListView.setRowCount(0)
887 for author in authors:
888- row_count = self.AuthorListView.rowCount()
889- self.AuthorListView.setRowCount(row_count + 1)
890- author_id = QtGui.QTableWidgetItem(str(author.id))
891- self.AuthorListView.setItem(row_count, 0, author_id)
892- display_name = QtGui.QTableWidgetItem(author.display_name)
893- display_name.setFlags(QtCore.Qt.ItemIsSelectable)
894- self.AuthorListView.setItem(row_count, 1, display_name)
895- self.AuthorListView.setRowHeight(row_count, 20)
896- row_count = self.AuthorListView.rowCount()
897- if self.currentrow > row_count:
898+ self.AuthorListData.addRow(author.id,author.display_name)
899+ #rowCount is number of rows BUT test should be Zero based
900+ row_count = self.AuthorListData.rowCount(None) - 1
901+ if self.currentRow > row_count:
902 # in case we have delete the last row of the table
903- self.currentrow = row_count
904- self.AuthorListView.selectRow(self.currentrow) # set selected row to previous selected row
905+ self.currentRow = row_count
906+ row = self.AuthorListData.createIndex(self.currentRow, 0)
907+ if row.isValid():
908+ self.AuthorListView.selectionModel().setCurrentIndex(row,
909+ QtGui.QItemSelectionModel.SelectCurrent)
910 self._validate_form()
911
912- @pyqtSignature("")
913- def on_DeleteButton_clicked(self):
914+ def onDeleteButtonClick(self):
915 """
916 Delete the author is the Author is not attached to any songs
917 """
918 self.songmanager.delete_author(self.author.id)
919- self.on_ClearButton_clicked()
920 self.load_form()
921
922- @pyqtSignature("")
923- def on_DisplayEdit_lostFocus(self):
924+ def onDisplayEditLostFocus(self):
925 self._validate_form()
926
927- @pyqtSignature("")
928- def on_AddUpdateButton_clicked(self):
929+ def onAddUpdateButtonClick(self):
930 """
931 Sent New or update details to the database
932 """
933@@ -95,38 +86,33 @@
934 self.author.first_name = unicode(self.FirstNameEdit.displayText())
935 self.author.last_name = unicode(self.LastNameEdit.displayText())
936 self.songmanager.save_author(self.author)
937- self.on_ClearButton_clicked()
938+ self.onClearButtonClick()
939 self.load_form()
940- self._validate_form()
941-
942-
943- @pyqtSignature("")
944- def on_ClearButton_clicked(self):
945+
946+ def onClearButtonClick(self):
947 """
948 Tidy up screen if clear button pressed
949 """
950- self.DisplayEdit.setText("")
951- self.FirstNameEdit.setText("")
952- self.LastNameEdit.setText("")
953- self.MessageLabel.setText("")
954+ self.DisplayEdit.setText(u'')
955+ self.FirstNameEdit.setText(u'')
956+ self.LastNameEdit.setText(u'')
957+ self.MessageLabel.setText(u'')
958 self.DeleteButton.setEnabled(False)
959 self.author = None
960 self._validate_form()
961
962- @pyqtSignature("QTableWidgetItem*")
963- def on_AuthorListView_itemClicked(self, item):
964+ def onAuthorListViewItemClicked(self, index):
965 """
966 An Author has been selected display it
967 If the author is attached to a Song prevent delete
968 """
969- self.currentrow = self.AuthorListView.currentRow()
970- id = int(self.AuthorListView.item(self.currentrow, 0).text())
971+ self.currentRow = index.row()
972+ id = int(self.AuthorListData.getId(index))
973 self.author = self.songmanager.get_author(id)
974
975 self.DisplayEdit.setText(self.author.display_name)
976 self.FirstNameEdit.setText(self.author.first_name)
977 self.LastNameEdit.setText(self.author.last_name)
978- #songs = self.songmanager.get_song_authors_for_author(id)
979 if len(self.author.songs) > 0:
980 self.MessageLabel.setText("Author in use 'Delete' is disabled")
981 self.DeleteButton.setEnabled(False)
982@@ -136,7 +122,8 @@
983 self._validate_form()
984
985 def _validate_form(self):
986- if len(self.DisplayEdit.displayText()) == 0: # We need at lease a display name
987+ # We need at lease a display name
988+ if len(self.DisplayEdit.displayText()) == 0:
989 self.AddUpdateButton.setEnabled(False)
990 else:
991 self.AddUpdateButton.setEnabled(True)
992
993=== modified file 'openlp/plugins/songs/forms/editsongdialog.py'
994--- openlp/plugins/songs/forms/editsongdialog.py 2009-05-01 22:26:43 +0000
995+++ openlp/plugins/songs/forms/editsongdialog.py 2009-06-04 19:00:41 +0000
996@@ -61,6 +61,7 @@
997 self.VerseEditLayout.setObjectName("VerseEditLayout")
998 self.VerseListWidget = QtGui.QListWidget(self.VerseEditWidget)
999 self.VerseListWidget.setObjectName("VerseListWidget")
1000+ self.VerseListWidget.setAlternatingRowColors(True)
1001 self.VerseEditLayout.addWidget(self.VerseListWidget)
1002 self.VerseButtonWidget = QtGui.QWidget(self.VerseEditWidget)
1003 self.VerseButtonWidget.setObjectName("VerseButtonWidget")
1004@@ -108,10 +109,10 @@
1005 self.ThemeSelectionComboItem = QtGui.QComboBox(self.ThemeGroupBox)
1006 self.ThemeSelectionComboItem.setObjectName("ThemeSelectionComboItem")
1007 self.ThemeLayout.addWidget(self.ThemeSelectionComboItem)
1008- self.ThemeAddItem = QtGui.QPushButton(self.ThemeGroupBox)
1009- self.ThemeAddItem.setMaximumSize(QtCore.QSize(110, 16777215))
1010- self.ThemeAddItem.setObjectName("ThemeAddItem")
1011- self.ThemeLayout.addWidget(self.ThemeAddItem)
1012+# self.ThemeAddItem = QtGui.QPushButton(self.ThemeGroupBox)
1013+# self.ThemeAddItem.setMaximumSize(QtCore.QSize(110, 16777215))
1014+# self.ThemeAddItem.setObjectName("ThemeAddItem")
1015+# self.ThemeLayout.addWidget(self.ThemeAddItem)
1016 self.DetailsLayout.addWidget(self.ThemeGroupBox)
1017 self.TopLayout.addWidget(self.TextWidget)
1018 self.AdditionalWidget = QtGui.QWidget(self.TopWidget)
1019@@ -234,12 +235,12 @@
1020 self.AddTopicsToSongButton.setObjectName("AddTopicsToSongButton")
1021 self.TopicAddLayout.addWidget(self.AddTopicsToSongButton)
1022 self.TopicLayout.addWidget(self.TopicAddWidget)
1023- self.ToticsListView = QtGui.QTableWidget(self.TopicGroupBox)
1024- self.ToticsListView.setAlternatingRowColors(True)
1025- self.ToticsListView.setObjectName("ToticsListView")
1026- self.ToticsListView.setColumnCount(0)
1027- self.ToticsListView.setRowCount(0)
1028- self.TopicLayout.addWidget(self.ToticsListView)
1029+ self.TopicsListView = QtGui.QTableWidget(self.TopicGroupBox)
1030+ self.TopicsListView.setAlternatingRowColors(True)
1031+ self.TopicsListView.setObjectName("TopicsListView")
1032+ self.TopicsListView.setColumnCount(0)
1033+ self.TopicsListView.setRowCount(0)
1034+ self.TopicLayout.addWidget(self.TopicsListView)
1035 self.TopicRemoveWidget = QtGui.QWidget(self.TopicGroupBox)
1036 self.TopicRemoveWidget.setObjectName("TopicRemoveWidget")
1037 self.TopicRemoveLayout = QtGui.QHBoxLayout(self.TopicRemoveWidget)
1038@@ -305,15 +306,14 @@
1039 EditSongDialog.setTabOrder(self.AlternativeEdit, self.VerseOrderEdit)
1040 EditSongDialog.setTabOrder(self.VerseOrderEdit, self.CommentsEdit)
1041 EditSongDialog.setTabOrder(self.CommentsEdit, self.ThemeSelectionComboItem)
1042- EditSongDialog.setTabOrder(self.ThemeSelectionComboItem, self.ThemeAddItem)
1043- EditSongDialog.setTabOrder(self.ThemeAddItem, self.AuthorAddtoSongItem)
1044+ EditSongDialog.setTabOrder(self.ThemeSelectionComboItem, self.AuthorAddtoSongItem)
1045 EditSongDialog.setTabOrder(self.AuthorAddtoSongItem, self.AuthorsListView)
1046 EditSongDialog.setTabOrder(self.AuthorsListView, self.AuthorRemoveItem)
1047 EditSongDialog.setTabOrder(self.AuthorRemoveItem, self.SongbookCombo)
1048 EditSongDialog.setTabOrder(self.SongbookCombo, self.AddSongBookButton)
1049 EditSongDialog.setTabOrder(self.AddSongBookButton, self.SongTopicCombo)
1050- EditSongDialog.setTabOrder(self.SongTopicCombo, self.ToticsListView)
1051- EditSongDialog.setTabOrder(self.ToticsListView, self.pushButton)
1052+ EditSongDialog.setTabOrder(self.SongTopicCombo, self.TopicsListView)
1053+ EditSongDialog.setTabOrder(self.TopicsListView, self.pushButton)
1054 EditSongDialog.setTabOrder(self.pushButton, self.CopyrightEditItem)
1055 EditSongDialog.setTabOrder(self.CopyrightEditItem, self.CopyrightInsertItem)
1056 EditSongDialog.setTabOrder(self.CopyrightInsertItem, self.CCLNumberEdit)
1057@@ -330,7 +330,6 @@
1058 self.VerseOrderLabel.setText(QtGui.QApplication.translate("EditSongDialog", "Verse Order:", None, QtGui.QApplication.UnicodeUTF8))
1059 self.CommentsLabel.setText(QtGui.QApplication.translate("EditSongDialog", "Comments:", None, QtGui.QApplication.UnicodeUTF8))
1060 self.ThemeGroupBox.setTitle(QtGui.QApplication.translate("EditSongDialog", "Theme", None, QtGui.QApplication.UnicodeUTF8))
1061- self.ThemeAddItem.setText(QtGui.QApplication.translate("EditSongDialog", "Add a Theme", None, QtGui.QApplication.UnicodeUTF8))
1062 self.AuthorsGroupBox.setTitle(QtGui.QApplication.translate("EditSongDialog", "Authors", None, QtGui.QApplication.UnicodeUTF8))
1063 self.AuthorAddtoSongItem.setText(QtGui.QApplication.translate("EditSongDialog", "Add to Song", None, QtGui.QApplication.UnicodeUTF8))
1064 self.AuthorRemoveItem.setText(QtGui.QApplication.translate("EditSongDialog", "Remove", None, QtGui.QApplication.UnicodeUTF8))
1065
1066=== modified file 'openlp/plugins/songs/forms/editsongform.py'
1067--- openlp/plugins/songs/forms/editsongform.py 2009-03-09 18:47:37 +0000
1068+++ openlp/plugins/songs/forms/editsongform.py 2009-06-04 20:06:32 +0000
1069@@ -3,7 +3,7 @@
1070 """
1071 OpenLP - Open Source Lyrics Projection
1072 Copyright (c) 2008 Raoul Snyman
1073-Portions copyright (c) 2008 Martin Thompson, Tim Bentley,
1074+Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley,
1075
1076 This program is free software; you can redistribute it and/or modify it under
1077 the terms of the GNU General Public License as published by the Free Software
1078@@ -69,6 +69,8 @@
1079
1080 def initialise(self):
1081 self.loadAuthors()
1082+ self.loadTopics()
1083+ self.loadBooks()
1084
1085 def loadAuthors(self):
1086 authors = self.songmanager.get_authors()
1087@@ -76,6 +78,18 @@
1088 for author in authors:
1089 self.AuthorsSelectionComboItem.addItem(author.display_name)
1090
1091+ def loadTopics(self):
1092+ topics = self.songmanager.get_topics()
1093+ self.SongTopicCombo.clear()
1094+ for topic in topics:
1095+ self.SongTopicCombo.addItem(topic.name)
1096+
1097+ def loadBooks(self):
1098+ books = self.songmanager.get_books()
1099+ self.SongbookCombo.clear()
1100+ for book in books:
1101+ self.SongbookCombo.addItem(book.name)
1102+
1103 def loadSong(self, id):
1104 self.song = self.songmanager.get_song(id)
1105 self.TitleEditItem.setText(self.song.title)
1106@@ -111,6 +125,7 @@
1107 """
1108 self.topics_form.load_form()
1109 self.topics_form.exec_()
1110+ self.loadTopics()
1111
1112 def onAddSongBookButtonClicked(self):
1113 """
1114@@ -118,6 +133,7 @@
1115 """
1116 self.song_book_form.load_form()
1117 self.song_book_form.exec_()
1118+ self.loadBooks()
1119
1120 def onAddVerseButtonClicked(self):
1121 self.verse_form.setVerse('')
1122
1123=== modified file 'openlp/plugins/songs/forms/songbookdialog.py'
1124--- openlp/plugins/songs/forms/songbookdialog.py 2009-03-09 18:47:37 +0000
1125+++ openlp/plugins/songs/forms/songbookdialog.py 2009-06-04 20:06:32 +0000
1126@@ -8,6 +8,7 @@
1127 # WARNING! All changes made in this file will be lost!
1128
1129 from PyQt4 import QtCore, QtGui
1130+from openlp.plugins.songs.lib import TextListData
1131
1132 class Ui_SongBookDialog(object):
1133 def setupUi(self, SongBookDialog):
1134@@ -17,10 +18,13 @@
1135 self.DialogLayout.setSpacing(8)
1136 self.DialogLayout.setMargin(8)
1137 self.DialogLayout.setObjectName("DialogLayout")
1138- self.BookSongListView = QtGui.QTableWidget(SongBookDialog)
1139- self.BookSongListView.setObjectName("BookSongListView")
1140- self.BookSongListView.setColumnCount(0)
1141- self.BookSongListView.setRowCount(0)
1142+
1143+ self.BookSongListView = QtGui.QListView()
1144+ self.BookSongListView.setAlternatingRowColors(True)
1145+ self.BookSongListData = TextListData()
1146+ self.BookSongListView.setModel(self.BookSongListData)
1147+ self.DialogLayout.addWidget(self.BookSongListView)
1148+
1149 self.DialogLayout.addWidget(self.BookSongListView)
1150 self.SongBookGroup = QtGui.QGroupBox(SongBookDialog)
1151 self.SongBookGroup.setMinimumSize(QtCore.QSize(0, 200))
1152
1153=== modified file 'openlp/plugins/songs/forms/songbookform.py'
1154--- openlp/plugins/songs/forms/songbookform.py 2009-01-02 20:20:33 +0000
1155+++ openlp/plugins/songs/forms/songbookform.py 2009-06-05 05:00:26 +0000
1156@@ -2,7 +2,7 @@
1157 """
1158 OpenLP - Open Source Lyrics Projection
1159 Copyright (c) 2008 Raoul Snyman
1160-Portions copyright (c) 2008 Martin Thompson, Tim Bentley, Carsten Tinggaard
1161+Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley, Carsten Tinggaard
1162
1163 This program is free software; you can redistribute it and/or modify it under
1164 the terms of the GNU General Public License as published by the Free Software
1165@@ -17,45 +17,110 @@
1166 Place, Suite 330, Boston, MA 02111-1307 USA
1167 """
1168
1169-from openlp.core.resources import *
1170-
1171 from PyQt4 import QtGui, QtCore
1172-from PyQt4.QtGui import QDialog
1173-from PyQt4.QtCore import pyqtSignature
1174 from songbookdialog import Ui_SongBookDialog
1175+from openlp.plugins.songs.lib.classes import Book
1176
1177-class SongBookForm(QDialog, Ui_SongBookDialog):
1178+class SongBookForm(QtGui.QDialog, Ui_SongBookDialog):
1179 """
1180 Class documentation goes here.
1181 """
1182- def __init__(self,songmanager, parent = None):
1183+ def __init__(self, songmanager, parent = None):
1184 """
1185 Constructor
1186 """
1187- QDialog.__init__(self, parent)
1188+ QtGui.QDialog.__init__(self, parent)
1189 self.setupUi(self)
1190 self.songmanager = songmanager
1191-
1192+ self.currentRow = 0
1193+ self.songbook = None
1194+
1195+ QtCore.QObject.connect(self.DeleteButton,
1196+ QtCore.SIGNAL('pressed()'), self.onDeleteButtonClick)
1197+ QtCore.QObject.connect(self.ClearButton,
1198+ QtCore.SIGNAL('pressed()'), self.onClearButtonClick)
1199+ QtCore.QObject.connect(self.AddUpdateButton,
1200+ QtCore.SIGNAL('pressed()'), self.onAddUpdateButtonClick)
1201+ QtCore.QObject.connect(self.NameEdit,
1202+ QtCore.SIGNAL('lostFocus()'), self.onBookNameEditLostFocus)
1203+ QtCore.QObject.connect(self.BookSongListView,
1204+ QtCore.SIGNAL(u'clicked(QModelIndex)'), self.onBooksListViewItemClicked)
1205+
1206 def load_form(self):
1207- A = 1
1208-
1209- @pyqtSignature("QTableWidgetItem*")
1210- def on_BookSongListView_itemClicked(self, item):
1211- """
1212- Slot documentation goes here.
1213- """
1214- print "bslv ic " + str(item)
1215-
1216- @pyqtSignature("")
1217- def on_DeleteButton_clicked(self):
1218- """
1219- Slot documentation goes here.
1220- """
1221- print "db c "
1222-
1223- @pyqtSignature("")
1224- def on_AddUpdateButton_clicked(self):
1225- """
1226- Slot documentation goes here.
1227- """
1228- print "au c "
1229+ """
1230+ Refresh the screen and rest fields
1231+ """
1232+ self.BookSongListData.resetStore()
1233+ self.onClearButtonClick() # tidy up screen
1234+ Books = self.songmanager.get_books()
1235+ for Book in Books:
1236+ self.BookSongListData.addRow(Book.id,Book.name)
1237+ #rowCount is number of rows BUT test should be Zero based
1238+ row_count = self.BookSongListData.rowCount(None) - 1
1239+ if self.currentRow > row_count:
1240+ # in case we have delete the last row of the table
1241+ self.currentRow = row_count
1242+ row = self.BookSongListData.createIndex(self.currentRow, 0)
1243+ if row.isValid():
1244+ self.BookSongListView.selectionModel().setCurrentIndex(row,
1245+ QtGui.QItemSelectionModel.SelectCurrent)
1246+ self._validate_form()
1247+
1248+ def onDeleteButtonClick(self):
1249+ """
1250+ Delete the Book is the Book is not attached to any songs
1251+ """
1252+ self.songmanager.delete_book(self.Book.id)
1253+ self.load_form()
1254+
1255+ def onBookNameEditLostFocus(self):
1256+ self._validate_form()
1257+
1258+ def onAddUpdateButtonClick(self):
1259+ """
1260+ Sent New or update details to the database
1261+ """
1262+ if self.Book == None:
1263+ self.Book = Book()
1264+ self.Book.name = unicode(self.NameEdit.displayText())
1265+ self.Book.publisher = unicode(self.PublisherEdit.displayText())
1266+ self.songmanager.save_book(self.Book)
1267+ self.onClearButtonClick()
1268+ self.load_form()
1269+
1270+ def onClearButtonClick(self):
1271+ """
1272+ Tidy up screen if clear button pressed
1273+ """
1274+ self.NameEdit.setText(u'')
1275+ self.PublisherEdit.setText(u'')
1276+ self.MessageLabel.setText(u'')
1277+ self.DeleteButton.setEnabled(False)
1278+ self.AddUpdateButton.setEnabled(True)
1279+ self.Book = None
1280+ self._validate_form()
1281+
1282+ def onBooksListViewItemClicked(self, index):
1283+ """
1284+ An Book has been selected display it
1285+ If the Book is attached to a Song prevent delete
1286+ """
1287+ self.currentRow = index.row()
1288+ id = int(self.BookSongListData.getId(index))
1289+ self.Book = self.songmanager.get_book(id)
1290+
1291+ self.NameEdit.setText(self.Book.name)
1292+ self.PublisherEdit.setText(self.Book.publisher)
1293+ if len(self.Book.songs) > 0:
1294+ self.MessageLabel.setText("Book in use 'Delete' is disabled")
1295+ self.DeleteButton.setEnabled(False)
1296+ else:
1297+ self.MessageLabel.setText("Book is not used")
1298+ self.DeleteButton.setEnabled(True)
1299+ self._validate_form()
1300+
1301+ def _validate_form(self):
1302+ if len(self.NameEdit.displayText()) == 0: # We need at lease a display name
1303+ self.AddUpdateButton.setEnabled(False)
1304+ else:
1305+ self.AddUpdateButton.setEnabled(True)
1306
1307=== modified file 'openlp/plugins/songs/forms/topicsdialog.py'
1308--- openlp/plugins/songs/forms/topicsdialog.py 2009-01-06 18:59:47 +0000
1309+++ openlp/plugins/songs/forms/topicsdialog.py 2009-06-04 19:00:41 +0000
1310@@ -8,6 +8,7 @@
1311 # WARNING! All changes made in this file will be lost!
1312
1313 from PyQt4 import QtCore, QtGui
1314+from openlp.plugins.songs.lib import TextListData
1315
1316 class Ui_TopicsDialog(object):
1317 def setupUi(self, TopicsDialog):
1318@@ -35,13 +36,13 @@
1319 self.gridLayout.addWidget(self.DeleteButton, 1, 3, 1, 1)
1320 self.AddUpdateButton = QtGui.QPushButton(self.TopicGroupBox)
1321 icon1 = QtGui.QIcon()
1322- icon1.addPixmap(QtGui.QPixmap(":/system/system_settings.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
1323+ icon1.addPixmap(QtGui.QPixmap(":/services/service_save.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
1324 self.AddUpdateButton.setIcon(icon1)
1325 self.AddUpdateButton.setObjectName("AddUpdateButton")
1326 self.gridLayout.addWidget(self.AddUpdateButton, 1, 4, 1, 1)
1327 self.ClearButton = QtGui.QPushButton(self.TopicGroupBox)
1328 icon2 = QtGui.QIcon()
1329- icon2.addPixmap(QtGui.QPixmap(":/songs/song_edit.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
1330+ icon2.addPixmap(QtGui.QPixmap(":/services/service_new.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
1331 self.ClearButton.setIcon(icon2)
1332 self.ClearButton.setObjectName("ClearButton")
1333 self.gridLayout.addWidget(self.ClearButton, 1, 2, 1, 1)
1334@@ -49,11 +50,13 @@
1335 self.MessageLabel = QtGui.QLabel(TopicsDialog)
1336 self.MessageLabel.setObjectName("MessageLabel")
1337 self.gridLayout_2.addWidget(self.MessageLabel, 3, 0, 1, 1)
1338- self.TopicsListView = QtGui.QTableWidget(TopicsDialog)
1339- self.TopicsListView.setObjectName("TopicsListView")
1340- self.TopicsListView.setColumnCount(0)
1341- self.TopicsListView.setRowCount(0)
1342+
1343+ self.TopicsListView = QtGui.QListView()
1344+ self.TopicsListView.setAlternatingRowColors(True)
1345+ self.TopicsListData = TextListData()
1346+ self.TopicsListView.setModel(self.TopicsListData)
1347 self.gridLayout_2.addWidget(self.TopicsListView, 0, 0, 1, 1)
1348+
1349 self.ButtonBox = QtGui.QDialogButtonBox(TopicsDialog)
1350 self.ButtonBox.setOrientation(QtCore.Qt.Horizontal)
1351 self.ButtonBox.setStandardButtons(QtGui.QDialogButtonBox.Ok)
1352@@ -69,8 +72,11 @@
1353 TopicsDialog.setWindowTitle(QtGui.QApplication.translate("TopicsDialog", "Topic Maintenance", None, QtGui.QApplication.UnicodeUTF8))
1354 self.TopicGroupBox.setTitle(QtGui.QApplication.translate("TopicsDialog", "Topic", None, QtGui.QApplication.UnicodeUTF8))
1355 self.TopicNameLabel.setText(QtGui.QApplication.translate("TopicsDialog", "Topic Name:", None, QtGui.QApplication.UnicodeUTF8))
1356+
1357 self.DeleteButton.setToolTip(QtGui.QApplication.translate("TopicsDialog", "Delete Author", None, QtGui.QApplication.UnicodeUTF8))
1358+ self.DeleteButton.setText(QtGui.QApplication.translate("AuthorsDialog", "Delete", None, QtGui.QApplication.UnicodeUTF8))
1359 self.AddUpdateButton.setToolTip(QtGui.QApplication.translate("TopicsDialog", "Add Update Author", None, QtGui.QApplication.UnicodeUTF8))
1360+ self.AddUpdateButton.setText(QtGui.QApplication.translate("AuthorsDialog", "Save", None, QtGui.QApplication.UnicodeUTF8))
1361 self.ClearButton.setToolTip(QtGui.QApplication.translate("TopicsDialog", "Clear Selection", None, QtGui.QApplication.UnicodeUTF8))
1362-
1363+ self.ClearButton.setText(QtGui.QApplication.translate("TopicsDialog", "Clear", None, QtGui.QApplication.UnicodeUTF8))
1364
1365
1366=== modified file 'openlp/plugins/songs/forms/topicsform.py'
1367--- openlp/plugins/songs/forms/topicsform.py 2009-02-19 22:25:58 +0000
1368+++ openlp/plugins/songs/forms/topicsform.py 2009-06-05 05:00:26 +0000
1369@@ -2,7 +2,7 @@
1370 """
1371 OpenLP - Open Source Lyrics Projection
1372 Copyright (c) 2008 Raoul Snyman
1373-Portions copyright (c) 2008 Martin Thompson, Tim Bentley, Carsten Tinggaard
1374+Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley, Carsten Tinggaard
1375
1376 This program is free software; you can redistribute it and/or modify it under
1377 the terms of the GNU General Public License as published by the Free Software
1378@@ -16,15 +16,14 @@
1379 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
1380 Place, Suite 330, Boston, MA 02111-1307 USA
1381 """
1382-from openlp.core.resources import *
1383
1384 from PyQt4 import QtGui, QtCore
1385-from PyQt4.QtGui import QDialog
1386-from PyQt4.QtCore import pyqtSignature
1387-
1388-from topicsdialog import Ui_TopicsDialog
1389-
1390-class TopicsForm(QDialog, Ui_TopicsDialog):
1391+from openlp.plugins.songs.lib import TextListData
1392+
1393+from openlp.plugins.songs.forms.topicsdialog import Ui_TopicsDialog
1394+from openlp.plugins.songs.lib.classes import Topic
1395+
1396+class TopicsForm(QtGui.QDialog, Ui_TopicsDialog):
1397 """
1398 Class documentation goes here.
1399 """
1400@@ -32,24 +31,95 @@
1401 """
1402 Constructor
1403 """
1404- QDialog.__init__(self, parent)
1405+ QtGui.QDialog.__init__(self, parent)
1406 self.setupUi(self)
1407 self.songmanager = songmanager
1408- #self.connect()
1409+ self.currentRow = 0
1410+ self.topic = None
1411+
1412+ QtCore.QObject.connect(self.DeleteButton,
1413+ QtCore.SIGNAL('pressed()'), self.onDeleteButtonClick)
1414+ QtCore.QObject.connect(self.ClearButton,
1415+ QtCore.SIGNAL('pressed()'), self.onClearButtonClick)
1416+ QtCore.QObject.connect(self.AddUpdateButton,
1417+ QtCore.SIGNAL('pressed()'), self.onAddUpdateButtonClick)
1418+ QtCore.QObject.connect(self.TopicNameEdit,
1419+ QtCore.SIGNAL('lostFocus()'), self.onTopicNameEditLostFocus)
1420+ QtCore.QObject.connect(self.TopicsListView,
1421+ QtCore.SIGNAL(u'clicked(QModelIndex)'), self.onTopicsListViewItemClicked)
1422
1423 def load_form(self):
1424- A = 1
1425-
1426- #@pyqtSignature("")
1427- def onDeleteButtonClicked(self):
1428- """
1429- Slot documentation goes here.
1430- """
1431- print "db clicked"
1432-
1433- #@pyqtSignature("")
1434- def onAddUpdateButtonClicked(self):
1435- """
1436- Slot documentation goes here.
1437- """
1438- print "au clicked"
1439+ """
1440+ Refresh the screen and rest fields
1441+ """
1442+ self.TopicsListData.resetStore()
1443+ self.onClearButtonClick() # tidy up screen
1444+ topics = self.songmanager.get_topics()
1445+ for topic in topics:
1446+ self.TopicsListData.addRow(topic.id,topic.name)
1447+ #rowCount is number of rows BUT test should be Zero based
1448+ row_count = self.TopicsListData.rowCount(None) - 1
1449+ if self.currentRow > row_count:
1450+ # in case we have delete the last row of the table
1451+ self.currentRow = row_count
1452+ row = self.TopicsListData.createIndex(self.currentRow, 0)
1453+ if row.isValid():
1454+ self.TopicsListView.selectionModel().setCurrentIndex(row,
1455+ QtGui.QItemSelectionModel.SelectCurrent)
1456+ self._validate_form()
1457+
1458+ def onDeleteButtonClick(self):
1459+ """
1460+ Delete the Topic is the Topic is not attached to any songs
1461+ """
1462+ self.songmanager.delete_topic(self.topic.id)
1463+ self.load_form()
1464+
1465+ def onTopicNameEditLostFocus(self):
1466+ self._validate_form()
1467+
1468+ def onAddUpdateButtonClick(self):
1469+ """
1470+ Sent New or update details to the database
1471+ """
1472+ if self.topic == None:
1473+ self.topic = Topic()
1474+ self.topic.name = unicode(self.TopicNameEdit.displayText())
1475+ self.songmanager.save_topic(self.topic)
1476+ self.onClearButtonClick()
1477+ self.load_form()
1478+
1479+ def onClearButtonClick(self):
1480+ """
1481+ Tidy up screen if clear button pressed
1482+ """
1483+ self.TopicNameEdit.setText(u'')
1484+ self.MessageLabel.setText(u'')
1485+ self.DeleteButton.setEnabled(False)
1486+ self.AddUpdateButton.setEnabled(True)
1487+ self.topic = None
1488+ self._validate_form()
1489+
1490+ def onTopicsListViewItemClicked(self, index):
1491+ """
1492+ An Topic has been selected display it
1493+ If the Topic is attached to a Song prevent delete
1494+ """
1495+ self.currentRow = index.row()
1496+ id = int(self.TopicsListData.getId(index))
1497+ self.topic = self.songmanager.get_topic(id)
1498+
1499+ self.TopicNameEdit.setText(self.topic.name)
1500+ if len(self.topic.songs) > 0:
1501+ self.MessageLabel.setText("Topic in use 'Delete' is disabled")
1502+ self.DeleteButton.setEnabled(False)
1503+ else:
1504+ self.MessageLabel.setText("Topic is not used")
1505+ self.DeleteButton.setEnabled(True)
1506+ self._validate_form()
1507+
1508+ def _validate_form(self):
1509+ if len(self.TopicNameEdit.displayText()) == 0: # We need at lease a display name
1510+ self.AddUpdateButton.setEnabled(False)
1511+ else:
1512+ self.AddUpdateButton.setEnabled(True)
1513
1514=== modified file 'openlp/plugins/songs/lib/__init__.py'
1515--- openlp/plugins/songs/lib/__init__.py 2009-03-09 12:49:55 +0000
1516+++ openlp/plugins/songs/lib/__init__.py 2009-06-03 15:38:14 +0000
1517@@ -3,7 +3,7 @@
1518 """
1519 OpenLP - Open Source Lyrics Projection
1520 Copyright (c) 2008 Raoul Snyman
1521-Portions copyright (c) 2008 Martin Thompson, Tim Bentley
1522+Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley
1523
1524 This program is free software; you can redistribute it and/or modify it under
1525 the terms of the GNU General Public License as published by the Free Software
1526@@ -17,10 +17,7 @@
1527 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
1528 Place, Suite 330, Boston, MA 02111-1307 USA
1529 """
1530-
1531+from textlistdata import TextListData
1532 from manager import SongManager
1533 from songstab import SongsTab
1534 from mediaitem import SongMediaItem
1535-#from xml import SongOpenXml
1536-
1537-#__all__ = ['SongManager', 'SongsTab', 'SongMediaItem']
1538
1539=== modified file 'openlp/plugins/songs/lib/manager.py'
1540--- openlp/plugins/songs/lib/manager.py 2009-02-19 22:25:58 +0000
1541+++ openlp/plugins/songs/lib/manager.py 2009-06-04 20:06:32 +0000
1542@@ -3,7 +3,7 @@
1543 """
1544 OpenLP - Open Source Lyrics Projection
1545 Copyright (c) 2008 Raoul Snyman
1546-Portions copyright (c) 2008 Martin Thompson, Tim Bentley
1547+Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley
1548
1549 This program is free software; you can redistribute it and/or modify it under
1550 the terms of the GNU General Public License as published by the Free Software
1551@@ -23,7 +23,7 @@
1552
1553 from sqlalchemy import asc, desc
1554 from openlp.plugins.songs.lib.models import init_models, metadata, session, \
1555- engine, songs_table, Song, Author, Topic
1556+ engine, songs_table, Song, Author, Topic, Book
1557
1558 import logging
1559
1560@@ -34,7 +34,7 @@
1561 """
1562
1563 global log
1564- log=logging.getLogger('SongManager')
1565+ log = logging.getLogger('SongManager')
1566 log.info('Song manager loaded')
1567
1568 def __init__(self, config):
1569@@ -45,7 +45,7 @@
1570 self.config = config
1571 log.debug('Song Initialising')
1572 self.db_url = u''
1573- db_type = self.config.get_config(u'db type')
1574+ db_type = self.config.get_config(u'db type', u'sqlite')
1575 if db_type == u'sqlite':
1576 self.db_url = u'sqlite:///' + self.config.get_data_path() + \
1577 u'/songs.sqlite'
1578@@ -134,11 +134,85 @@
1579
1580 def delete_author(self, authorid):
1581 """
1582- Delete the author and refresh the author cache
1583+ Delete the author
1584 """
1585+ author = self.get_author(authorid)
1586 try:
1587 self.session.delete(author)
1588 self.session.commit()
1589 return True
1590 except:
1591+ log.error("Errow thrown %s", sys.exc_info()[1])
1592+ return False
1593+
1594+ def get_topics(self):
1595+ """
1596+ Returns a list of all the topics
1597+ """
1598+ return self.session.query(Topic).order_by(Topic.name).all()
1599+
1600+ def get_topic(self, id):
1601+ """
1602+ Details of the Topic
1603+ """
1604+ return self.session.query(Topic).get(id)
1605+
1606+ def save_topic(self, topic):
1607+ """
1608+ Save the Topic
1609+ """
1610+ try:
1611+ self.session.add(topic)
1612+ self.session.commit()
1613+ return True
1614+ except:
1615+ return False
1616+
1617+ def delete_topic(self, topicid):
1618+ """
1619+ Delete the topic
1620+ """
1621+ topic = self.get_topic(topicid)
1622+ try:
1623+ self.session.delete(topic)
1624+ self.session.commit()
1625+ return True
1626+ except:
1627+ log.error("Errow thrown %s", sys.exc_info()[1])
1628+ return False
1629+
1630+ def get_books(self):
1631+ """
1632+ Returns a list of all the Books
1633+ """
1634+ return self.session.query(Book).order_by(Book.name).all()
1635+
1636+ def get_book(self, id):
1637+ """
1638+ Details of the Books
1639+ """
1640+ return self.session.query(Book).get(id)
1641+
1642+ def save_book(self, book):
1643+ """
1644+ Save the Book
1645+ """
1646+ try:
1647+ self.session.add(book)
1648+ self.session.commit()
1649+ return True
1650+ except:
1651+ return False
1652+
1653+ def delete_book(self, bookid):
1654+ """
1655+ Delete the Book
1656+ """
1657+ book = self.get_book(bookid)
1658+ try:
1659+ self.session.delete(book)
1660+ self.session.commit()
1661+ return True
1662+ except:
1663+ log.error("Errow thrown %s", sys.exc_info()[1])
1664 return False
1665
1666=== modified file 'openlp/plugins/songs/lib/mediaitem.py'
1667--- openlp/plugins/songs/lib/mediaitem.py 2009-05-22 18:30:25 +0000
1668+++ openlp/plugins/songs/lib/mediaitem.py 2009-06-03 16:14:56 +0000
1669@@ -3,7 +3,7 @@
1670 """
1671 OpenLP - Open Source Lyrics Projection
1672 Copyright (c) 2008 Raoul Snyman
1673-Portions copyright (c) 2008 Martin Thompson, Tim Bentley
1674+Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley
1675
1676 This program is free software; you can redistribute it and/or modify it under
1677 the terms of the GNU General Public License as published by the Free Software
1678@@ -21,9 +21,33 @@
1679
1680 from PyQt4 import QtCore, QtGui
1681
1682-from openlp.core.lib import MediaManagerItem, translate
1683+from openlp.core.lib import MediaManagerItem, translate, ServiceItem
1684
1685 from openlp.plugins.songs.forms import EditSongForm
1686+from openlp.plugins.songs.lib import TextListData
1687+
1688+class SongList(QtGui.QListView):
1689+
1690+ def __init__(self,parent=None,name=None):
1691+ QtGui.QListView.__init__(self,parent)
1692+
1693+ def mouseMoveEvent(self, event):
1694+ """
1695+ Drag and drop event does not care what data is selected
1696+ as the recepient will use events to request the data move
1697+ just tell it what plugin to call
1698+ """
1699+ if event.buttons() != QtCore.Qt.LeftButton:
1700+ return
1701+ drag = QtGui.QDrag(self)
1702+ mimeData = QtCore.QMimeData()
1703+ drag.setMimeData(mimeData)
1704+ mimeData.setText(u'Song')
1705+
1706+ dropAction = drag.start(QtCore.Qt.CopyAction)
1707+
1708+ if dropAction == QtCore.Qt.CopyAction:
1709+ self.close()
1710
1711 class SongMediaItem(MediaManagerItem):
1712 """
1713@@ -98,19 +122,29 @@
1714 self.SearchLayout.addWidget(self.SearchTextButton, 3, 2, 1, 1)
1715 # Add the song widget to the page layout
1716 self.PageLayout.addWidget(self.SongWidget)
1717- self.SongListView = QtGui.QTableWidget()
1718- self.SongListView.setColumnCount(2)
1719- self.SongListView.setColumnHidden(0, True)
1720- self.SongListView.setColumnWidth(1, 240)
1721- self.SongListView.setShowGrid(False)
1722- self.SongListView.setSortingEnabled(False)
1723+
1724+ self.SongListView = SongList()
1725 self.SongListView.setAlternatingRowColors(True)
1726- self.SongListView.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows)
1727- self.SongListView.horizontalHeader().setVisible(False)
1728- self.SongListView.verticalHeader().setVisible(False)
1729- self.SongListView.setGeometry(QtCore.QRect(10, 100, 256, 591))
1730+ self.SongListData = TextListData()
1731+ self.SongListView.setModel(self.SongListData)
1732+ self.SongListView.setDragEnabled(True)
1733+
1734+# self.SongListView = QtGui.QTableWidget()
1735+# self.SongListView.setColumnCount(2)
1736+# self.SongListView.setColumnHidden(0, True)
1737+# self.SongListView.setColumnWidth(1, 240)
1738+# self.SongListView.setShowGrid(False)
1739+# self.SongListView.setSortingEnabled(False)
1740+# self.SongListView.setAlternatingRowColors(True)
1741+# self.SongListView.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows)
1742+# self.SongListView.horizontalHeader().setVisible(False)
1743+# self.SongListView.verticalHeader().setVisible(False)
1744+# self.SongListView.setGeometry(QtCore.QRect(10, 100, 256, 591))
1745 self.SongListView.setObjectName('SongListView')
1746+
1747 self.PageLayout.addWidget(self.SongListView)
1748+ self.SongListView.setDragEnabled(True)
1749+
1750 # Signals and slots
1751 QtCore.QObject.connect(self.SearchTextButton,
1752 QtCore.SIGNAL('pressed()'), self.onSearchTextButtonClick)
1753@@ -118,8 +152,8 @@
1754 QtCore.SIGNAL('pressed()'), self.onClearTextButtonClick)
1755 QtCore.QObject.connect(self.SearchTextEdit,
1756 QtCore.SIGNAL('textChanged(const QString&)'), self.onSearchTextEditChanged)
1757- QtCore.QObject.connect(self.SongListView,
1758- QtCore.SIGNAL('itemPressed(QTableWidgetItem * item)'), self.onSongSelected)
1759+# QtCore.QObject.connect(self.SongListView,
1760+# QtCore.SIGNAL('itemPressed(QTableWidgetItem * item)'), self.onSongSelected)
1761 #define and add the context menu
1762 self.SongListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
1763 self.SongListView.addAction(self.contextMenuAction(self.SongListView,
1764@@ -148,26 +182,18 @@
1765 self.SearchTypeComboBox.addItem(translate('SongMediaItem', u'Authors'))
1766
1767 def displayResults(self, searchresults):
1768- log.debug("_search results")
1769- self.SongListView.clear() # clear the results
1770- self.SongListView.horizontalHeader().setVisible(False)
1771- self.SongListView.verticalHeader().setVisible(False)
1772- self.SongListView.setRowCount(0)
1773+ log.debug("display results")
1774+ self.SongListData.resetStore()
1775 #log.debug("Records returned from search %s", len(searchresults))
1776 for song in searchresults:
1777- row_count = self.SongListView.rowCount()
1778- self.SongListView.setRowCount(row_count + 1)
1779- song_index = QtGui.QTableWidgetItem(str(song.id))
1780- self.SongListView.setItem(row_count, 0, song_index)
1781 author_list = u''
1782 for author in song.authors:
1783 if author_list != u'':
1784 author_list = author_list + u', '
1785 author_list = author_list + author.display_name
1786- song_detail = QtGui.QTableWidgetItem(
1787- u'%s (%s)' % (str(song.title), str(author_list)))
1788- self.SongListView.setItem(row_count, 1, song_detail)
1789- self.SongListView.setRowHeight(row_count, 20)
1790+ song_detail = str(u'%s (%s)' % (str(song.title), str(author_list)))
1791+
1792+ self.SongListData.addRow(song.id,song_detail)
1793
1794 def onClearTextButtonClick(self):
1795 """
1796@@ -197,26 +223,57 @@
1797 #searchresults = self.songmanager.get_song_from_author(searchtext)
1798 self.displayResults(search_results)
1799
1800- def onSongSelected(self, item):
1801- print item
1802-
1803 def onSongNewClick(self):
1804 self.edit_song_form.exec_()
1805
1806 def onSongEditClick(self):
1807- current_row = self.SongListView.currentRow()
1808- id = int(self.SongListView.item(current_row, 0).text())
1809- self.edit_song_form.loadSong(id)
1810- self.edit_song_form.exec_()
1811+ indexes = self.SongListView.selectedIndexes()
1812+ for index in indexes:
1813+ id = self.SongListData.getId(index)
1814+ self.edit_song_form.loadSong(id)
1815+ self.edit_song_form.exec_()
1816
1817 def onSongDeleteClick(self):
1818- pass
1819+ indexes = self.SongListView.selectedIndexes()
1820+ for index in indexes:
1821+ id = self.SongListData.getId(index)
1822+ self.parent.songmanager.delete_song(id)
1823+ self.SongListData.deleteRow(index)
1824
1825 def onSongPreviewClick(self):
1826- pass
1827+ service_item = ServiceItem(self.parent)
1828+ service_item.addIcon( ":/media/media_song.png")
1829+ self.generateSlideData(service_item)
1830+ self.parent.preview_controller.addServiceItem(service_item)
1831+
1832+ def generateSlideData(self, service_item):
1833+ raw_slides =[]
1834+ raw_footer = []
1835+ indexes = self.SongListView.selectedIndexes()
1836+ for index in indexes:
1837+ id = self.SongListData.getId(index)
1838+ song = self.parent.songmanager.get_song(id)
1839+ if song.theme_name == None or len(song.theme_name) == 0:
1840+ service_item.theme = None
1841+ else:
1842+ service_item.theme = song.theme_name
1843+ verses = song.lyrics.split(u'\n\n')
1844+ for verse in verses:
1845+ raw_slides.append(verse)
1846+ service_item.raw_slides = raw_slides
1847+ service_item.title = song.title
1848+ raw_footer.append(str(u'%s \n%s \n' % (song.title, song.copyright )))
1849+ raw_footer.append(song.copyright)
1850+ service_item.raw_footer = raw_footer
1851
1852 def onSongLiveClick(self):
1853- pass
1854+ service_item = ServiceItem(self.parent)
1855+ service_item.addIcon( ":/media/media_song.png")
1856+ self.generateSlideData(service_item)
1857+ self.parent.live_controller.addServiceItem(service_item)
1858
1859 def onSongAddClick(self):
1860- pass
1861+ service_item = ServiceItem(self.parent)
1862+ service_item.addIcon( ":/media/media_song.png")
1863+ self.generateSlideData(service_item)
1864+ self.parent.service_manager.addServiceItem(service_item)
1865
1866=== added file 'openlp/plugins/songs/lib/textlistdata.py'
1867--- openlp/plugins/songs/lib/textlistdata.py 1970-01-01 00:00:00 +0000
1868+++ openlp/plugins/songs/lib/textlistdata.py 2009-06-03 15:38:14 +0000
1869@@ -0,0 +1,80 @@
1870+# -*- coding: utf-8 -*-
1871+# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
1872+"""
1873+OpenLP - Open Source Lyrics Projection
1874+Copyright (c) 2008 Raoul Snyman
1875+Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley
1876+
1877+This program is free software; you can redistribute it and/or modify it under
1878+the terms of the GNU General Public License as published by the Free Software
1879+Foundation; version 2 of the License.
1880+
1881+This program is distributed in the hope that it will be useful, but WITHOUT ANY
1882+WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
1883+PARTICULAR PURPOSE. See the GNU General Public License for more details.
1884+
1885+You should have received a copy of the GNU General Public License along with
1886+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
1887+Place, Suite 330, Boston, MA 02111-1307 USA
1888+"""
1889+import logging
1890+
1891+from PyQt4 import QtCore, QtGui
1892+
1893+class TextListData(QtCore.QAbstractListModel):
1894+ """
1895+ An abstract list of strings
1896+ """
1897+ global log
1898+ log = logging.getLogger(u'TextListData')
1899+ log.info(u'started')
1900+
1901+ def __init__(self):
1902+ QtCore.QAbstractListModel.__init__(self)
1903+ self.items = [] # will be a list of (database id , title) tuples
1904+
1905+ def resetStore(self):
1906+ #reset list so can be reloaded
1907+ self.items = []
1908+
1909+ def rowCount(self, parent):
1910+ return len(self.items)
1911+
1912+ def insertRow(self, row, id, title):
1913+ self.beginInsertRows(QtCore.QModelIndex(),row,row)
1914+ log.debug("insert row %d:%s for id %d" % (row,title, id))
1915+ self.items.insert(row, (id, title))
1916+ self.endInsertRows()
1917+
1918+ def removeRow(self, row):
1919+ self.beginRemoveRows(QtCore.QModelIndex(), row,row)
1920+ self.items.pop(row)
1921+ self.endRemoveRows()
1922+
1923+ def addRow(self, id, title):
1924+ self.insertRow(len(self.items), id, title)
1925+
1926+ def data(self, index, role):
1927+ row = index.row()
1928+ if row > len(self.items): # if the last row is selected and deleted, we then get called with an empty row!
1929+ return QtCore.QVariant()
1930+ if role == QtCore.Qt.DisplayRole:
1931+ retval = self.items[row][1]
1932+ else:
1933+ retval = QtCore.QVariant()
1934+ if type(retval) is not type(QtCore.QVariant):
1935+ return QtCore.QVariant(retval)
1936+ else:
1937+ return retval
1938+
1939+ def getIdList(self):
1940+ filelist = [item[0] for item in self.items];
1941+ return filelist
1942+
1943+ def getId(self, index):
1944+ row = index.row()
1945+ return self.items[row][0]
1946+
1947+ def deleteRow(self, index):
1948+ row = index.row()
1949+ self.removeRow(row)
1950
1951=== modified file 'openlp/plugins/songs/songsplugin.py'
1952--- openlp/plugins/songs/songsplugin.py 2009-05-22 18:30:25 +0000
1953+++ openlp/plugins/songs/songsplugin.py 2009-06-03 15:38:14 +0000
1954@@ -49,8 +49,8 @@
1955
1956 def get_media_manager_item(self):
1957 # Create the MediaManagerItem object
1958- self.MediaManagerItem = SongMediaItem(self, self.icon, 'Songs')
1959- return self.MediaManagerItem
1960+ self.media_item = SongMediaItem(self, self.icon, 'Songs')
1961+ return self.media_item
1962
1963 def add_import_menu_item(self, import_menu):
1964 self.ImportSongMenu = QtGui.QMenu(import_menu)
1965@@ -127,3 +127,12 @@
1966 if event.event_type == EventType.ThemeListChanged:
1967 log.debug(u'New Theme request received')
1968 #self.edit_custom_form.loadThemes(self.theme_manager.getThemes())
1969+ if event.event_type == EventType.LoadServiceItem and event.payload == 'Song':
1970+ log.debug(u'Load Service Item received')
1971+ self.media_item.onSongAddClick()
1972+ if event.event_type == EventType.PreviewShow and event.payload == 'Song':
1973+ log.debug(u'Load Preview Item received ')
1974+ self.media_item.onSongPreviewClick()
1975+ if event.event_type == EventType.LiveShow and event.payload == 'Song':
1976+ log.debug(u'Load Live Show Item received')
1977+ self.media_item.onSongLiveClick()