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

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

Phase 2 complete of operation Song plugin
Screen based error handling
code cleanups
Lists as Widgets and standard MVC behaviour

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

Looks fine.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'openlp/plugins/songs/forms/authorsdialog.py'
2--- openlp/plugins/songs/forms/authorsdialog.py 2009-06-04 19:00:41 +0000
3+++ openlp/plugins/songs/forms/authorsdialog.py 2009-06-14 15:12:40 +0000
4@@ -1,115 +1,121 @@
5 # -*- coding: utf-8 -*-
6-
7-# Form implementation generated from reading ui file 'authorsdialog.ui'
8-#
9-# Created: Sat Jan 3 11:48:36 2009
10-# by: PyQt4 UI code generator 4.4.3
11-#
12-# WARNING! All changes made in this file will be lost!
13-
14+# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
15+"""
16+OpenLP - Open Source Lyrics Projection
17+Copyright (c) 2008 Raoul Snyman
18+Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley,
19+
20+This program is free software; you can redistribute it and/or modify it under
21+the terms of the GNU General Public License as published by the Free Software
22+Foundation; version 2 of the License.
23+
24+This program is distributed in the hope that it will be useful, but WITHOUT ANY
25+WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
26+PARTICULAR PURPOSE. See the GNU General Public License for more details.
27+
28+You should have received a copy of the GNU General Public License along with
29+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
30+Place, Suite 330, Boston, MA 02111-1307 USA
31+"""
32 from PyQt4 import QtCore, QtGui
33-from openlp.plugins.songs.lib import TextListData
34+from openlp.core.lib import translate
35
36 class Ui_AuthorsDialog(object):
37 def setupUi(self, AuthorsDialog):
38- AuthorsDialog.setObjectName("AuthorsDialog")
39+ AuthorsDialog.setObjectName(u'AuthorsDialog')
40 AuthorsDialog.resize(410, 505)
41 self.DialogLayout = QtGui.QVBoxLayout(AuthorsDialog)
42 self.DialogLayout.setSpacing(8)
43 self.DialogLayout.setMargin(8)
44- self.DialogLayout.setObjectName("DialogLayout")
45-
46- self.AuthorListView = QtGui.QListView()
47- self.AuthorListView.setAlternatingRowColors(True)
48- self.AuthorListData = TextListData()
49- self.AuthorListView.setModel(self.AuthorListData)
50- self.DialogLayout.addWidget(self.AuthorListView)
51-
52+ self.DialogLayout.setObjectName(u'DialogLayout')
53+ self.AuthorListWidget = QtGui.QListWidget()
54+ self.AuthorListWidget.setAlternatingRowColors(True)
55+ self.DialogLayout.addWidget(self.AuthorListWidget)
56 self.AuthorDetails = QtGui.QGroupBox(AuthorsDialog)
57 self.AuthorDetails.setMinimumSize(QtCore.QSize(0, 0))
58- self.AuthorDetails.setObjectName("AuthorDetails")
59+ self.AuthorDetails.setObjectName(u'AuthorDetails')
60 self.AuthorLayout = QtGui.QVBoxLayout(self.AuthorDetails)
61 self.AuthorLayout.setSpacing(8)
62 self.AuthorLayout.setMargin(8)
63- self.AuthorLayout.setObjectName("AuthorLayout")
64+ self.AuthorLayout.setObjectName(u'AuthorLayout')
65 self.DetailsWidget = QtGui.QWidget(self.AuthorDetails)
66- self.DetailsWidget.setObjectName("DetailsWidget")
67+ self.DetailsWidget.setObjectName(u'DetailsWidget')
68 self.DetailsLayout = QtGui.QFormLayout(self.DetailsWidget)
69 self.DetailsLayout.setMargin(0)
70 self.DetailsLayout.setSpacing(8)
71- self.DetailsLayout.setObjectName("DetailsLayout")
72+ self.DetailsLayout.setObjectName(u'DetailsLayout')
73 self.DisplayLabel = QtGui.QLabel(self.DetailsWidget)
74- self.DisplayLabel.setObjectName("DisplayLabel")
75+ self.DisplayLabel.setObjectName(u'DisplayLabel')
76 self.DetailsLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.DisplayLabel)
77 self.DisplayEdit = QtGui.QLineEdit(self.DetailsWidget)
78- self.DisplayEdit.setObjectName("DisplayEdit")
79+ self.DisplayEdit.setObjectName(u'DisplayEdit')
80 self.DetailsLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.DisplayEdit)
81 self.FirstNameLabel = QtGui.QLabel(self.DetailsWidget)
82- self.FirstNameLabel.setObjectName("FirstNameLabel")
83+ self.FirstNameLabel.setObjectName(u'FirstNameLabel')
84 self.DetailsLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.FirstNameLabel)
85 self.FirstNameEdit = QtGui.QLineEdit(self.DetailsWidget)
86- self.FirstNameEdit.setObjectName("FirstNameEdit")
87+ self.FirstNameEdit.setObjectName(u'FirstNameEdit')
88 self.DetailsLayout.setWidget(1, QtGui.QFormLayout.FieldRole, self.FirstNameEdit)
89 self.LastNameLabel = QtGui.QLabel(self.DetailsWidget)
90- self.LastNameLabel.setObjectName("LastNameLabel")
91+ self.LastNameLabel.setObjectName(u'LastNameLabel')
92 self.DetailsLayout.setWidget(2, QtGui.QFormLayout.LabelRole, self.LastNameLabel)
93 self.LastNameEdit = QtGui.QLineEdit(self.DetailsWidget)
94- self.LastNameEdit.setObjectName("LastNameEdit")
95+ self.LastNameEdit.setObjectName(u'LastNameEdit')
96 self.DetailsLayout.setWidget(2, QtGui.QFormLayout.FieldRole, self.LastNameEdit)
97 self.AuthorLayout.addWidget(self.DetailsWidget)
98 self.MessageLabel = QtGui.QLabel(self.AuthorDetails)
99- self.MessageLabel.setObjectName("MessageLabel")
100+ self.MessageLabel.setObjectName(u'MessageLabel')
101 self.AuthorLayout.addWidget(self.MessageLabel)
102 self.ButtonWidget = QtGui.QWidget(self.AuthorDetails)
103 self.ButtonWidget.setMinimumSize(QtCore.QSize(0, 0))
104- self.ButtonWidget.setObjectName("ButtonWidget")
105+ self.ButtonWidget.setObjectName(u'ButtonWidget')
106 self.ButtonLayout = QtGui.QHBoxLayout(self.ButtonWidget)
107 self.ButtonLayout.setSpacing(8)
108 self.ButtonLayout.setMargin(0)
109- self.ButtonLayout.setObjectName("ButtonLayout")
110+ self.ButtonLayout.setObjectName(u'ButtonLayout')
111 spacerItem = QtGui.QSpacerItem(198, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
112 self.ButtonLayout.addItem(spacerItem)
113 self.ClearButton = QtGui.QPushButton(self.ButtonWidget)
114 icon = QtGui.QIcon()
115- icon.addPixmap(QtGui.QPixmap(":/services/service_new.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
116+ icon.addPixmap(QtGui.QPixmap(u':/services/service_new.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off)
117 self.ClearButton.setIcon(icon)
118- self.ClearButton.setObjectName("ClearButton")
119+ self.ClearButton.setObjectName(u'ClearButton')
120 self.ButtonLayout.addWidget(self.ClearButton)
121 self.AddUpdateButton = QtGui.QPushButton(self.ButtonWidget)
122 icon1 = QtGui.QIcon()
123- icon1.addPixmap(QtGui.QPixmap(":/services/service_save.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
124+ icon1.addPixmap(QtGui.QPixmap(u':/services/service_save.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off)
125 self.AddUpdateButton.setIcon(icon1)
126- self.AddUpdateButton.setObjectName("AddUpdateButton")
127+ self.AddUpdateButton.setObjectName(u'AddUpdateButton')
128 self.ButtonLayout.addWidget(self.AddUpdateButton)
129 self.DeleteButton = QtGui.QPushButton(self.ButtonWidget)
130 icon2 = QtGui.QIcon()
131- icon2.addPixmap(QtGui.QPixmap(":/services/service_delete.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
132+ icon2.addPixmap(QtGui.QPixmap(u':/services/service_delete.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off)
133 self.DeleteButton.setIcon(icon2)
134- self.DeleteButton.setObjectName("DeleteButton")
135+ self.DeleteButton.setObjectName(u'DeleteButton')
136 self.ButtonLayout.addWidget(self.DeleteButton)
137 self.AuthorLayout.addWidget(self.ButtonWidget)
138 self.DialogLayout.addWidget(self.AuthorDetails)
139 self.buttonBox = QtGui.QDialogButtonBox(AuthorsDialog)
140 self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
141 self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Ok)
142- self.buttonBox.setObjectName("buttonBox")
143+ self.buttonBox.setObjectName(u'buttonBox')
144 self.DialogLayout.addWidget(self.buttonBox)
145
146 self.retranslateUi(AuthorsDialog)
147- QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("accepted()"), AuthorsDialog.accept)
148- QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("rejected()"), AuthorsDialog.reject)
149+ QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'accepted()'), AuthorsDialog.accept)
150+ QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'rejected()'), AuthorsDialog.reject)
151 QtCore.QMetaObject.connectSlotsByName(AuthorsDialog)
152
153 def retranslateUi(self, AuthorsDialog):
154- AuthorsDialog.setWindowTitle(QtGui.QApplication.translate("AuthorsDialog", "Author Maintenance", None, QtGui.QApplication.UnicodeUTF8))
155- self.AuthorDetails.setTitle(QtGui.QApplication.translate("AuthorsDialog", "Author Details", None, QtGui.QApplication.UnicodeUTF8))
156- self.DisplayLabel.setText(QtGui.QApplication.translate("AuthorsDialog", "Display Name:", None, QtGui.QApplication.UnicodeUTF8))
157- self.FirstNameLabel.setText(QtGui.QApplication.translate("AuthorsDialog", "First Name:", None, QtGui.QApplication.UnicodeUTF8))
158- self.LastNameLabel.setText(QtGui.QApplication.translate("AuthorsDialog", "Last Name:", None, QtGui.QApplication.UnicodeUTF8))
159- self.ClearButton.setToolTip(QtGui.QApplication.translate("AuthorsDialog", "Clear Selection", None, QtGui.QApplication.UnicodeUTF8))
160- self.ClearButton.setText(QtGui.QApplication.translate("AuthorsDialog", "Clear", None, QtGui.QApplication.UnicodeUTF8))
161- self.AddUpdateButton.setToolTip(QtGui.QApplication.translate("AuthorsDialog", "Add Update Author", None, QtGui.QApplication.UnicodeUTF8))
162- self.AddUpdateButton.setText(QtGui.QApplication.translate("AuthorsDialog", "Save", None, QtGui.QApplication.UnicodeUTF8))
163- self.DeleteButton.setToolTip(QtGui.QApplication.translate("AuthorsDialog", "Delete Author", None, QtGui.QApplication.UnicodeUTF8))
164- self.DeleteButton.setText(QtGui.QApplication.translate("AuthorsDialog", "Delete", None, QtGui.QApplication.UnicodeUTF8))
165- self.buttonBox.setToolTip(QtGui.QApplication.translate("AuthorsDialog", "Exit Screen", None, QtGui.QApplication.UnicodeUTF8))
166+ AuthorsDialog.setWindowTitle(translate(u'AuthorsDialog', u'Author Maintenance'))
167+ self.AuthorDetails.setTitle(translate(u'AuthorsDialog', u'Author Details'))
168+ self.DisplayLabel.setText(translate(u'AuthorsDialog', u'Display Name:'))
169+ self.FirstNameLabel.setText(translate(u'AuthorsDialog', u'First Name:'))
170+ self.LastNameLabel.setText(translate(u'AuthorsDialog', u'Last Name:'))
171+ self.ClearButton.setToolTip(translate(u'AuthorsDialog', u'Clear Selection'))
172+ self.ClearButton.setText(translate(u'AuthorsDialog', u'Clear'))
173+ self.AddUpdateButton.setToolTip(translate(u'AuthorsDialog', u'Add Update Author'))
174+ self.AddUpdateButton.setText(translate(u'AuthorsDialog', u'Save'))
175+ self.DeleteButton.setToolTip(translate(u'AuthorsDialog', u'Delete Author'))
176+ self.DeleteButton.setText(translate(u'AuthorsDialog', u'Delete'))
177+ self.buttonBox.setToolTip(translate(u'AuthorsDialog', u'Exit Screen'))
178
179=== modified file 'openlp/plugins/songs/forms/authorsform.py'
180--- openlp/plugins/songs/forms/authorsform.py 2009-06-10 17:12:03 +0000
181+++ openlp/plugins/songs/forms/authorsform.py 2009-06-14 15:12:40 +0000
182@@ -19,7 +19,7 @@
183 from PyQt4 import QtGui, QtCore
184 from openlp.core.lib import translate
185 from openlp.plugins.songs.forms.authorsdialog import Ui_AuthorsDialog
186-from openlp.plugins.songs.lib import TextListData
187+from openlp.plugins.songs.lib.classes import Author
188
189 class AuthorsForm(QtGui.QDialog, Ui_AuthorsDialog):
190 """
191@@ -43,27 +43,24 @@
192 QtCore.SIGNAL(u'pressed()'), self.onAddUpdateButtonClick)
193 QtCore.QObject.connect(self.DisplayEdit,
194 QtCore.SIGNAL(u'lostFocus()'), self.onDisplayEditLostFocus)
195- QtCore.QObject.connect(self.AuthorListView,
196- QtCore.SIGNAL(u'clicked(QModelIndex)'), self.onAuthorListViewItemClicked)
197+ QtCore.QObject.connect(self.AuthorListWidget,
198+ QtCore.SIGNAL(u'clicked(QModelIndex)'), self.onAuthorListWidgetItemClicked)
199
200 def load_form(self):
201 """
202 Refresh the screen and rest fields
203 """
204- self.AuthorListData.resetStore()
205+ self.AuthorListWidget.clear()
206 self.onClearButtonClick() # tidy up screen
207 authors = self.songmanager.get_authors()
208 for author in authors:
209- self.AuthorListData.addRow(author.id,author.display_name)
210- #rowCount is number of rows BUT test should be Zero based
211- row_count = self.AuthorListData.rowCount(None) - 1
212- if self.currentRow > row_count:
213- # in case we have delete the last row of the table
214- self.currentRow = row_count
215- row = self.AuthorListData.createIndex(self.currentRow, 0)
216- if row.isValid():
217- self.AuthorListView.selectionModel().setCurrentIndex(row,
218- QtGui.QItemSelectionModel.SelectCurrent)
219+ author_name = QtGui.QListWidgetItem(author.display_name)
220+ author_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(author.id))
221+ self.AuthorListWidget.addItem(author_name)
222+ if self.currentRow >= self.AuthorListWidget.count() :
223+ self.AuthorListWidget.setCurrentRow(self.AuthorListWidget.count() - 1)
224+ else:
225+ self.AuthorListWidget.setCurrentRow(self.currentRow)
226 self._validate_form()
227
228 def onDeleteButtonClick(self):
229@@ -101,15 +98,15 @@
230 self.author = None
231 self._validate_form()
232
233- def onAuthorListViewItemClicked(self, index):
234+ def onAuthorListWidgetItemClicked(self, index):
235 """
236 An Author has been selected display it
237 If the author is attached to a Song prevent delete
238 """
239- self.currentRow = index.row()
240- id = int(self.AuthorListData.getId(index))
241- self.author = self.songmanager.get_author(id)
242-
243+ self.currentRow = self.AuthorListWidget.currentRow()
244+ item = self.AuthorListWidget.currentItem()
245+ item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
246+ self.author = self.songmanager.get_author(item_id)
247 self.DisplayEdit.setText(self.author.display_name)
248 self.FirstNameEdit.setText(self.author.first_name)
249 self.LastNameEdit.setText(self.author.last_name)
250
251=== modified file 'openlp/plugins/songs/forms/editsongdialog.py'
252--- openlp/plugins/songs/forms/editsongdialog.py 2009-06-14 06:30:09 +0000
253+++ openlp/plugins/songs/forms/editsongdialog.py 2009-06-14 13:50:56 +0000
254@@ -1,4 +1,22 @@
255-
256+# -*- coding: utf-8 -*-
257+# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
258+"""
259+OpenLP - Open Source Lyrics Projection
260+Copyright (c) 2008 Raoul Snyman
261+Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley,
262+
263+This program is free software; you can redistribute it and/or modify it under
264+the terms of the GNU General Public License as published by the Free Software
265+Foundation; version 2 of the License.
266+
267+This program is distributed in the hope that it will be useful, but WITHOUT ANY
268+WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
269+PARTICULAR PURPOSE. See the GNU General Public License for more details.
270+
271+You should have received a copy of the GNU General Public License along with
272+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
273+Place, Suite 330, Boston, MA 02111-1307 USA
274+"""
275 from openlp.core.lib import translate
276 from PyQt4 import QtCore, QtGui
277
278
279=== modified file 'openlp/plugins/songs/forms/editsongform.py'
280--- openlp/plugins/songs/forms/editsongform.py 2009-06-14 07:25:39 +0000
281+++ openlp/plugins/songs/forms/editsongform.py 2009-06-14 13:50:56 +0000
282@@ -99,20 +99,26 @@
283 authors = self.songmanager.get_authors()
284 self.AuthorsSelectionComboItem.clear()
285 for author in authors:
286+ row = self.AuthorsSelectionComboItem.count()
287 self.AuthorsSelectionComboItem.addItem(author.display_name)
288+ self.AuthorsSelectionComboItem.setItemData(row, QtCore.QVariant(author.id))
289
290 def loadTopics(self):
291 topics = self.songmanager.get_topics()
292 self.SongTopicCombo.clear()
293 for topic in topics:
294+ row = self.SongTopicCombo.count()
295 self.SongTopicCombo.addItem(topic.name)
296+ self.SongTopicCombo.setItemData(row, QtCore.QVariant(topic.id))
297
298 def loadBooks(self):
299 books = self.songmanager.get_books()
300 self.SongbookCombo.clear()
301 self.SongbookCombo.addItem(u' ')
302 for book in books:
303+ row = self.SongbookCombo.count()
304 self.SongbookCombo.addItem(book.name)
305+ self.SongbookCombo.setItemData(row, QtCore.QVariant(book.id))
306
307 def loadThemes(self, theme_list):
308 self.ThemeSelectionComboItem.clear()
309@@ -180,8 +186,9 @@
310 self.title_change = False
311
312 def onAuthorAddtoSongItemClicked(self):
313- author_name = unicode(self.AuthorsSelectionComboItem.currentText())
314- author = self.songmanager.get_author_by_name(author_name)
315+ item = int(self.AuthorsSelectionComboItem.currentIndex())
316+ item_id = (self.AuthorsSelectionComboItem.itemData(item)).toInt()[0]
317+ author = self.songmanager.get_author(item_id)
318 self.song.authors.append(author)
319 author_item = QtGui.QListWidgetItem(unicode(author.display_name))
320 author_item.setData(QtCore.Qt.UserRole, QtCore.QVariant(author.id))
321@@ -201,8 +208,9 @@
322 self.AuthorsListView.takeItem(row)
323
324 def onTopicAddtoSongItemClicked(self):
325- topic_name = unicode(self.SongTopicCombo.currentText())
326- topic = self.songmanager.get_topic_by_name(topic_name)
327+ item = int(self.SongTopicCombo.currentIndex())
328+ item_id = (self.SongTopicCombo.itemData(item)).toInt()[0]
329+ topic = self.songmanager.get_topic(item_id)
330 self.song.topics.append(topic)
331 topic_item = QtGui.QListWidgetItem(unicode(topic.name))
332 topic_item.setData(QtCore.Qt.UserRole, QtCore.QVariant(topic.id))
333@@ -248,9 +256,8 @@
334 if item == 0:
335 self.song.song_book_id = 0
336 else:
337- book_name = unicode(self.SongbookCombo.itemText(item))
338- book = self.songmanager.get_book_by_name(book_name)
339- self.song.song_book_id = book.id
340+ item = int(self.SongbookCombo.currentIndex())
341+ self.song.song_book_id = (self.SongbookCombo.itemData(item)).toInt()[0]
342
343 def onThemeComboChanged(self, item):
344 if item == 0:
345@@ -293,23 +300,26 @@
346 valid = True
347 if len(self.TitleEditItem.displayText()) == 0:
348 valid = False
349+ self.TitleEditItem.setStyleSheet(u'background-color: red; color: white')
350+ else:
351+ self.TitleEditItem.setStyleSheet(u'')
352 if len(self.CopyrightEditItem.displayText()) == 0:
353 valid = False
354+ self.CopyrightEditItem.setStyleSheet(u'background-color: red; color: white')
355+ else:
356+ self.CopyrightEditItem.setStyleSheet(u'')
357 if self.VerseListWidget.count() == 0:
358 valid = False
359+ self.VerseListWidget.setStyleSheet(u'background-color: red; color: white')
360+ else:
361+ self.VerseListWidget.setStyleSheet(u'')
362 if self.AuthorsListView.count() == 0:
363 valid = False
364+ self.AuthorsListView.setStyleSheet(u'background-color: red; color: white')
365+ else:
366+ self.AuthorsListView.setStyleSheet(u'')
367 return valid
368
369- def _color_widget(self, slot, invalid):
370- r = Qt.QPalette(slot.palette())
371- if invalid == True:
372- r.setColor(Qt.QPalette.Base, Qt.QColor(u'darkRed'))
373- else:
374- r.setColor(Qt.QPalette.Base, Qt.QColor(u'white'))
375- slot.setPalette(r)
376- slot.setAutoFillBackground(True)
377-
378 def on_TitleEditItem_lostFocus(self):
379 self.song.title = self.TitleEditItem.text()
380 self.title_change = True
381
382=== modified file 'openlp/plugins/songs/forms/songbookdialog.py'
383--- openlp/plugins/songs/forms/songbookdialog.py 2009-06-04 20:06:32 +0000
384+++ openlp/plugins/songs/forms/songbookdialog.py 2009-06-14 15:12:40 +0000
385@@ -1,60 +1,66 @@
386 # -*- coding: utf-8 -*-
387-
388-# Form implementation generated from reading ui file 'songbookdialog.ui'
389-#
390-# Created: Sun Jan 4 08:43:12 2009
391-# by: PyQt4 UI code generator 4.4.3
392-#
393-# WARNING! All changes made in this file will be lost!
394-
395+# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
396+"""
397+OpenLP - Open Source Lyrics Projection
398+Copyright (c) 2008 Raoul Snyman
399+Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley,
400+
401+This program is free software; you can redistribute it and/or modify it under
402+the terms of the GNU General Public License as published by the Free Software
403+Foundation; version 2 of the License.
404+
405+This program is distributed in the hope that it will be useful, but WITHOUT ANY
406+WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
407+PARTICULAR PURPOSE. See the GNU General Public License for more details.
408+
409+You should have received a copy of the GNU General Public License along with
410+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
411+Place, Suite 330, Boston, MA 02111-1307 USA
412+"""
413 from PyQt4 import QtCore, QtGui
414-from openlp.plugins.songs.lib import TextListData
415+from openlp.core.lib import translate
416
417 class Ui_SongBookDialog(object):
418 def setupUi(self, SongBookDialog):
419- SongBookDialog.setObjectName("SongBookDialog")
420+ SongBookDialog.setObjectName(u'SongBookDialog')
421 SongBookDialog.resize(387, 531)
422 self.DialogLayout = QtGui.QVBoxLayout(SongBookDialog)
423 self.DialogLayout.setSpacing(8)
424 self.DialogLayout.setMargin(8)
425- self.DialogLayout.setObjectName("DialogLayout")
426-
427- self.BookSongListView = QtGui.QListView()
428- self.BookSongListView.setAlternatingRowColors(True)
429- self.BookSongListData = TextListData()
430- self.BookSongListView.setModel(self.BookSongListData)
431- self.DialogLayout.addWidget(self.BookSongListView)
432-
433- self.DialogLayout.addWidget(self.BookSongListView)
434+ self.DialogLayout.setObjectName(u'DialogLayout')
435+ self.BookSongListWidget = QtGui.QListWidget()
436+ self.BookSongListWidget.setAlternatingRowColors(True)
437+ self.DialogLayout.addWidget(self.BookSongListWidget)
438+ self.DialogLayout.addWidget(self.BookSongListWidget)
439 self.SongBookGroup = QtGui.QGroupBox(SongBookDialog)
440 self.SongBookGroup.setMinimumSize(QtCore.QSize(0, 200))
441- self.SongBookGroup.setObjectName("SongBookGroup")
442+ self.SongBookGroup.setObjectName(u'SongBookGroup')
443 self.SongBookLayout = QtGui.QVBoxLayout(self.SongBookGroup)
444 self.SongBookLayout.setSpacing(8)
445 self.SongBookLayout.setMargin(8)
446- self.SongBookLayout.setObjectName("SongBookLayout")
447+ self.SongBookLayout.setObjectName(u'SongBookLayout')
448 self.DetailsWidget = QtGui.QWidget(self.SongBookGroup)
449 self.DetailsWidget.setMinimumSize(QtCore.QSize(0, 0))
450- self.DetailsWidget.setObjectName("DetailsWidget")
451+ self.DetailsWidget.setObjectName(u'DetailsWidget')
452 self.DetailsLayout = QtGui.QFormLayout(self.DetailsWidget)
453 self.DetailsLayout.setMargin(0)
454 self.DetailsLayout.setSpacing(8)
455- self.DetailsLayout.setObjectName("DetailsLayout")
456+ self.DetailsLayout.setObjectName(u'DetailsLayout')
457 self.NameLabel = QtGui.QLabel(self.DetailsWidget)
458- self.NameLabel.setObjectName("NameLabel")
459+ self.NameLabel.setObjectName(u'NameLabel')
460 self.DetailsLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.NameLabel)
461 self.NameEdit = QtGui.QLineEdit(self.DetailsWidget)
462- self.NameEdit.setObjectName("NameEdit")
463+ self.NameEdit.setObjectName(u'NameEdit')
464 self.DetailsLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.NameEdit)
465 self.PublisherLabel = QtGui.QLabel(self.DetailsWidget)
466- self.PublisherLabel.setObjectName("PublisherLabel")
467+ self.PublisherLabel.setObjectName(u'PublisherLabel')
468 self.DetailsLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.PublisherLabel)
469 self.PublisherEdit = QtGui.QLineEdit(self.DetailsWidget)
470- self.PublisherEdit.setObjectName("PublisherEdit")
471+ self.PublisherEdit.setObjectName(u'PublisherEdit')
472 self.DetailsLayout.setWidget(1, QtGui.QFormLayout.FieldRole, self.PublisherEdit)
473 self.SongBookLayout.addWidget(self.DetailsWidget)
474 self.MessageLabel = QtGui.QLabel(self.SongBookGroup)
475- self.MessageLabel.setObjectName("MessageLabel")
476+ self.MessageLabel.setObjectName(u'MessageLabel')
477 self.SongBookLayout.addWidget(self.MessageLabel)
478 self.ButtonWidget = QtGui.QWidget(self.SongBookGroup)
479 sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred)
480@@ -63,52 +69,51 @@
481 sizePolicy.setHeightForWidth(self.ButtonWidget.sizePolicy().hasHeightForWidth())
482 self.ButtonWidget.setSizePolicy(sizePolicy)
483 self.ButtonWidget.setMinimumSize(QtCore.QSize(0, 0))
484- self.ButtonWidget.setObjectName("ButtonWidget")
485+ self.ButtonWidget.setObjectName(u'ButtonWidget')
486 self.ButtonLayout = QtGui.QHBoxLayout(self.ButtonWidget)
487 self.ButtonLayout.setSpacing(8)
488 self.ButtonLayout.setMargin(0)
489- self.ButtonLayout.setObjectName("ButtonLayout")
490+ self.ButtonLayout.setObjectName(u'ButtonLayout')
491 spacerItem = QtGui.QSpacerItem(61, 24, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
492 self.ButtonLayout.addItem(spacerItem)
493 self.ClearButton = QtGui.QPushButton(self.ButtonWidget)
494 icon = QtGui.QIcon()
495- icon.addPixmap(QtGui.QPixmap(":/services/service_new.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
496+ icon.addPixmap(QtGui.QPixmap(u':/services/service_new.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off)
497 self.ClearButton.setIcon(icon)
498- self.ClearButton.setObjectName("ClearButton")
499+ self.ClearButton.setObjectName(u'ClearButton')
500 self.ButtonLayout.addWidget(self.ClearButton)
501 self.AddUpdateButton = QtGui.QPushButton(self.ButtonWidget)
502 icon1 = QtGui.QIcon()
503- icon1.addPixmap(QtGui.QPixmap(":/services/service_save.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
504+ icon1.addPixmap(QtGui.QPixmap(u':/services/service_save.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off)
505 self.AddUpdateButton.setIcon(icon1)
506- self.AddUpdateButton.setObjectName("AddUpdateButton")
507+ self.AddUpdateButton.setObjectName(u'AddUpdateButton')
508 self.ButtonLayout.addWidget(self.AddUpdateButton)
509 self.DeleteButton = QtGui.QPushButton(self.ButtonWidget)
510 icon2 = QtGui.QIcon()
511- icon2.addPixmap(QtGui.QPixmap(":/services/service_delete.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
512+ icon2.addPixmap(QtGui.QPixmap(u':/services/service_delete.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off)
513 self.DeleteButton.setIcon(icon2)
514- self.DeleteButton.setObjectName("DeleteButton")
515+ self.DeleteButton.setObjectName(u'DeleteButton')
516 self.ButtonLayout.addWidget(self.DeleteButton)
517 self.SongBookLayout.addWidget(self.ButtonWidget)
518 self.DialogLayout.addWidget(self.SongBookGroup)
519 self.ButtonBox = QtGui.QDialogButtonBox(SongBookDialog)
520 self.ButtonBox.setOrientation(QtCore.Qt.Horizontal)
521 self.ButtonBox.setStandardButtons(QtGui.QDialogButtonBox.Ok)
522- self.ButtonBox.setObjectName("ButtonBox")
523+ self.ButtonBox.setObjectName(u'ButtonBox')
524 self.DialogLayout.addWidget(self.ButtonBox)
525-
526 self.retranslateUi(SongBookDialog)
527- QtCore.QObject.connect(self.ButtonBox, QtCore.SIGNAL("accepted()"), SongBookDialog.accept)
528- QtCore.QObject.connect(self.ButtonBox, QtCore.SIGNAL("rejected()"), SongBookDialog.reject)
529+ QtCore.QObject.connect(self.ButtonBox, QtCore.SIGNAL(u'accepted()'), SongBookDialog.accept)
530+ QtCore.QObject.connect(self.ButtonBox, QtCore.SIGNAL(u'rejected()'), SongBookDialog.reject)
531 QtCore.QMetaObject.connectSlotsByName(SongBookDialog)
532
533 def retranslateUi(self, SongBookDialog):
534- SongBookDialog.setWindowTitle(QtGui.QApplication.translate("SongBookDialog", "Book Song Maintenance", None, QtGui.QApplication.UnicodeUTF8))
535- self.SongBookGroup.setTitle(QtGui.QApplication.translate("SongBookDialog", "Song Book", None, QtGui.QApplication.UnicodeUTF8))
536- self.NameLabel.setText(QtGui.QApplication.translate("SongBookDialog", "Name:", None, QtGui.QApplication.UnicodeUTF8))
537- self.PublisherLabel.setText(QtGui.QApplication.translate("SongBookDialog", "Publisher:", None, QtGui.QApplication.UnicodeUTF8))
538- self.ClearButton.setToolTip(QtGui.QApplication.translate("SongBookDialog", "Clear Selection", None, QtGui.QApplication.UnicodeUTF8))
539- self.ClearButton.setText(QtGui.QApplication.translate("SongBookDialog", "New", None, QtGui.QApplication.UnicodeUTF8))
540- self.AddUpdateButton.setToolTip(QtGui.QApplication.translate("SongBookDialog", "Add Update Author", None, QtGui.QApplication.UnicodeUTF8))
541- self.AddUpdateButton.setText(QtGui.QApplication.translate("SongBookDialog", "Save", None, QtGui.QApplication.UnicodeUTF8))
542- self.DeleteButton.setToolTip(QtGui.QApplication.translate("SongBookDialog", "Delete Author", None, QtGui.QApplication.UnicodeUTF8))
543- self.DeleteButton.setText(QtGui.QApplication.translate("SongBookDialog", "Delete", None, QtGui.QApplication.UnicodeUTF8))
544+ SongBookDialog.setWindowTitle(translate(u'SongBookDialog', u'Book Song Maintenance'))
545+ self.SongBookGroup.setTitle(translate(u'SongBookDialog', u'Song Book'))
546+ self.NameLabel.setText(translate(u'SongBookDialog', u'Name:'))
547+ self.PublisherLabel.setText(translate(u'SongBookDialog', u'Publisher:'))
548+ self.ClearButton.setToolTip(translate(u'SongBookDialog', u'Clear Selection'))
549+ self.ClearButton.setText(translate(u'SongBookDialog', u'Clear'))
550+ self.AddUpdateButton.setToolTip(translate(u'SongBookDialog', u'Add Update Author'))
551+ self.AddUpdateButton.setText(translate(u'SongBookDialog', u'Save'))
552+ self.DeleteButton.setToolTip(translate(u'SongBookDialog', u'Delete Author'))
553+ self.DeleteButton.setText(translate(u'SongBookDialog', u'Delete'))
554
555=== modified file 'openlp/plugins/songs/forms/songbookform.py'
556--- openlp/plugins/songs/forms/songbookform.py 2009-06-10 17:12:03 +0000
557+++ openlp/plugins/songs/forms/songbookform.py 2009-06-14 15:12:40 +0000
558@@ -44,28 +44,24 @@
559 QtCore.SIGNAL(u'pressed()'), self.onAddUpdateButtonClick)
560 QtCore.QObject.connect(self.NameEdit,
561 QtCore.SIGNAL(u'lostFocus()'), self.onBookNameEditLostFocus)
562- QtCore.QObject.connect(self.BookSongListView,
563+ QtCore.QObject.connect(self.BookSongListWidget,
564 QtCore.SIGNAL(u'clicked(QModelIndex)'), self.onBooksListViewItemClicked)
565
566 def load_form(self):
567 """
568 Refresh the screen and rest fields
569 """
570- self.BookSongListData.resetStore()
571+ self.BookSongListWidget.clear()
572 self.onClearButtonClick() # tidy up screen
573- Books = self.songmanager.get_books()
574- for Book in Books:
575- self.BookSongListData.addRow(Book.id,Book.name)
576- #rowCount is number of rows BUT test should be Zero based
577- row_count = self.BookSongListData.rowCount(None) - 1
578- if self.currentRow > row_count:
579- # in case we have delete the last row of the table
580- self.currentRow = row_count
581- row = self.BookSongListData.createIndex(self.currentRow, 0)
582- if row.isValid():
583- self.BookSongListView.selectionModel().setCurrentIndex(row,
584- QtGui.QItemSelectionModel.SelectCurrent)
585- self._validate_form()
586+ books = self.songmanager.get_books()
587+ for book in books:
588+ book_name = QtGui.QListWidgetItem(book.name)
589+ book_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(book.id))
590+ self.BookSongListWidget.addItem(book_name)
591+ if self.currentRow >= self.BookSongListWidget.count() :
592+ self.BookSongListWidget.setCurrentRow(self.BookSongListWidget.count() - 1)
593+ else:
594+ self.BookSongListWidget.setCurrentRow(self.currentRow)
595
596 def onDeleteButtonClick(self):
597 """
598@@ -106,10 +102,10 @@
599 An Book has been selected display it
600 If the Book is attached to a Song prevent delete
601 """
602- self.currentRow = index.row()
603- id = int(self.BookSongListData.getId(index))
604- self.Book = self.songmanager.get_book(id)
605-
606+ self.currentRow = self.BookSongListWidget.currentRow()
607+ item = self.BookSongListWidget.currentItem()
608+ item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
609+ self.Book = self.songmanager.get_book(item_id)
610 self.NameEdit.setText(self.Book.name)
611 self.PublisherEdit.setText(self.Book.publisher)
612 if len(self.Book.songs) > 0:
613
614=== modified file 'openlp/plugins/songs/forms/topicsdialog.py'
615--- openlp/plugins/songs/forms/topicsdialog.py 2009-06-04 19:00:41 +0000
616+++ openlp/plugins/songs/forms/topicsdialog.py 2009-06-14 15:12:40 +0000
617@@ -1,82 +1,88 @@
618 # -*- coding: utf-8 -*-
619-
620-# Form implementation generated from reading ui file 'topicsdialog.ui'
621-#
622-# Created: Sun Jan 4 08:42:59 2009
623-# by: PyQt4 UI code generator 4.4.3
624-#
625-# WARNING! All changes made in this file will be lost!
626-
627+# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
628+"""
629+OpenLP - Open Source Lyrics Projection
630+Copyright (c) 2008 Raoul Snyman
631+Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley,
632+
633+This program is free software; you can redistribute it and/or modify it under
634+the terms of the GNU General Public License as published by the Free Software
635+Foundation; version 2 of the License.
636+
637+This program is distributed in the hope that it will be useful, but WITHOUT ANY
638+WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
639+PARTICULAR PURPOSE. See the GNU General Public License for more details.
640+
641+You should have received a copy of the GNU General Public License along with
642+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
643+Place, Suite 330, Boston, MA 02111-1307 USA
644+"""
645 from PyQt4 import QtCore, QtGui
646-from openlp.plugins.songs.lib import TextListData
647+from openlp.core.lib import translate
648
649 class Ui_TopicsDialog(object):
650 def setupUi(self, TopicsDialog):
651- TopicsDialog.setObjectName("TopicsDialog")
652+ TopicsDialog.setObjectName(u'TopicsDialog')
653 TopicsDialog.resize(387, 463)
654 self.gridLayout_2 = QtGui.QGridLayout(TopicsDialog)
655- self.gridLayout_2.setObjectName("gridLayout_2")
656+ self.gridLayout_2.setObjectName(u'gridLayout_2')
657 self.TopicGroupBox = QtGui.QGroupBox(TopicsDialog)
658- self.TopicGroupBox.setObjectName("TopicGroupBox")
659+ self.TopicGroupBox.setObjectName(u'TopicGroupBox')
660 self.gridLayout = QtGui.QGridLayout(self.TopicGroupBox)
661- self.gridLayout.setObjectName("gridLayout")
662+ self.gridLayout.setObjectName(u'gridLayout')
663 self.TopicNameLabel = QtGui.QLabel(self.TopicGroupBox)
664- self.TopicNameLabel.setObjectName("TopicNameLabel")
665+ self.TopicNameLabel.setObjectName(u'TopicNameLabel')
666 self.gridLayout.addWidget(self.TopicNameLabel, 0, 0, 1, 1)
667 self.TopicNameEdit = QtGui.QLineEdit(self.TopicGroupBox)
668- self.TopicNameEdit.setObjectName("TopicNameEdit")
669+ self.TopicNameEdit.setObjectName(u'TopicNameEdit')
670 self.gridLayout.addWidget(self.TopicNameEdit, 0, 1, 1, 4)
671 spacerItem = QtGui.QSpacerItem(198, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
672 self.gridLayout.addItem(spacerItem, 1, 0, 1, 2)
673 self.DeleteButton = QtGui.QPushButton(self.TopicGroupBox)
674 icon = QtGui.QIcon()
675- icon.addPixmap(QtGui.QPixmap(":/services/service_delete.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
676+ icon.addPixmap(QtGui.QPixmap(u':/services/service_delete.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off)
677 self.DeleteButton.setIcon(icon)
678- self.DeleteButton.setObjectName("DeleteButton")
679+ self.DeleteButton.setObjectName(u'DeleteButton')
680 self.gridLayout.addWidget(self.DeleteButton, 1, 3, 1, 1)
681 self.AddUpdateButton = QtGui.QPushButton(self.TopicGroupBox)
682 icon1 = QtGui.QIcon()
683- icon1.addPixmap(QtGui.QPixmap(":/services/service_save.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
684+ icon1.addPixmap(QtGui.QPixmap(u':/services/service_save.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off)
685 self.AddUpdateButton.setIcon(icon1)
686- self.AddUpdateButton.setObjectName("AddUpdateButton")
687+ self.AddUpdateButton.setObjectName(u'AddUpdateButton')
688 self.gridLayout.addWidget(self.AddUpdateButton, 1, 4, 1, 1)
689 self.ClearButton = QtGui.QPushButton(self.TopicGroupBox)
690 icon2 = QtGui.QIcon()
691- icon2.addPixmap(QtGui.QPixmap(":/services/service_new.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
692+ icon2.addPixmap(QtGui.QPixmap(u':/services/service_new.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off)
693 self.ClearButton.setIcon(icon2)
694- self.ClearButton.setObjectName("ClearButton")
695+ self.ClearButton.setObjectName(u'ClearButton')
696 self.gridLayout.addWidget(self.ClearButton, 1, 2, 1, 1)
697 self.gridLayout_2.addWidget(self.TopicGroupBox, 1, 0, 1, 1)
698 self.MessageLabel = QtGui.QLabel(TopicsDialog)
699- self.MessageLabel.setObjectName("MessageLabel")
700+ self.MessageLabel.setObjectName(u'MessageLabel')
701 self.gridLayout_2.addWidget(self.MessageLabel, 3, 0, 1, 1)
702-
703- self.TopicsListView = QtGui.QListView()
704- self.TopicsListView.setAlternatingRowColors(True)
705- self.TopicsListData = TextListData()
706- self.TopicsListView.setModel(self.TopicsListData)
707- self.gridLayout_2.addWidget(self.TopicsListView, 0, 0, 1, 1)
708-
709+ self.TopicsListWidget = QtGui.QListWidget()
710+ self.TopicsListWidget.setAlternatingRowColors(True)
711+ self.gridLayout_2.addWidget(self.TopicsListWidget, 0, 0, 1, 1)
712 self.ButtonBox = QtGui.QDialogButtonBox(TopicsDialog)
713 self.ButtonBox.setOrientation(QtCore.Qt.Horizontal)
714 self.ButtonBox.setStandardButtons(QtGui.QDialogButtonBox.Ok)
715- self.ButtonBox.setObjectName("ButtonBox")
716+ self.ButtonBox.setObjectName(u'ButtonBox')
717 self.gridLayout_2.addWidget(self.ButtonBox, 2, 0, 1, 1)
718
719 self.retranslateUi(TopicsDialog)
720- QtCore.QObject.connect(self.ButtonBox, QtCore.SIGNAL("accepted()"), TopicsDialog.accept)
721- QtCore.QObject.connect(self.ButtonBox, QtCore.SIGNAL("rejected()"), TopicsDialog.reject)
722+ QtCore.QObject.connect(self.ButtonBox, QtCore.SIGNAL(u'accepted()'), TopicsDialog.accept)
723+ QtCore.QObject.connect(self.ButtonBox, QtCore.SIGNAL(u'rejected()'), TopicsDialog.reject)
724 QtCore.QMetaObject.connectSlotsByName(TopicsDialog)
725
726 def retranslateUi(self, TopicsDialog):
727- TopicsDialog.setWindowTitle(QtGui.QApplication.translate("TopicsDialog", "Topic Maintenance", None, QtGui.QApplication.UnicodeUTF8))
728- self.TopicGroupBox.setTitle(QtGui.QApplication.translate("TopicsDialog", "Topic", None, QtGui.QApplication.UnicodeUTF8))
729- self.TopicNameLabel.setText(QtGui.QApplication.translate("TopicsDialog", "Topic Name:", None, QtGui.QApplication.UnicodeUTF8))
730+ TopicsDialog.setWindowTitle(translate(u'TopicsDialog', u'Topic Maintenance'))
731+ self.TopicGroupBox.setTitle(translate(u'TopicsDialog', u'Topic'))
732+ self.TopicNameLabel.setText(translate(u'TopicsDialog', u'Topic Name:'))
733
734- self.DeleteButton.setToolTip(QtGui.QApplication.translate("TopicsDialog", "Delete Author", None, QtGui.QApplication.UnicodeUTF8))
735- self.DeleteButton.setText(QtGui.QApplication.translate("AuthorsDialog", "Delete", None, QtGui.QApplication.UnicodeUTF8))
736- self.AddUpdateButton.setToolTip(QtGui.QApplication.translate("TopicsDialog", "Add Update Author", None, QtGui.QApplication.UnicodeUTF8))
737- self.AddUpdateButton.setText(QtGui.QApplication.translate("AuthorsDialog", "Save", None, QtGui.QApplication.UnicodeUTF8))
738- self.ClearButton.setToolTip(QtGui.QApplication.translate("TopicsDialog", "Clear Selection", None, QtGui.QApplication.UnicodeUTF8))
739- self.ClearButton.setText(QtGui.QApplication.translate("TopicsDialog", "Clear", None, QtGui.QApplication.UnicodeUTF8))
740+ self.DeleteButton.setToolTip(translate(u'TopicsDialog', u'Delete Author'))
741+ self.DeleteButton.setText(translate(u'AuthorsDialog', u'Delete'))
742+ self.AddUpdateButton.setToolTip(translate(u'TopicsDialog', u'Add Update Author'))
743+ self.AddUpdateButton.setText(translate(u'AuthorsDialog', u'Save'))
744+ self.ClearButton.setToolTip(translate(u'TopicsDialog', u'Clear Selection'))
745+ self.ClearButton.setText(translate(u'TopicsDialog', u'Clear'))
746
747
748=== modified file 'openlp/plugins/songs/forms/topicsform.py'
749--- openlp/plugins/songs/forms/topicsform.py 2009-06-10 17:12:03 +0000
750+++ openlp/plugins/songs/forms/topicsform.py 2009-06-14 15:12:40 +0000
751@@ -18,7 +18,6 @@
752 """
753 from PyQt4 import QtGui, QtCore
754 from openlp.core.lib import translate
755-from openlp.plugins.songs.lib import TextListData
756 from openlp.plugins.songs.forms.topicsdialog import Ui_TopicsDialog
757 from openlp.plugins.songs.lib.classes import Topic
758
759@@ -44,27 +43,24 @@
760 QtCore.SIGNAL(u'pressed()'), self.onAddUpdateButtonClick)
761 QtCore.QObject.connect(self.TopicNameEdit,
762 QtCore.SIGNAL(u'lostFocus()'), self.onTopicNameEditLostFocus)
763- QtCore.QObject.connect(self.TopicsListView,
764- QtCore.SIGNAL(u'clicked(QModelIndex)'), self.onTopicsListViewItemClicked)
765+ QtCore.QObject.connect(self.TopicsListWidget,
766+ QtCore.SIGNAL(u'clicked(QModelIndex)'), self.onTopicsListWidgetItemClicked)
767
768 def load_form(self):
769 """
770 Refresh the screen and rest fields
771 """
772- self.TopicsListData.resetStore()
773+ self.TopicsListWidget.clear()
774 self.onClearButtonClick() # tidy up screen
775 topics = self.songmanager.get_topics()
776 for topic in topics:
777- self.TopicsListData.addRow(topic.id,topic.name)
778- #rowCount is number of rows BUT test should be Zero based
779- row_count = self.TopicsListData.rowCount(None) - 1
780- if self.currentRow > row_count:
781- # in case we have delete the last row of the table
782- self.currentRow = row_count
783- row = self.TopicsListData.createIndex(self.currentRow, 0)
784- if row.isValid():
785- self.TopicsListView.selectionModel().setCurrentIndex(row,
786- QtGui.QItemSelectionModel.SelectCurrent)
787+ topic_name = QtGui.QListWidgetItem(topic.name)
788+ topic_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(topic.id))
789+ self.TopicsListWidget.addItem(topic_name)
790+ if self.currentRow >= self.TopicsListWidget.count() :
791+ self.TopicsListWidget.setCurrentRow(self.TopicsListWidget.count() - 1)
792+ else:
793+ self.TopicsListWidget.setCurrentRow(self.currentRow)
794 self._validate_form()
795
796 def onDeleteButtonClick(self):
797@@ -99,15 +95,15 @@
798 self.topic = None
799 self._validate_form()
800
801- def onTopicsListViewItemClicked(self, index):
802+ def onTopicsListWidgetItemClicked(self, index):
803 """
804 An Topic has been selected display it
805 If the Topic is attached to a Song prevent delete
806 """
807- self.currentRow = index.row()
808- id = int(self.TopicsListData.getId(index))
809- self.topic = self.songmanager.get_topic(id)
810-
811+ self.currentRow = self.TopicsListWidget.currentRow()
812+ item = self.TopicsListWidget.currentItem()
813+ item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
814+ self.topic = self.songmanager.get_topic(item_id)
815 self.TopicNameEdit.setText(self.topic.name)
816 if len(self.topic.songs) > 0:
817 self.MessageLabel.setText(translate(u'TopicForm', u'Topic in use "Delete" is disabled'))
818
819=== modified file 'openlp/plugins/songs/lib/__init__.py'
820--- openlp/plugins/songs/lib/__init__.py 2009-06-03 15:38:14 +0000
821+++ openlp/plugins/songs/lib/__init__.py 2009-06-14 15:12:40 +0000
822@@ -17,7 +17,6 @@
823 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
824 Place, Suite 330, Boston, MA 02111-1307 USA
825 """
826-from textlistdata import TextListData
827 from manager import SongManager
828 from songstab import SongsTab
829 from mediaitem import SongMediaItem
830
831=== modified file 'openlp/plugins/songs/lib/manager.py'
832--- openlp/plugins/songs/lib/manager.py 2009-06-14 06:48:38 +0000
833+++ openlp/plugins/songs/lib/manager.py 2009-06-14 13:50:56 +0000
834@@ -127,12 +127,6 @@
835 """
836 return self.session.query(Author).get(id)
837
838- def get_author_by_name(self, name):
839- """
840- Details of the Author
841- """
842- return self.session.query(Author).filter_by(display_name = name).first()
843-
844 def save_author(self, author):
845 """
846 Save the Author and refresh the cache
847@@ -172,12 +166,6 @@
848 """
849 return self.session.query(Topic).get(id)
850
851- def get_topic_by_name(self, name):
852- """
853- Details of the Topic
854- """
855- return self.session.query(Topic).filter_by(name = name).first()
856-
857 def save_topic(self, topic):
858 """
859 Save the Topic
860@@ -217,12 +205,6 @@
861 """
862 return self.session.query(Book).get(id)
863
864- def get_book_by_name(self, name):
865- """
866- Details of the Books
867- """
868- return self.session.query(Book).filter_by(name = name).first()
869-
870 def save_book(self, book):
871 """
872 Save the Book
873
874=== modified file 'openlp/plugins/songs/lib/mediaitem.py'
875--- openlp/plugins/songs/lib/mediaitem.py 2009-06-14 07:25:39 +0000
876+++ openlp/plugins/songs/lib/mediaitem.py 2009-06-14 13:50:56 +0000
877@@ -23,12 +23,11 @@
878 from openlp.core.lib import MediaManagerItem, translate, ServiceItem, SongXMLParser
879
880 from openlp.plugins.songs.forms import EditSongForm
881-from openlp.plugins.songs.lib import TextListData
882
883-class SongList(QtGui.QListView):
884+class SongList(QtGui.QListWidget):
885
886 def __init__(self,parent=None,name=None):
887- QtGui.QListView.__init__(self,parent)
888+ QtGui.QListWidget.__init__(self,parent)
889
890 def mouseMoveEvent(self, event):
891 """
892@@ -119,14 +118,12 @@
893 self.SearchLayout.addWidget(self.SearchTextButton, 3, 2, 1, 1)
894 # Add the song widget to the page layout
895 self.PageLayout.addWidget(self.SongWidget)
896- self.SongListView = SongList()
897- self.SongListView.setAlternatingRowColors(True)
898- self.SongListData = TextListData()
899- self.SongListView.setModel(self.SongListData)
900- self.SongListView.setDragEnabled(True)
901- self.SongListView.setObjectName(u'SongListView')
902- self.PageLayout.addWidget(self.SongListView)
903- self.SongListView.setDragEnabled(True)
904+ self.SongListWidget = SongList()
905+ self.SongListWidget.setAlternatingRowColors(True)
906+ self.SongListWidget.setDragEnabled(True)
907+ self.SongListWidget.setObjectName(u'SongListWidget')
908+ self.PageLayout.addWidget(self.SongListWidget)
909+ self.SongListWidget.setDragEnabled(True)
910 # Signals and slots
911 QtCore.QObject.connect(self.SearchTextButton,
912 QtCore.SIGNAL(u'pressed()'), self.onSearchTextButtonClick)
913@@ -134,21 +131,21 @@
914 QtCore.SIGNAL(u'pressed()'), self.onClearTextButtonClick)
915 QtCore.QObject.connect(self.SearchTextEdit,
916 QtCore.SIGNAL(u'textChanged(const QString&)'), self.onSearchTextEditChanged)
917- QtCore.QObject.connect(self.SongListView,
918+ QtCore.QObject.connect(self.SongListWidget,
919 QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.onSongPreviewClick)
920 #define and add the context menu
921- self.SongListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
922- self.SongListView.addAction(self.contextMenuAction(self.SongListView,
923+ self.SongListWidget.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
924+ self.SongListWidget.addAction(self.contextMenuAction(self.SongListWidget,
925 ':/songs/song_new.png', translate(u'SongMediaItem', u'&Edit Song'),
926 self.onSongEditClick))
927- self.SongListView.addAction(self.contextMenuSeparator(self.SongListView))
928- self.SongListView.addAction(self.contextMenuAction(self.SongListView,
929+ self.SongListWidget.addAction(self.contextMenuSeparator(self.SongListWidget))
930+ self.SongListWidget.addAction(self.contextMenuAction(self.SongListWidget,
931 ':/system/system_preview.png', translate(u'SongMediaItem', u'&Preview Song'),
932 self.onSongPreviewClick))
933- self.SongListView.addAction(self.contextMenuAction(self.SongListView,
934+ self.SongListWidget.addAction(self.contextMenuAction(self.SongListWidget,
935 ':/system/system_live.png', translate(u'SongMediaItem', u'&Show Live'),
936 self.onSongLiveClick))
937- self.SongListView.addAction(self.contextMenuAction(self.SongListView,
938+ self.SongListWidget.addAction(self.contextMenuAction(self.SongListWidget,
939 ':/system/system_add.png', translate(u'SongMediaItem', u'&Add to Service'),
940 self.onSongAddClick))
941
942@@ -165,7 +162,7 @@
943
944 def displayResults(self, searchresults):
945 log.debug(u'display results')
946- self.SongListData.resetStore()
947+ self.SongListWidget.clear()
948 #log.debug(u'Records returned from search %s", len(searchresults))
949 for song in searchresults:
950 author_list = u''
951@@ -174,7 +171,9 @@
952 author_list = author_list + u', '
953 author_list = author_list + author.display_name
954 song_detail = unicode(u'%s (%s)' % (unicode(song.title), unicode(author_list)))
955- self.SongListData.addRow(song.id,song_detail)
956+ song_name = QtGui.QListWidgetItem(song_detail)
957+ song_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(song.id))
958+ self.SongListWidget.addItem(song_name)
959
960 def onClearTextButtonClick(self):
961 """
962@@ -209,18 +208,16 @@
963 self.edit_song_form.exec_()
964
965 def onSongEditClick(self):
966- indexes = self.SongListView.selectedIndexes()
967- for index in indexes:
968- id = self.SongListData.getId(index)
969- self.edit_song_form.loadSong(id)
970- self.edit_song_form.exec_()
971+ item = self.SongListWidget.currentItem()
972+ item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
973+ self.edit_song_form.loadSong(item_id)
974+ self.edit_song_form.exec_()
975
976 def onSongDeleteClick(self):
977- indexes = self.SongListView.selectedIndexes()
978- for index in indexes:
979- id = self.SongListData.getId(index)
980- self.parent.songmanager.delete_song(id)
981- self.SongListData.deleteRow(index)
982+ item = self.SongListWidget.currentItem()
983+ item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
984+ self.parent.songmanager.delete_song(id)
985+ self.SongListWidget.removeItem(item)
986
987 def onSongPreviewClick(self):
988 service_item = ServiceItem(self.parent)
989@@ -233,29 +230,28 @@
990 raw_footer = []
991 author_list = u''
992 ccl = u''
993- indexes = self.SongListView.selectedIndexes()
994- for index in indexes:
995- id = self.SongListData.getId(index)
996- song = self.parent.songmanager.get_song(id)
997- service_item.theme = song.theme_name
998- if song.lyrics.startswith(u'<?xml version='):
999- songXML=SongXMLParser(song.lyrics)
1000- verseList = songXML.get_verses()
1001- for verse in verseList:
1002- service_item.add_from_text(verse[1][:30], verse[1])
1003- else:
1004- verses = song.lyrics.split(u'\n\n')
1005- for slide in verses:
1006- service_item.add_from_text(slide[:30], slide)
1007- service_item.title = song.title
1008- for author in song.authors:
1009- if len(author_list) > 1:
1010- author_list = author_list + u', '
1011- author_list = author_list + unicode(author.display_name)
1012- if song.ccli_number == None or len(song.ccli_number) == 0:
1013- ccl = self.parent.settings.GeneralTab.CCLNumber
1014- else:
1015- ccl = unicode(song.ccli_number)
1016+ item = self.SongListWidget.currentItem()
1017+ item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
1018+ song = self.parent.songmanager.get_song(item_id)
1019+ service_item.theme = song.theme_name
1020+ if song.lyrics.startswith(u'<?xml version='):
1021+ songXML=SongXMLParser(song.lyrics)
1022+ verseList = songXML.get_verses()
1023+ for verse in verseList:
1024+ service_item.add_from_text(verse[1][:30], verse[1])
1025+ else:
1026+ verses = song.lyrics.split(u'\n\n')
1027+ for slide in verses:
1028+ service_item.add_from_text(slide[:30], slide)
1029+ service_item.title = song.title
1030+ for author in song.authors:
1031+ if len(author_list) > 1:
1032+ author_list = author_list + u', '
1033+ author_list = author_list + unicode(author.display_name)
1034+ if song.ccli_number == None or len(song.ccli_number) == 0:
1035+ ccl = self.parent.settings.GeneralTab.CCLNumber
1036+ else:
1037+ ccl = unicode(song.ccli_number)
1038 raw_footer.append(song.title)
1039 raw_footer.append(author_list)
1040 raw_footer.append(song.copyright )
1041
1042=== removed file 'openlp/plugins/songs/lib/textlistdata.py'
1043--- openlp/plugins/songs/lib/textlistdata.py 2009-06-13 16:15:55 +0000
1044+++ openlp/plugins/songs/lib/textlistdata.py 1970-01-01 00:00:00 +0000
1045@@ -1,81 +0,0 @@
1046-# -*- coding: utf-8 -*-
1047-# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
1048-"""
1049-OpenLP - Open Source Lyrics Projection
1050-Copyright (c) 2008 Raoul Snyman
1051-Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley
1052-
1053-This program is free software; you can redistribute it and/or modify it under
1054-the terms of the GNU General Public License as published by the Free Software
1055-Foundation; version 2 of the License.
1056-
1057-This program is distributed in the hope that it will be useful, but WITHOUT ANY
1058-WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
1059-PARTICULAR PURPOSE. See the GNU General Public License for more details.
1060-
1061-You should have received a copy of the GNU General Public License along with
1062-this program; if not, write to the Free Software Foundation, Inc., 59 Temple
1063-Place, Suite 330, Boston, MA 02111-1307 USA
1064-"""
1065-import logging
1066-
1067-from PyQt4 import QtCore, QtGui
1068-
1069-class TextListData(QtCore.QAbstractListModel):
1070- """
1071- An abstract list of strings
1072- """
1073- global log
1074- log = logging.getLogger(u'TextListData')
1075- log.info(u'started')
1076-
1077- def __init__(self):
1078- QtCore.QAbstractListModel.__init__(self)
1079- self.items = [] # will be a list of (database id , title) tuples
1080-
1081- def resetStore(self):
1082- #reset list so can be reloaded
1083- self.items = []
1084-
1085- def rowCount(self, parent):
1086- return len(self.items)
1087-
1088- def insertRow(self, row, id, title):
1089- self.beginInsertRows(QtCore.QModelIndex(),row,row)
1090- self.items.insert(row, (id, title))
1091- self.endInsertRows()
1092-
1093- def removeRow(self, row):
1094- self.beginRemoveRows(QtCore.QModelIndex(), row,row)
1095- self.items.pop(row)
1096- self.endRemoveRows()
1097-
1098- def addRow(self, id, title):
1099- self.insertRow(len(self.items), id, title)
1100-
1101- def data(self, index, role):
1102- row = index.row()
1103- if row > len(self.items): # if the last row is selected and deleted, we then get called with an empty row!
1104- return QtCore.QVariant()
1105- if role == QtCore.Qt.DisplayRole:
1106- if row == self.rowCount(None):
1107- row -= 1
1108- retval = self.items[row][1]
1109- else:
1110- retval = QtCore.QVariant()
1111- if type(retval) is not type(QtCore.QVariant):
1112- return QtCore.QVariant(retval)
1113- else:
1114- return retval
1115-
1116- def getIdList(self):
1117- filelist = [item[0] for item in self.items];
1118- return filelist
1119-
1120- def getId(self, index):
1121- row = index.row()
1122- return self.items[row][0]
1123-
1124- def deleteRow(self, index):
1125- row = index.row()
1126- self.removeRow(row)