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
=== modified file 'openlp/plugins/songs/forms/authorsdialog.py'
--- openlp/plugins/songs/forms/authorsdialog.py 2009-06-04 19:00:41 +0000
+++ openlp/plugins/songs/forms/authorsdialog.py 2009-06-14 15:12:40 +0000
@@ -1,115 +1,121 @@
1# -*- coding: utf-8 -*-1# -*- coding: utf-8 -*-
22# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
3# Form implementation generated from reading ui file 'authorsdialog.ui'3"""
4#4OpenLP - Open Source Lyrics Projection
5# Created: Sat Jan 3 11:48:36 20095Copyright (c) 2008 Raoul Snyman
6# by: PyQt4 UI code generator 4.4.36Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley,
7#7
8# WARNING! All changes made in this file will be lost!8This program is free software; you can redistribute it and/or modify it under
99the terms of the GNU General Public License as published by the Free Software
10Foundation; version 2 of the License.
11
12This program is distributed in the hope that it will be useful, but WITHOUT ANY
13WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
14PARTICULAR PURPOSE. See the GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License along with
17this program; if not, write to the Free Software Foundation, Inc., 59 Temple
18Place, Suite 330, Boston, MA 02111-1307 USA
19"""
10from PyQt4 import QtCore, QtGui20from PyQt4 import QtCore, QtGui
11from openlp.plugins.songs.lib import TextListData21from openlp.core.lib import translate
1222
13class Ui_AuthorsDialog(object):23class Ui_AuthorsDialog(object):
14 def setupUi(self, AuthorsDialog):24 def setupUi(self, AuthorsDialog):
15 AuthorsDialog.setObjectName("AuthorsDialog")25 AuthorsDialog.setObjectName(u'AuthorsDialog')
16 AuthorsDialog.resize(410, 505)26 AuthorsDialog.resize(410, 505)
17 self.DialogLayout = QtGui.QVBoxLayout(AuthorsDialog)27 self.DialogLayout = QtGui.QVBoxLayout(AuthorsDialog)
18 self.DialogLayout.setSpacing(8)28 self.DialogLayout.setSpacing(8)
19 self.DialogLayout.setMargin(8)29 self.DialogLayout.setMargin(8)
20 self.DialogLayout.setObjectName("DialogLayout")30 self.DialogLayout.setObjectName(u'DialogLayout')
2131 self.AuthorListWidget = QtGui.QListWidget()
22 self.AuthorListView = QtGui.QListView()32 self.AuthorListWidget.setAlternatingRowColors(True)
23 self.AuthorListView.setAlternatingRowColors(True)33 self.DialogLayout.addWidget(self.AuthorListWidget)
24 self.AuthorListData = TextListData()
25 self.AuthorListView.setModel(self.AuthorListData)
26 self.DialogLayout.addWidget(self.AuthorListView)
27
28 self.AuthorDetails = QtGui.QGroupBox(AuthorsDialog)34 self.AuthorDetails = QtGui.QGroupBox(AuthorsDialog)
29 self.AuthorDetails.setMinimumSize(QtCore.QSize(0, 0))35 self.AuthorDetails.setMinimumSize(QtCore.QSize(0, 0))
30 self.AuthorDetails.setObjectName("AuthorDetails")36 self.AuthorDetails.setObjectName(u'AuthorDetails')
31 self.AuthorLayout = QtGui.QVBoxLayout(self.AuthorDetails)37 self.AuthorLayout = QtGui.QVBoxLayout(self.AuthorDetails)
32 self.AuthorLayout.setSpacing(8)38 self.AuthorLayout.setSpacing(8)
33 self.AuthorLayout.setMargin(8)39 self.AuthorLayout.setMargin(8)
34 self.AuthorLayout.setObjectName("AuthorLayout")40 self.AuthorLayout.setObjectName(u'AuthorLayout')
35 self.DetailsWidget = QtGui.QWidget(self.AuthorDetails)41 self.DetailsWidget = QtGui.QWidget(self.AuthorDetails)
36 self.DetailsWidget.setObjectName("DetailsWidget")42 self.DetailsWidget.setObjectName(u'DetailsWidget')
37 self.DetailsLayout = QtGui.QFormLayout(self.DetailsWidget)43 self.DetailsLayout = QtGui.QFormLayout(self.DetailsWidget)
38 self.DetailsLayout.setMargin(0)44 self.DetailsLayout.setMargin(0)
39 self.DetailsLayout.setSpacing(8)45 self.DetailsLayout.setSpacing(8)
40 self.DetailsLayout.setObjectName("DetailsLayout")46 self.DetailsLayout.setObjectName(u'DetailsLayout')
41 self.DisplayLabel = QtGui.QLabel(self.DetailsWidget)47 self.DisplayLabel = QtGui.QLabel(self.DetailsWidget)
42 self.DisplayLabel.setObjectName("DisplayLabel")48 self.DisplayLabel.setObjectName(u'DisplayLabel')
43 self.DetailsLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.DisplayLabel)49 self.DetailsLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.DisplayLabel)
44 self.DisplayEdit = QtGui.QLineEdit(self.DetailsWidget)50 self.DisplayEdit = QtGui.QLineEdit(self.DetailsWidget)
45 self.DisplayEdit.setObjectName("DisplayEdit")51 self.DisplayEdit.setObjectName(u'DisplayEdit')
46 self.DetailsLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.DisplayEdit)52 self.DetailsLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.DisplayEdit)
47 self.FirstNameLabel = QtGui.QLabel(self.DetailsWidget)53 self.FirstNameLabel = QtGui.QLabel(self.DetailsWidget)
48 self.FirstNameLabel.setObjectName("FirstNameLabel")54 self.FirstNameLabel.setObjectName(u'FirstNameLabel')
49 self.DetailsLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.FirstNameLabel)55 self.DetailsLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.FirstNameLabel)
50 self.FirstNameEdit = QtGui.QLineEdit(self.DetailsWidget)56 self.FirstNameEdit = QtGui.QLineEdit(self.DetailsWidget)
51 self.FirstNameEdit.setObjectName("FirstNameEdit")57 self.FirstNameEdit.setObjectName(u'FirstNameEdit')
52 self.DetailsLayout.setWidget(1, QtGui.QFormLayout.FieldRole, self.FirstNameEdit)58 self.DetailsLayout.setWidget(1, QtGui.QFormLayout.FieldRole, self.FirstNameEdit)
53 self.LastNameLabel = QtGui.QLabel(self.DetailsWidget)59 self.LastNameLabel = QtGui.QLabel(self.DetailsWidget)
54 self.LastNameLabel.setObjectName("LastNameLabel")60 self.LastNameLabel.setObjectName(u'LastNameLabel')
55 self.DetailsLayout.setWidget(2, QtGui.QFormLayout.LabelRole, self.LastNameLabel)61 self.DetailsLayout.setWidget(2, QtGui.QFormLayout.LabelRole, self.LastNameLabel)
56 self.LastNameEdit = QtGui.QLineEdit(self.DetailsWidget)62 self.LastNameEdit = QtGui.QLineEdit(self.DetailsWidget)
57 self.LastNameEdit.setObjectName("LastNameEdit")63 self.LastNameEdit.setObjectName(u'LastNameEdit')
58 self.DetailsLayout.setWidget(2, QtGui.QFormLayout.FieldRole, self.LastNameEdit)64 self.DetailsLayout.setWidget(2, QtGui.QFormLayout.FieldRole, self.LastNameEdit)
59 self.AuthorLayout.addWidget(self.DetailsWidget)65 self.AuthorLayout.addWidget(self.DetailsWidget)
60 self.MessageLabel = QtGui.QLabel(self.AuthorDetails)66 self.MessageLabel = QtGui.QLabel(self.AuthorDetails)
61 self.MessageLabel.setObjectName("MessageLabel")67 self.MessageLabel.setObjectName(u'MessageLabel')
62 self.AuthorLayout.addWidget(self.MessageLabel)68 self.AuthorLayout.addWidget(self.MessageLabel)
63 self.ButtonWidget = QtGui.QWidget(self.AuthorDetails)69 self.ButtonWidget = QtGui.QWidget(self.AuthorDetails)
64 self.ButtonWidget.setMinimumSize(QtCore.QSize(0, 0))70 self.ButtonWidget.setMinimumSize(QtCore.QSize(0, 0))
65 self.ButtonWidget.setObjectName("ButtonWidget")71 self.ButtonWidget.setObjectName(u'ButtonWidget')
66 self.ButtonLayout = QtGui.QHBoxLayout(self.ButtonWidget)72 self.ButtonLayout = QtGui.QHBoxLayout(self.ButtonWidget)
67 self.ButtonLayout.setSpacing(8)73 self.ButtonLayout.setSpacing(8)
68 self.ButtonLayout.setMargin(0)74 self.ButtonLayout.setMargin(0)
69 self.ButtonLayout.setObjectName("ButtonLayout")75 self.ButtonLayout.setObjectName(u'ButtonLayout')
70 spacerItem = QtGui.QSpacerItem(198, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)76 spacerItem = QtGui.QSpacerItem(198, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
71 self.ButtonLayout.addItem(spacerItem)77 self.ButtonLayout.addItem(spacerItem)
72 self.ClearButton = QtGui.QPushButton(self.ButtonWidget)78 self.ClearButton = QtGui.QPushButton(self.ButtonWidget)
73 icon = QtGui.QIcon()79 icon = QtGui.QIcon()
74 icon.addPixmap(QtGui.QPixmap(":/services/service_new.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)80 icon.addPixmap(QtGui.QPixmap(u':/services/service_new.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off)
75 self.ClearButton.setIcon(icon)81 self.ClearButton.setIcon(icon)
76 self.ClearButton.setObjectName("ClearButton")82 self.ClearButton.setObjectName(u'ClearButton')
77 self.ButtonLayout.addWidget(self.ClearButton)83 self.ButtonLayout.addWidget(self.ClearButton)
78 self.AddUpdateButton = QtGui.QPushButton(self.ButtonWidget)84 self.AddUpdateButton = QtGui.QPushButton(self.ButtonWidget)
79 icon1 = QtGui.QIcon()85 icon1 = QtGui.QIcon()
80 icon1.addPixmap(QtGui.QPixmap(":/services/service_save.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)86 icon1.addPixmap(QtGui.QPixmap(u':/services/service_save.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off)
81 self.AddUpdateButton.setIcon(icon1)87 self.AddUpdateButton.setIcon(icon1)
82 self.AddUpdateButton.setObjectName("AddUpdateButton")88 self.AddUpdateButton.setObjectName(u'AddUpdateButton')
83 self.ButtonLayout.addWidget(self.AddUpdateButton)89 self.ButtonLayout.addWidget(self.AddUpdateButton)
84 self.DeleteButton = QtGui.QPushButton(self.ButtonWidget)90 self.DeleteButton = QtGui.QPushButton(self.ButtonWidget)
85 icon2 = QtGui.QIcon()91 icon2 = QtGui.QIcon()
86 icon2.addPixmap(QtGui.QPixmap(":/services/service_delete.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)92 icon2.addPixmap(QtGui.QPixmap(u':/services/service_delete.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off)
87 self.DeleteButton.setIcon(icon2)93 self.DeleteButton.setIcon(icon2)
88 self.DeleteButton.setObjectName("DeleteButton")94 self.DeleteButton.setObjectName(u'DeleteButton')
89 self.ButtonLayout.addWidget(self.DeleteButton)95 self.ButtonLayout.addWidget(self.DeleteButton)
90 self.AuthorLayout.addWidget(self.ButtonWidget)96 self.AuthorLayout.addWidget(self.ButtonWidget)
91 self.DialogLayout.addWidget(self.AuthorDetails)97 self.DialogLayout.addWidget(self.AuthorDetails)
92 self.buttonBox = QtGui.QDialogButtonBox(AuthorsDialog)98 self.buttonBox = QtGui.QDialogButtonBox(AuthorsDialog)
93 self.buttonBox.setOrientation(QtCore.Qt.Horizontal)99 self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
94 self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Ok)100 self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Ok)
95 self.buttonBox.setObjectName("buttonBox")101 self.buttonBox.setObjectName(u'buttonBox')
96 self.DialogLayout.addWidget(self.buttonBox)102 self.DialogLayout.addWidget(self.buttonBox)
97103
98 self.retranslateUi(AuthorsDialog)104 self.retranslateUi(AuthorsDialog)
99 QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("accepted()"), AuthorsDialog.accept)105 QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'accepted()'), AuthorsDialog.accept)
100 QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("rejected()"), AuthorsDialog.reject)106 QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'rejected()'), AuthorsDialog.reject)
101 QtCore.QMetaObject.connectSlotsByName(AuthorsDialog)107 QtCore.QMetaObject.connectSlotsByName(AuthorsDialog)
102108
103 def retranslateUi(self, AuthorsDialog):109 def retranslateUi(self, AuthorsDialog):
104 AuthorsDialog.setWindowTitle(QtGui.QApplication.translate("AuthorsDialog", "Author Maintenance", None, QtGui.QApplication.UnicodeUTF8))110 AuthorsDialog.setWindowTitle(translate(u'AuthorsDialog', u'Author Maintenance'))
105 self.AuthorDetails.setTitle(QtGui.QApplication.translate("AuthorsDialog", "Author Details", None, QtGui.QApplication.UnicodeUTF8))111 self.AuthorDetails.setTitle(translate(u'AuthorsDialog', u'Author Details'))
106 self.DisplayLabel.setText(QtGui.QApplication.translate("AuthorsDialog", "Display Name:", None, QtGui.QApplication.UnicodeUTF8))112 self.DisplayLabel.setText(translate(u'AuthorsDialog', u'Display Name:'))
107 self.FirstNameLabel.setText(QtGui.QApplication.translate("AuthorsDialog", "First Name:", None, QtGui.QApplication.UnicodeUTF8))113 self.FirstNameLabel.setText(translate(u'AuthorsDialog', u'First Name:'))
108 self.LastNameLabel.setText(QtGui.QApplication.translate("AuthorsDialog", "Last Name:", None, QtGui.QApplication.UnicodeUTF8))114 self.LastNameLabel.setText(translate(u'AuthorsDialog', u'Last Name:'))
109 self.ClearButton.setToolTip(QtGui.QApplication.translate("AuthorsDialog", "Clear Selection", None, QtGui.QApplication.UnicodeUTF8))115 self.ClearButton.setToolTip(translate(u'AuthorsDialog', u'Clear Selection'))
110 self.ClearButton.setText(QtGui.QApplication.translate("AuthorsDialog", "Clear", None, QtGui.QApplication.UnicodeUTF8))116 self.ClearButton.setText(translate(u'AuthorsDialog', u'Clear'))
111 self.AddUpdateButton.setToolTip(QtGui.QApplication.translate("AuthorsDialog", "Add Update Author", None, QtGui.QApplication.UnicodeUTF8))117 self.AddUpdateButton.setToolTip(translate(u'AuthorsDialog', u'Add Update Author'))
112 self.AddUpdateButton.setText(QtGui.QApplication.translate("AuthorsDialog", "Save", None, QtGui.QApplication.UnicodeUTF8))118 self.AddUpdateButton.setText(translate(u'AuthorsDialog', u'Save'))
113 self.DeleteButton.setToolTip(QtGui.QApplication.translate("AuthorsDialog", "Delete Author", None, QtGui.QApplication.UnicodeUTF8))119 self.DeleteButton.setToolTip(translate(u'AuthorsDialog', u'Delete Author'))
114 self.DeleteButton.setText(QtGui.QApplication.translate("AuthorsDialog", "Delete", None, QtGui.QApplication.UnicodeUTF8))120 self.DeleteButton.setText(translate(u'AuthorsDialog', u'Delete'))
115 self.buttonBox.setToolTip(QtGui.QApplication.translate("AuthorsDialog", "Exit Screen", None, QtGui.QApplication.UnicodeUTF8))121 self.buttonBox.setToolTip(translate(u'AuthorsDialog', u'Exit Screen'))
116122
=== modified file 'openlp/plugins/songs/forms/authorsform.py'
--- openlp/plugins/songs/forms/authorsform.py 2009-06-10 17:12:03 +0000
+++ openlp/plugins/songs/forms/authorsform.py 2009-06-14 15:12:40 +0000
@@ -19,7 +19,7 @@
19from PyQt4 import QtGui, QtCore19from PyQt4 import QtGui, QtCore
20from openlp.core.lib import translate20from openlp.core.lib import translate
21from openlp.plugins.songs.forms.authorsdialog import Ui_AuthorsDialog21from openlp.plugins.songs.forms.authorsdialog import Ui_AuthorsDialog
22from openlp.plugins.songs.lib import TextListData22from openlp.plugins.songs.lib.classes import Author
2323
24class AuthorsForm(QtGui.QDialog, Ui_AuthorsDialog):24class AuthorsForm(QtGui.QDialog, Ui_AuthorsDialog):
25 """25 """
@@ -43,27 +43,24 @@
43 QtCore.SIGNAL(u'pressed()'), self.onAddUpdateButtonClick)43 QtCore.SIGNAL(u'pressed()'), self.onAddUpdateButtonClick)
44 QtCore.QObject.connect(self.DisplayEdit,44 QtCore.QObject.connect(self.DisplayEdit,
45 QtCore.SIGNAL(u'lostFocus()'), self.onDisplayEditLostFocus)45 QtCore.SIGNAL(u'lostFocus()'), self.onDisplayEditLostFocus)
46 QtCore.QObject.connect(self.AuthorListView,46 QtCore.QObject.connect(self.AuthorListWidget,
47 QtCore.SIGNAL(u'clicked(QModelIndex)'), self.onAuthorListViewItemClicked)47 QtCore.SIGNAL(u'clicked(QModelIndex)'), self.onAuthorListWidgetItemClicked)
4848
49 def load_form(self):49 def load_form(self):
50 """50 """
51 Refresh the screen and rest fields51 Refresh the screen and rest fields
52 """52 """
53 self.AuthorListData.resetStore()53 self.AuthorListWidget.clear()
54 self.onClearButtonClick() # tidy up screen54 self.onClearButtonClick() # tidy up screen
55 authors = self.songmanager.get_authors()55 authors = self.songmanager.get_authors()
56 for author in authors:56 for author in authors:
57 self.AuthorListData.addRow(author.id,author.display_name)57 author_name = QtGui.QListWidgetItem(author.display_name)
58 #rowCount is number of rows BUT test should be Zero based58 author_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(author.id))
59 row_count = self.AuthorListData.rowCount(None) - 159 self.AuthorListWidget.addItem(author_name)
60 if self.currentRow > row_count:60 if self.currentRow >= self.AuthorListWidget.count() :
61 # in case we have delete the last row of the table61 self.AuthorListWidget.setCurrentRow(self.AuthorListWidget.count() - 1)
62 self.currentRow = row_count62 else:
63 row = self.AuthorListData.createIndex(self.currentRow, 0)63 self.AuthorListWidget.setCurrentRow(self.currentRow)
64 if row.isValid():
65 self.AuthorListView.selectionModel().setCurrentIndex(row,
66 QtGui.QItemSelectionModel.SelectCurrent)
67 self._validate_form()64 self._validate_form()
6865
69 def onDeleteButtonClick(self):66 def onDeleteButtonClick(self):
@@ -101,15 +98,15 @@
101 self.author = None98 self.author = None
102 self._validate_form()99 self._validate_form()
103100
104 def onAuthorListViewItemClicked(self, index):101 def onAuthorListWidgetItemClicked(self, index):
105 """102 """
106 An Author has been selected display it103 An Author has been selected display it
107 If the author is attached to a Song prevent delete104 If the author is attached to a Song prevent delete
108 """105 """
109 self.currentRow = index.row()106 self.currentRow = self.AuthorListWidget.currentRow()
110 id = int(self.AuthorListData.getId(index))107 item = self.AuthorListWidget.currentItem()
111 self.author = self.songmanager.get_author(id)108 item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
112109 self.author = self.songmanager.get_author(item_id)
113 self.DisplayEdit.setText(self.author.display_name)110 self.DisplayEdit.setText(self.author.display_name)
114 self.FirstNameEdit.setText(self.author.first_name)111 self.FirstNameEdit.setText(self.author.first_name)
115 self.LastNameEdit.setText(self.author.last_name)112 self.LastNameEdit.setText(self.author.last_name)
116113
=== modified file 'openlp/plugins/songs/forms/editsongdialog.py'
--- openlp/plugins/songs/forms/editsongdialog.py 2009-06-14 06:30:09 +0000
+++ openlp/plugins/songs/forms/editsongdialog.py 2009-06-14 13:50:56 +0000
@@ -1,4 +1,22 @@
11# -*- coding: utf-8 -*-
2# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
3"""
4OpenLP - Open Source Lyrics Projection
5Copyright (c) 2008 Raoul Snyman
6Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley,
7
8This program is free software; you can redistribute it and/or modify it under
9the terms of the GNU General Public License as published by the Free Software
10Foundation; version 2 of the License.
11
12This program is distributed in the hope that it will be useful, but WITHOUT ANY
13WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
14PARTICULAR PURPOSE. See the GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License along with
17this program; if not, write to the Free Software Foundation, Inc., 59 Temple
18Place, Suite 330, Boston, MA 02111-1307 USA
19"""
2from openlp.core.lib import translate20from openlp.core.lib import translate
3from PyQt4 import QtCore, QtGui21from PyQt4 import QtCore, QtGui
422
523
=== modified file 'openlp/plugins/songs/forms/editsongform.py'
--- openlp/plugins/songs/forms/editsongform.py 2009-06-14 07:25:39 +0000
+++ openlp/plugins/songs/forms/editsongform.py 2009-06-14 13:50:56 +0000
@@ -99,20 +99,26 @@
99 authors = self.songmanager.get_authors()99 authors = self.songmanager.get_authors()
100 self.AuthorsSelectionComboItem.clear()100 self.AuthorsSelectionComboItem.clear()
101 for author in authors:101 for author in authors:
102 row = self.AuthorsSelectionComboItem.count()
102 self.AuthorsSelectionComboItem.addItem(author.display_name)103 self.AuthorsSelectionComboItem.addItem(author.display_name)
104 self.AuthorsSelectionComboItem.setItemData(row, QtCore.QVariant(author.id))
103105
104 def loadTopics(self):106 def loadTopics(self):
105 topics = self.songmanager.get_topics()107 topics = self.songmanager.get_topics()
106 self.SongTopicCombo.clear()108 self.SongTopicCombo.clear()
107 for topic in topics:109 for topic in topics:
110 row = self.SongTopicCombo.count()
108 self.SongTopicCombo.addItem(topic.name)111 self.SongTopicCombo.addItem(topic.name)
112 self.SongTopicCombo.setItemData(row, QtCore.QVariant(topic.id))
109113
110 def loadBooks(self):114 def loadBooks(self):
111 books = self.songmanager.get_books()115 books = self.songmanager.get_books()
112 self.SongbookCombo.clear()116 self.SongbookCombo.clear()
113 self.SongbookCombo.addItem(u' ')117 self.SongbookCombo.addItem(u' ')
114 for book in books:118 for book in books:
119 row = self.SongbookCombo.count()
115 self.SongbookCombo.addItem(book.name)120 self.SongbookCombo.addItem(book.name)
121 self.SongbookCombo.setItemData(row, QtCore.QVariant(book.id))
116122
117 def loadThemes(self, theme_list):123 def loadThemes(self, theme_list):
118 self.ThemeSelectionComboItem.clear()124 self.ThemeSelectionComboItem.clear()
@@ -180,8 +186,9 @@
180 self.title_change = False186 self.title_change = False
181187
182 def onAuthorAddtoSongItemClicked(self):188 def onAuthorAddtoSongItemClicked(self):
183 author_name = unicode(self.AuthorsSelectionComboItem.currentText())189 item = int(self.AuthorsSelectionComboItem.currentIndex())
184 author = self.songmanager.get_author_by_name(author_name)190 item_id = (self.AuthorsSelectionComboItem.itemData(item)).toInt()[0]
191 author = self.songmanager.get_author(item_id)
185 self.song.authors.append(author)192 self.song.authors.append(author)
186 author_item = QtGui.QListWidgetItem(unicode(author.display_name))193 author_item = QtGui.QListWidgetItem(unicode(author.display_name))
187 author_item.setData(QtCore.Qt.UserRole, QtCore.QVariant(author.id))194 author_item.setData(QtCore.Qt.UserRole, QtCore.QVariant(author.id))
@@ -201,8 +208,9 @@
201 self.AuthorsListView.takeItem(row)208 self.AuthorsListView.takeItem(row)
202209
203 def onTopicAddtoSongItemClicked(self):210 def onTopicAddtoSongItemClicked(self):
204 topic_name = unicode(self.SongTopicCombo.currentText())211 item = int(self.SongTopicCombo.currentIndex())
205 topic = self.songmanager.get_topic_by_name(topic_name)212 item_id = (self.SongTopicCombo.itemData(item)).toInt()[0]
213 topic = self.songmanager.get_topic(item_id)
206 self.song.topics.append(topic)214 self.song.topics.append(topic)
207 topic_item = QtGui.QListWidgetItem(unicode(topic.name))215 topic_item = QtGui.QListWidgetItem(unicode(topic.name))
208 topic_item.setData(QtCore.Qt.UserRole, QtCore.QVariant(topic.id))216 topic_item.setData(QtCore.Qt.UserRole, QtCore.QVariant(topic.id))
@@ -248,9 +256,8 @@
248 if item == 0:256 if item == 0:
249 self.song.song_book_id = 0257 self.song.song_book_id = 0
250 else:258 else:
251 book_name = unicode(self.SongbookCombo.itemText(item))259 item = int(self.SongbookCombo.currentIndex())
252 book = self.songmanager.get_book_by_name(book_name)260 self.song.song_book_id = (self.SongbookCombo.itemData(item)).toInt()[0]
253 self.song.song_book_id = book.id
254261
255 def onThemeComboChanged(self, item):262 def onThemeComboChanged(self, item):
256 if item == 0:263 if item == 0:
@@ -293,23 +300,26 @@
293 valid = True300 valid = True
294 if len(self.TitleEditItem.displayText()) == 0:301 if len(self.TitleEditItem.displayText()) == 0:
295 valid = False302 valid = False
303 self.TitleEditItem.setStyleSheet(u'background-color: red; color: white')
304 else:
305 self.TitleEditItem.setStyleSheet(u'')
296 if len(self.CopyrightEditItem.displayText()) == 0:306 if len(self.CopyrightEditItem.displayText()) == 0:
297 valid = False307 valid = False
308 self.CopyrightEditItem.setStyleSheet(u'background-color: red; color: white')
309 else:
310 self.CopyrightEditItem.setStyleSheet(u'')
298 if self.VerseListWidget.count() == 0:311 if self.VerseListWidget.count() == 0:
299 valid = False312 valid = False
313 self.VerseListWidget.setStyleSheet(u'background-color: red; color: white')
314 else:
315 self.VerseListWidget.setStyleSheet(u'')
300 if self.AuthorsListView.count() == 0:316 if self.AuthorsListView.count() == 0:
301 valid = False317 valid = False
318 self.AuthorsListView.setStyleSheet(u'background-color: red; color: white')
319 else:
320 self.AuthorsListView.setStyleSheet(u'')
302 return valid321 return valid
303322
304 def _color_widget(self, slot, invalid):
305 r = Qt.QPalette(slot.palette())
306 if invalid == True:
307 r.setColor(Qt.QPalette.Base, Qt.QColor(u'darkRed'))
308 else:
309 r.setColor(Qt.QPalette.Base, Qt.QColor(u'white'))
310 slot.setPalette(r)
311 slot.setAutoFillBackground(True)
312
313 def on_TitleEditItem_lostFocus(self):323 def on_TitleEditItem_lostFocus(self):
314 self.song.title = self.TitleEditItem.text()324 self.song.title = self.TitleEditItem.text()
315 self.title_change = True325 self.title_change = True
316326
=== modified file 'openlp/plugins/songs/forms/songbookdialog.py'
--- openlp/plugins/songs/forms/songbookdialog.py 2009-06-04 20:06:32 +0000
+++ openlp/plugins/songs/forms/songbookdialog.py 2009-06-14 15:12:40 +0000
@@ -1,60 +1,66 @@
1# -*- coding: utf-8 -*-1# -*- coding: utf-8 -*-
22# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
3# Form implementation generated from reading ui file 'songbookdialog.ui'3"""
4#4OpenLP - Open Source Lyrics Projection
5# Created: Sun Jan 4 08:43:12 20095Copyright (c) 2008 Raoul Snyman
6# by: PyQt4 UI code generator 4.4.36Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley,
7#7
8# WARNING! All changes made in this file will be lost!8This program is free software; you can redistribute it and/or modify it under
99the terms of the GNU General Public License as published by the Free Software
10Foundation; version 2 of the License.
11
12This program is distributed in the hope that it will be useful, but WITHOUT ANY
13WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
14PARTICULAR PURPOSE. See the GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License along with
17this program; if not, write to the Free Software Foundation, Inc., 59 Temple
18Place, Suite 330, Boston, MA 02111-1307 USA
19"""
10from PyQt4 import QtCore, QtGui20from PyQt4 import QtCore, QtGui
11from openlp.plugins.songs.lib import TextListData21from openlp.core.lib import translate
1222
13class Ui_SongBookDialog(object):23class Ui_SongBookDialog(object):
14 def setupUi(self, SongBookDialog):24 def setupUi(self, SongBookDialog):
15 SongBookDialog.setObjectName("SongBookDialog")25 SongBookDialog.setObjectName(u'SongBookDialog')
16 SongBookDialog.resize(387, 531)26 SongBookDialog.resize(387, 531)
17 self.DialogLayout = QtGui.QVBoxLayout(SongBookDialog)27 self.DialogLayout = QtGui.QVBoxLayout(SongBookDialog)
18 self.DialogLayout.setSpacing(8)28 self.DialogLayout.setSpacing(8)
19 self.DialogLayout.setMargin(8)29 self.DialogLayout.setMargin(8)
20 self.DialogLayout.setObjectName("DialogLayout")30 self.DialogLayout.setObjectName(u'DialogLayout')
2131 self.BookSongListWidget = QtGui.QListWidget()
22 self.BookSongListView = QtGui.QListView()32 self.BookSongListWidget.setAlternatingRowColors(True)
23 self.BookSongListView.setAlternatingRowColors(True)33 self.DialogLayout.addWidget(self.BookSongListWidget)
24 self.BookSongListData = TextListData()34 self.DialogLayout.addWidget(self.BookSongListWidget)
25 self.BookSongListView.setModel(self.BookSongListData)
26 self.DialogLayout.addWidget(self.BookSongListView)
27
28 self.DialogLayout.addWidget(self.BookSongListView)
29 self.SongBookGroup = QtGui.QGroupBox(SongBookDialog)35 self.SongBookGroup = QtGui.QGroupBox(SongBookDialog)
30 self.SongBookGroup.setMinimumSize(QtCore.QSize(0, 200))36 self.SongBookGroup.setMinimumSize(QtCore.QSize(0, 200))
31 self.SongBookGroup.setObjectName("SongBookGroup")37 self.SongBookGroup.setObjectName(u'SongBookGroup')
32 self.SongBookLayout = QtGui.QVBoxLayout(self.SongBookGroup)38 self.SongBookLayout = QtGui.QVBoxLayout(self.SongBookGroup)
33 self.SongBookLayout.setSpacing(8)39 self.SongBookLayout.setSpacing(8)
34 self.SongBookLayout.setMargin(8)40 self.SongBookLayout.setMargin(8)
35 self.SongBookLayout.setObjectName("SongBookLayout")41 self.SongBookLayout.setObjectName(u'SongBookLayout')
36 self.DetailsWidget = QtGui.QWidget(self.SongBookGroup)42 self.DetailsWidget = QtGui.QWidget(self.SongBookGroup)
37 self.DetailsWidget.setMinimumSize(QtCore.QSize(0, 0))43 self.DetailsWidget.setMinimumSize(QtCore.QSize(0, 0))
38 self.DetailsWidget.setObjectName("DetailsWidget")44 self.DetailsWidget.setObjectName(u'DetailsWidget')
39 self.DetailsLayout = QtGui.QFormLayout(self.DetailsWidget)45 self.DetailsLayout = QtGui.QFormLayout(self.DetailsWidget)
40 self.DetailsLayout.setMargin(0)46 self.DetailsLayout.setMargin(0)
41 self.DetailsLayout.setSpacing(8)47 self.DetailsLayout.setSpacing(8)
42 self.DetailsLayout.setObjectName("DetailsLayout")48 self.DetailsLayout.setObjectName(u'DetailsLayout')
43 self.NameLabel = QtGui.QLabel(self.DetailsWidget)49 self.NameLabel = QtGui.QLabel(self.DetailsWidget)
44 self.NameLabel.setObjectName("NameLabel")50 self.NameLabel.setObjectName(u'NameLabel')
45 self.DetailsLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.NameLabel)51 self.DetailsLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.NameLabel)
46 self.NameEdit = QtGui.QLineEdit(self.DetailsWidget)52 self.NameEdit = QtGui.QLineEdit(self.DetailsWidget)
47 self.NameEdit.setObjectName("NameEdit")53 self.NameEdit.setObjectName(u'NameEdit')
48 self.DetailsLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.NameEdit)54 self.DetailsLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.NameEdit)
49 self.PublisherLabel = QtGui.QLabel(self.DetailsWidget)55 self.PublisherLabel = QtGui.QLabel(self.DetailsWidget)
50 self.PublisherLabel.setObjectName("PublisherLabel")56 self.PublisherLabel.setObjectName(u'PublisherLabel')
51 self.DetailsLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.PublisherLabel)57 self.DetailsLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.PublisherLabel)
52 self.PublisherEdit = QtGui.QLineEdit(self.DetailsWidget)58 self.PublisherEdit = QtGui.QLineEdit(self.DetailsWidget)
53 self.PublisherEdit.setObjectName("PublisherEdit")59 self.PublisherEdit.setObjectName(u'PublisherEdit')
54 self.DetailsLayout.setWidget(1, QtGui.QFormLayout.FieldRole, self.PublisherEdit)60 self.DetailsLayout.setWidget(1, QtGui.QFormLayout.FieldRole, self.PublisherEdit)
55 self.SongBookLayout.addWidget(self.DetailsWidget)61 self.SongBookLayout.addWidget(self.DetailsWidget)
56 self.MessageLabel = QtGui.QLabel(self.SongBookGroup)62 self.MessageLabel = QtGui.QLabel(self.SongBookGroup)
57 self.MessageLabel.setObjectName("MessageLabel")63 self.MessageLabel.setObjectName(u'MessageLabel')
58 self.SongBookLayout.addWidget(self.MessageLabel)64 self.SongBookLayout.addWidget(self.MessageLabel)
59 self.ButtonWidget = QtGui.QWidget(self.SongBookGroup)65 self.ButtonWidget = QtGui.QWidget(self.SongBookGroup)
60 sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred)66 sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred)
@@ -63,52 +69,51 @@
63 sizePolicy.setHeightForWidth(self.ButtonWidget.sizePolicy().hasHeightForWidth())69 sizePolicy.setHeightForWidth(self.ButtonWidget.sizePolicy().hasHeightForWidth())
64 self.ButtonWidget.setSizePolicy(sizePolicy)70 self.ButtonWidget.setSizePolicy(sizePolicy)
65 self.ButtonWidget.setMinimumSize(QtCore.QSize(0, 0))71 self.ButtonWidget.setMinimumSize(QtCore.QSize(0, 0))
66 self.ButtonWidget.setObjectName("ButtonWidget")72 self.ButtonWidget.setObjectName(u'ButtonWidget')
67 self.ButtonLayout = QtGui.QHBoxLayout(self.ButtonWidget)73 self.ButtonLayout = QtGui.QHBoxLayout(self.ButtonWidget)
68 self.ButtonLayout.setSpacing(8)74 self.ButtonLayout.setSpacing(8)
69 self.ButtonLayout.setMargin(0)75 self.ButtonLayout.setMargin(0)
70 self.ButtonLayout.setObjectName("ButtonLayout")76 self.ButtonLayout.setObjectName(u'ButtonLayout')
71 spacerItem = QtGui.QSpacerItem(61, 24, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)77 spacerItem = QtGui.QSpacerItem(61, 24, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
72 self.ButtonLayout.addItem(spacerItem)78 self.ButtonLayout.addItem(spacerItem)
73 self.ClearButton = QtGui.QPushButton(self.ButtonWidget)79 self.ClearButton = QtGui.QPushButton(self.ButtonWidget)
74 icon = QtGui.QIcon()80 icon = QtGui.QIcon()
75 icon.addPixmap(QtGui.QPixmap(":/services/service_new.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)81 icon.addPixmap(QtGui.QPixmap(u':/services/service_new.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off)
76 self.ClearButton.setIcon(icon)82 self.ClearButton.setIcon(icon)
77 self.ClearButton.setObjectName("ClearButton")83 self.ClearButton.setObjectName(u'ClearButton')
78 self.ButtonLayout.addWidget(self.ClearButton)84 self.ButtonLayout.addWidget(self.ClearButton)
79 self.AddUpdateButton = QtGui.QPushButton(self.ButtonWidget)85 self.AddUpdateButton = QtGui.QPushButton(self.ButtonWidget)
80 icon1 = QtGui.QIcon()86 icon1 = QtGui.QIcon()
81 icon1.addPixmap(QtGui.QPixmap(":/services/service_save.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)87 icon1.addPixmap(QtGui.QPixmap(u':/services/service_save.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off)
82 self.AddUpdateButton.setIcon(icon1)88 self.AddUpdateButton.setIcon(icon1)
83 self.AddUpdateButton.setObjectName("AddUpdateButton")89 self.AddUpdateButton.setObjectName(u'AddUpdateButton')
84 self.ButtonLayout.addWidget(self.AddUpdateButton)90 self.ButtonLayout.addWidget(self.AddUpdateButton)
85 self.DeleteButton = QtGui.QPushButton(self.ButtonWidget)91 self.DeleteButton = QtGui.QPushButton(self.ButtonWidget)
86 icon2 = QtGui.QIcon()92 icon2 = QtGui.QIcon()
87 icon2.addPixmap(QtGui.QPixmap(":/services/service_delete.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)93 icon2.addPixmap(QtGui.QPixmap(u':/services/service_delete.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off)
88 self.DeleteButton.setIcon(icon2)94 self.DeleteButton.setIcon(icon2)
89 self.DeleteButton.setObjectName("DeleteButton")95 self.DeleteButton.setObjectName(u'DeleteButton')
90 self.ButtonLayout.addWidget(self.DeleteButton)96 self.ButtonLayout.addWidget(self.DeleteButton)
91 self.SongBookLayout.addWidget(self.ButtonWidget)97 self.SongBookLayout.addWidget(self.ButtonWidget)
92 self.DialogLayout.addWidget(self.SongBookGroup)98 self.DialogLayout.addWidget(self.SongBookGroup)
93 self.ButtonBox = QtGui.QDialogButtonBox(SongBookDialog)99 self.ButtonBox = QtGui.QDialogButtonBox(SongBookDialog)
94 self.ButtonBox.setOrientation(QtCore.Qt.Horizontal)100 self.ButtonBox.setOrientation(QtCore.Qt.Horizontal)
95 self.ButtonBox.setStandardButtons(QtGui.QDialogButtonBox.Ok)101 self.ButtonBox.setStandardButtons(QtGui.QDialogButtonBox.Ok)
96 self.ButtonBox.setObjectName("ButtonBox")102 self.ButtonBox.setObjectName(u'ButtonBox')
97 self.DialogLayout.addWidget(self.ButtonBox)103 self.DialogLayout.addWidget(self.ButtonBox)
98
99 self.retranslateUi(SongBookDialog)104 self.retranslateUi(SongBookDialog)
100 QtCore.QObject.connect(self.ButtonBox, QtCore.SIGNAL("accepted()"), SongBookDialog.accept)105 QtCore.QObject.connect(self.ButtonBox, QtCore.SIGNAL(u'accepted()'), SongBookDialog.accept)
101 QtCore.QObject.connect(self.ButtonBox, QtCore.SIGNAL("rejected()"), SongBookDialog.reject)106 QtCore.QObject.connect(self.ButtonBox, QtCore.SIGNAL(u'rejected()'), SongBookDialog.reject)
102 QtCore.QMetaObject.connectSlotsByName(SongBookDialog)107 QtCore.QMetaObject.connectSlotsByName(SongBookDialog)
103108
104 def retranslateUi(self, SongBookDialog):109 def retranslateUi(self, SongBookDialog):
105 SongBookDialog.setWindowTitle(QtGui.QApplication.translate("SongBookDialog", "Book Song Maintenance", None, QtGui.QApplication.UnicodeUTF8))110 SongBookDialog.setWindowTitle(translate(u'SongBookDialog', u'Book Song Maintenance'))
106 self.SongBookGroup.setTitle(QtGui.QApplication.translate("SongBookDialog", "Song Book", None, QtGui.QApplication.UnicodeUTF8))111 self.SongBookGroup.setTitle(translate(u'SongBookDialog', u'Song Book'))
107 self.NameLabel.setText(QtGui.QApplication.translate("SongBookDialog", "Name:", None, QtGui.QApplication.UnicodeUTF8))112 self.NameLabel.setText(translate(u'SongBookDialog', u'Name:'))
108 self.PublisherLabel.setText(QtGui.QApplication.translate("SongBookDialog", "Publisher:", None, QtGui.QApplication.UnicodeUTF8))113 self.PublisherLabel.setText(translate(u'SongBookDialog', u'Publisher:'))
109 self.ClearButton.setToolTip(QtGui.QApplication.translate("SongBookDialog", "Clear Selection", None, QtGui.QApplication.UnicodeUTF8))114 self.ClearButton.setToolTip(translate(u'SongBookDialog', u'Clear Selection'))
110 self.ClearButton.setText(QtGui.QApplication.translate("SongBookDialog", "New", None, QtGui.QApplication.UnicodeUTF8))115 self.ClearButton.setText(translate(u'SongBookDialog', u'Clear'))
111 self.AddUpdateButton.setToolTip(QtGui.QApplication.translate("SongBookDialog", "Add Update Author", None, QtGui.QApplication.UnicodeUTF8))116 self.AddUpdateButton.setToolTip(translate(u'SongBookDialog', u'Add Update Author'))
112 self.AddUpdateButton.setText(QtGui.QApplication.translate("SongBookDialog", "Save", None, QtGui.QApplication.UnicodeUTF8))117 self.AddUpdateButton.setText(translate(u'SongBookDialog', u'Save'))
113 self.DeleteButton.setToolTip(QtGui.QApplication.translate("SongBookDialog", "Delete Author", None, QtGui.QApplication.UnicodeUTF8))118 self.DeleteButton.setToolTip(translate(u'SongBookDialog', u'Delete Author'))
114 self.DeleteButton.setText(QtGui.QApplication.translate("SongBookDialog", "Delete", None, QtGui.QApplication.UnicodeUTF8))119 self.DeleteButton.setText(translate(u'SongBookDialog', u'Delete'))
115120
=== modified file 'openlp/plugins/songs/forms/songbookform.py'
--- openlp/plugins/songs/forms/songbookform.py 2009-06-10 17:12:03 +0000
+++ openlp/plugins/songs/forms/songbookform.py 2009-06-14 15:12:40 +0000
@@ -44,28 +44,24 @@
44 QtCore.SIGNAL(u'pressed()'), self.onAddUpdateButtonClick)44 QtCore.SIGNAL(u'pressed()'), self.onAddUpdateButtonClick)
45 QtCore.QObject.connect(self.NameEdit,45 QtCore.QObject.connect(self.NameEdit,
46 QtCore.SIGNAL(u'lostFocus()'), self.onBookNameEditLostFocus)46 QtCore.SIGNAL(u'lostFocus()'), self.onBookNameEditLostFocus)
47 QtCore.QObject.connect(self.BookSongListView,47 QtCore.QObject.connect(self.BookSongListWidget,
48 QtCore.SIGNAL(u'clicked(QModelIndex)'), self.onBooksListViewItemClicked)48 QtCore.SIGNAL(u'clicked(QModelIndex)'), self.onBooksListViewItemClicked)
4949
50 def load_form(self):50 def load_form(self):
51 """51 """
52 Refresh the screen and rest fields52 Refresh the screen and rest fields
53 """53 """
54 self.BookSongListData.resetStore()54 self.BookSongListWidget.clear()
55 self.onClearButtonClick() # tidy up screen55 self.onClearButtonClick() # tidy up screen
56 Books = self.songmanager.get_books()56 books = self.songmanager.get_books()
57 for Book in Books:57 for book in books:
58 self.BookSongListData.addRow(Book.id,Book.name)58 book_name = QtGui.QListWidgetItem(book.name)
59 #rowCount is number of rows BUT test should be Zero based59 book_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(book.id))
60 row_count = self.BookSongListData.rowCount(None) - 160 self.BookSongListWidget.addItem(book_name)
61 if self.currentRow > row_count:61 if self.currentRow >= self.BookSongListWidget.count() :
62 # in case we have delete the last row of the table62 self.BookSongListWidget.setCurrentRow(self.BookSongListWidget.count() - 1)
63 self.currentRow = row_count63 else:
64 row = self.BookSongListData.createIndex(self.currentRow, 0)64 self.BookSongListWidget.setCurrentRow(self.currentRow)
65 if row.isValid():
66 self.BookSongListView.selectionModel().setCurrentIndex(row,
67 QtGui.QItemSelectionModel.SelectCurrent)
68 self._validate_form()
6965
70 def onDeleteButtonClick(self):66 def onDeleteButtonClick(self):
71 """67 """
@@ -106,10 +102,10 @@
106 An Book has been selected display it102 An Book has been selected display it
107 If the Book is attached to a Song prevent delete103 If the Book is attached to a Song prevent delete
108 """104 """
109 self.currentRow = index.row()105 self.currentRow = self.BookSongListWidget.currentRow()
110 id = int(self.BookSongListData.getId(index))106 item = self.BookSongListWidget.currentItem()
111 self.Book = self.songmanager.get_book(id)107 item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
112108 self.Book = self.songmanager.get_book(item_id)
113 self.NameEdit.setText(self.Book.name)109 self.NameEdit.setText(self.Book.name)
114 self.PublisherEdit.setText(self.Book.publisher)110 self.PublisherEdit.setText(self.Book.publisher)
115 if len(self.Book.songs) > 0:111 if len(self.Book.songs) > 0:
116112
=== modified file 'openlp/plugins/songs/forms/topicsdialog.py'
--- openlp/plugins/songs/forms/topicsdialog.py 2009-06-04 19:00:41 +0000
+++ openlp/plugins/songs/forms/topicsdialog.py 2009-06-14 15:12:40 +0000
@@ -1,82 +1,88 @@
1# -*- coding: utf-8 -*-1# -*- coding: utf-8 -*-
22# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
3# Form implementation generated from reading ui file 'topicsdialog.ui'3"""
4#4OpenLP - Open Source Lyrics Projection
5# Created: Sun Jan 4 08:42:59 20095Copyright (c) 2008 Raoul Snyman
6# by: PyQt4 UI code generator 4.4.36Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley,
7#7
8# WARNING! All changes made in this file will be lost!8This program is free software; you can redistribute it and/or modify it under
99the terms of the GNU General Public License as published by the Free Software
10Foundation; version 2 of the License.
11
12This program is distributed in the hope that it will be useful, but WITHOUT ANY
13WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
14PARTICULAR PURPOSE. See the GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License along with
17this program; if not, write to the Free Software Foundation, Inc., 59 Temple
18Place, Suite 330, Boston, MA 02111-1307 USA
19"""
10from PyQt4 import QtCore, QtGui20from PyQt4 import QtCore, QtGui
11from openlp.plugins.songs.lib import TextListData21from openlp.core.lib import translate
1222
13class Ui_TopicsDialog(object):23class Ui_TopicsDialog(object):
14 def setupUi(self, TopicsDialog):24 def setupUi(self, TopicsDialog):
15 TopicsDialog.setObjectName("TopicsDialog")25 TopicsDialog.setObjectName(u'TopicsDialog')
16 TopicsDialog.resize(387, 463)26 TopicsDialog.resize(387, 463)
17 self.gridLayout_2 = QtGui.QGridLayout(TopicsDialog)27 self.gridLayout_2 = QtGui.QGridLayout(TopicsDialog)
18 self.gridLayout_2.setObjectName("gridLayout_2")28 self.gridLayout_2.setObjectName(u'gridLayout_2')
19 self.TopicGroupBox = QtGui.QGroupBox(TopicsDialog)29 self.TopicGroupBox = QtGui.QGroupBox(TopicsDialog)
20 self.TopicGroupBox.setObjectName("TopicGroupBox")30 self.TopicGroupBox.setObjectName(u'TopicGroupBox')
21 self.gridLayout = QtGui.QGridLayout(self.TopicGroupBox)31 self.gridLayout = QtGui.QGridLayout(self.TopicGroupBox)
22 self.gridLayout.setObjectName("gridLayout")32 self.gridLayout.setObjectName(u'gridLayout')
23 self.TopicNameLabel = QtGui.QLabel(self.TopicGroupBox)33 self.TopicNameLabel = QtGui.QLabel(self.TopicGroupBox)
24 self.TopicNameLabel.setObjectName("TopicNameLabel")34 self.TopicNameLabel.setObjectName(u'TopicNameLabel')
25 self.gridLayout.addWidget(self.TopicNameLabel, 0, 0, 1, 1)35 self.gridLayout.addWidget(self.TopicNameLabel, 0, 0, 1, 1)
26 self.TopicNameEdit = QtGui.QLineEdit(self.TopicGroupBox)36 self.TopicNameEdit = QtGui.QLineEdit(self.TopicGroupBox)
27 self.TopicNameEdit.setObjectName("TopicNameEdit")37 self.TopicNameEdit.setObjectName(u'TopicNameEdit')
28 self.gridLayout.addWidget(self.TopicNameEdit, 0, 1, 1, 4)38 self.gridLayout.addWidget(self.TopicNameEdit, 0, 1, 1, 4)
29 spacerItem = QtGui.QSpacerItem(198, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)39 spacerItem = QtGui.QSpacerItem(198, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
30 self.gridLayout.addItem(spacerItem, 1, 0, 1, 2)40 self.gridLayout.addItem(spacerItem, 1, 0, 1, 2)
31 self.DeleteButton = QtGui.QPushButton(self.TopicGroupBox)41 self.DeleteButton = QtGui.QPushButton(self.TopicGroupBox)
32 icon = QtGui.QIcon()42 icon = QtGui.QIcon()
33 icon.addPixmap(QtGui.QPixmap(":/services/service_delete.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)43 icon.addPixmap(QtGui.QPixmap(u':/services/service_delete.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off)
34 self.DeleteButton.setIcon(icon)44 self.DeleteButton.setIcon(icon)
35 self.DeleteButton.setObjectName("DeleteButton")45 self.DeleteButton.setObjectName(u'DeleteButton')
36 self.gridLayout.addWidget(self.DeleteButton, 1, 3, 1, 1)46 self.gridLayout.addWidget(self.DeleteButton, 1, 3, 1, 1)
37 self.AddUpdateButton = QtGui.QPushButton(self.TopicGroupBox)47 self.AddUpdateButton = QtGui.QPushButton(self.TopicGroupBox)
38 icon1 = QtGui.QIcon()48 icon1 = QtGui.QIcon()
39 icon1.addPixmap(QtGui.QPixmap(":/services/service_save.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)49 icon1.addPixmap(QtGui.QPixmap(u':/services/service_save.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off)
40 self.AddUpdateButton.setIcon(icon1)50 self.AddUpdateButton.setIcon(icon1)
41 self.AddUpdateButton.setObjectName("AddUpdateButton")51 self.AddUpdateButton.setObjectName(u'AddUpdateButton')
42 self.gridLayout.addWidget(self.AddUpdateButton, 1, 4, 1, 1)52 self.gridLayout.addWidget(self.AddUpdateButton, 1, 4, 1, 1)
43 self.ClearButton = QtGui.QPushButton(self.TopicGroupBox)53 self.ClearButton = QtGui.QPushButton(self.TopicGroupBox)
44 icon2 = QtGui.QIcon()54 icon2 = QtGui.QIcon()
45 icon2.addPixmap(QtGui.QPixmap(":/services/service_new.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)55 icon2.addPixmap(QtGui.QPixmap(u':/services/service_new.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off)
46 self.ClearButton.setIcon(icon2)56 self.ClearButton.setIcon(icon2)
47 self.ClearButton.setObjectName("ClearButton")57 self.ClearButton.setObjectName(u'ClearButton')
48 self.gridLayout.addWidget(self.ClearButton, 1, 2, 1, 1)58 self.gridLayout.addWidget(self.ClearButton, 1, 2, 1, 1)
49 self.gridLayout_2.addWidget(self.TopicGroupBox, 1, 0, 1, 1)59 self.gridLayout_2.addWidget(self.TopicGroupBox, 1, 0, 1, 1)
50 self.MessageLabel = QtGui.QLabel(TopicsDialog)60 self.MessageLabel = QtGui.QLabel(TopicsDialog)
51 self.MessageLabel.setObjectName("MessageLabel")61 self.MessageLabel.setObjectName(u'MessageLabel')
52 self.gridLayout_2.addWidget(self.MessageLabel, 3, 0, 1, 1)62 self.gridLayout_2.addWidget(self.MessageLabel, 3, 0, 1, 1)
5363 self.TopicsListWidget = QtGui.QListWidget()
54 self.TopicsListView = QtGui.QListView()64 self.TopicsListWidget.setAlternatingRowColors(True)
55 self.TopicsListView.setAlternatingRowColors(True)65 self.gridLayout_2.addWidget(self.TopicsListWidget, 0, 0, 1, 1)
56 self.TopicsListData = TextListData()
57 self.TopicsListView.setModel(self.TopicsListData)
58 self.gridLayout_2.addWidget(self.TopicsListView, 0, 0, 1, 1)
59
60 self.ButtonBox = QtGui.QDialogButtonBox(TopicsDialog)66 self.ButtonBox = QtGui.QDialogButtonBox(TopicsDialog)
61 self.ButtonBox.setOrientation(QtCore.Qt.Horizontal)67 self.ButtonBox.setOrientation(QtCore.Qt.Horizontal)
62 self.ButtonBox.setStandardButtons(QtGui.QDialogButtonBox.Ok)68 self.ButtonBox.setStandardButtons(QtGui.QDialogButtonBox.Ok)
63 self.ButtonBox.setObjectName("ButtonBox")69 self.ButtonBox.setObjectName(u'ButtonBox')
64 self.gridLayout_2.addWidget(self.ButtonBox, 2, 0, 1, 1)70 self.gridLayout_2.addWidget(self.ButtonBox, 2, 0, 1, 1)
6571
66 self.retranslateUi(TopicsDialog)72 self.retranslateUi(TopicsDialog)
67 QtCore.QObject.connect(self.ButtonBox, QtCore.SIGNAL("accepted()"), TopicsDialog.accept)73 QtCore.QObject.connect(self.ButtonBox, QtCore.SIGNAL(u'accepted()'), TopicsDialog.accept)
68 QtCore.QObject.connect(self.ButtonBox, QtCore.SIGNAL("rejected()"), TopicsDialog.reject)74 QtCore.QObject.connect(self.ButtonBox, QtCore.SIGNAL(u'rejected()'), TopicsDialog.reject)
69 QtCore.QMetaObject.connectSlotsByName(TopicsDialog)75 QtCore.QMetaObject.connectSlotsByName(TopicsDialog)
7076
71 def retranslateUi(self, TopicsDialog):77 def retranslateUi(self, TopicsDialog):
72 TopicsDialog.setWindowTitle(QtGui.QApplication.translate("TopicsDialog", "Topic Maintenance", None, QtGui.QApplication.UnicodeUTF8))78 TopicsDialog.setWindowTitle(translate(u'TopicsDialog', u'Topic Maintenance'))
73 self.TopicGroupBox.setTitle(QtGui.QApplication.translate("TopicsDialog", "Topic", None, QtGui.QApplication.UnicodeUTF8))79 self.TopicGroupBox.setTitle(translate(u'TopicsDialog', u'Topic'))
74 self.TopicNameLabel.setText(QtGui.QApplication.translate("TopicsDialog", "Topic Name:", None, QtGui.QApplication.UnicodeUTF8))80 self.TopicNameLabel.setText(translate(u'TopicsDialog', u'Topic Name:'))
7581
76 self.DeleteButton.setToolTip(QtGui.QApplication.translate("TopicsDialog", "Delete Author", None, QtGui.QApplication.UnicodeUTF8))82 self.DeleteButton.setToolTip(translate(u'TopicsDialog', u'Delete Author'))
77 self.DeleteButton.setText(QtGui.QApplication.translate("AuthorsDialog", "Delete", None, QtGui.QApplication.UnicodeUTF8))83 self.DeleteButton.setText(translate(u'AuthorsDialog', u'Delete'))
78 self.AddUpdateButton.setToolTip(QtGui.QApplication.translate("TopicsDialog", "Add Update Author", None, QtGui.QApplication.UnicodeUTF8))84 self.AddUpdateButton.setToolTip(translate(u'TopicsDialog', u'Add Update Author'))
79 self.AddUpdateButton.setText(QtGui.QApplication.translate("AuthorsDialog", "Save", None, QtGui.QApplication.UnicodeUTF8))85 self.AddUpdateButton.setText(translate(u'AuthorsDialog', u'Save'))
80 self.ClearButton.setToolTip(QtGui.QApplication.translate("TopicsDialog", "Clear Selection", None, QtGui.QApplication.UnicodeUTF8))86 self.ClearButton.setToolTip(translate(u'TopicsDialog', u'Clear Selection'))
81 self.ClearButton.setText(QtGui.QApplication.translate("TopicsDialog", "Clear", None, QtGui.QApplication.UnicodeUTF8))87 self.ClearButton.setText(translate(u'TopicsDialog', u'Clear'))
8288
8389
=== modified file 'openlp/plugins/songs/forms/topicsform.py'
--- openlp/plugins/songs/forms/topicsform.py 2009-06-10 17:12:03 +0000
+++ openlp/plugins/songs/forms/topicsform.py 2009-06-14 15:12:40 +0000
@@ -18,7 +18,6 @@
18"""18"""
19from PyQt4 import QtGui, QtCore19from PyQt4 import QtGui, QtCore
20from openlp.core.lib import translate20from openlp.core.lib import translate
21from openlp.plugins.songs.lib import TextListData
22from openlp.plugins.songs.forms.topicsdialog import Ui_TopicsDialog21from openlp.plugins.songs.forms.topicsdialog import Ui_TopicsDialog
23from openlp.plugins.songs.lib.classes import Topic22from openlp.plugins.songs.lib.classes import Topic
2423
@@ -44,27 +43,24 @@
44 QtCore.SIGNAL(u'pressed()'), self.onAddUpdateButtonClick)43 QtCore.SIGNAL(u'pressed()'), self.onAddUpdateButtonClick)
45 QtCore.QObject.connect(self.TopicNameEdit,44 QtCore.QObject.connect(self.TopicNameEdit,
46 QtCore.SIGNAL(u'lostFocus()'), self.onTopicNameEditLostFocus)45 QtCore.SIGNAL(u'lostFocus()'), self.onTopicNameEditLostFocus)
47 QtCore.QObject.connect(self.TopicsListView,46 QtCore.QObject.connect(self.TopicsListWidget,
48 QtCore.SIGNAL(u'clicked(QModelIndex)'), self.onTopicsListViewItemClicked)47 QtCore.SIGNAL(u'clicked(QModelIndex)'), self.onTopicsListWidgetItemClicked)
4948
50 def load_form(self):49 def load_form(self):
51 """50 """
52 Refresh the screen and rest fields51 Refresh the screen and rest fields
53 """52 """
54 self.TopicsListData.resetStore()53 self.TopicsListWidget.clear()
55 self.onClearButtonClick() # tidy up screen54 self.onClearButtonClick() # tidy up screen
56 topics = self.songmanager.get_topics()55 topics = self.songmanager.get_topics()
57 for topic in topics:56 for topic in topics:
58 self.TopicsListData.addRow(topic.id,topic.name)57 topic_name = QtGui.QListWidgetItem(topic.name)
59 #rowCount is number of rows BUT test should be Zero based58 topic_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(topic.id))
60 row_count = self.TopicsListData.rowCount(None) - 159 self.TopicsListWidget.addItem(topic_name)
61 if self.currentRow > row_count:60 if self.currentRow >= self.TopicsListWidget.count() :
62 # in case we have delete the last row of the table61 self.TopicsListWidget.setCurrentRow(self.TopicsListWidget.count() - 1)
63 self.currentRow = row_count62 else:
64 row = self.TopicsListData.createIndex(self.currentRow, 0)63 self.TopicsListWidget.setCurrentRow(self.currentRow)
65 if row.isValid():
66 self.TopicsListView.selectionModel().setCurrentIndex(row,
67 QtGui.QItemSelectionModel.SelectCurrent)
68 self._validate_form()64 self._validate_form()
6965
70 def onDeleteButtonClick(self):66 def onDeleteButtonClick(self):
@@ -99,15 +95,15 @@
99 self.topic = None95 self.topic = None
100 self._validate_form()96 self._validate_form()
10197
102 def onTopicsListViewItemClicked(self, index):98 def onTopicsListWidgetItemClicked(self, index):
103 """99 """
104 An Topic has been selected display it100 An Topic has been selected display it
105 If the Topic is attached to a Song prevent delete101 If the Topic is attached to a Song prevent delete
106 """102 """
107 self.currentRow = index.row()103 self.currentRow = self.TopicsListWidget.currentRow()
108 id = int(self.TopicsListData.getId(index))104 item = self.TopicsListWidget.currentItem()
109 self.topic = self.songmanager.get_topic(id)105 item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
110106 self.topic = self.songmanager.get_topic(item_id)
111 self.TopicNameEdit.setText(self.topic.name)107 self.TopicNameEdit.setText(self.topic.name)
112 if len(self.topic.songs) > 0:108 if len(self.topic.songs) > 0:
113 self.MessageLabel.setText(translate(u'TopicForm', u'Topic in use "Delete" is disabled'))109 self.MessageLabel.setText(translate(u'TopicForm', u'Topic in use "Delete" is disabled'))
114110
=== modified file 'openlp/plugins/songs/lib/__init__.py'
--- openlp/plugins/songs/lib/__init__.py 2009-06-03 15:38:14 +0000
+++ openlp/plugins/songs/lib/__init__.py 2009-06-14 15:12:40 +0000
@@ -17,7 +17,6 @@
17this program; if not, write to the Free Software Foundation, Inc., 59 Temple17this program; if not, write to the Free Software Foundation, Inc., 59 Temple
18Place, Suite 330, Boston, MA 02111-1307 USA18Place, Suite 330, Boston, MA 02111-1307 USA
19"""19"""
20from textlistdata import TextListData
21from manager import SongManager20from manager import SongManager
22from songstab import SongsTab21from songstab import SongsTab
23from mediaitem import SongMediaItem22from mediaitem import SongMediaItem
2423
=== modified file 'openlp/plugins/songs/lib/manager.py'
--- openlp/plugins/songs/lib/manager.py 2009-06-14 06:48:38 +0000
+++ openlp/plugins/songs/lib/manager.py 2009-06-14 13:50:56 +0000
@@ -127,12 +127,6 @@
127 """127 """
128 return self.session.query(Author).get(id)128 return self.session.query(Author).get(id)
129129
130 def get_author_by_name(self, name):
131 """
132 Details of the Author
133 """
134 return self.session.query(Author).filter_by(display_name = name).first()
135
136 def save_author(self, author):130 def save_author(self, author):
137 """131 """
138 Save the Author and refresh the cache132 Save the Author and refresh the cache
@@ -172,12 +166,6 @@
172 """166 """
173 return self.session.query(Topic).get(id)167 return self.session.query(Topic).get(id)
174168
175 def get_topic_by_name(self, name):
176 """
177 Details of the Topic
178 """
179 return self.session.query(Topic).filter_by(name = name).first()
180
181 def save_topic(self, topic):169 def save_topic(self, topic):
182 """170 """
183 Save the Topic171 Save the Topic
@@ -217,12 +205,6 @@
217 """205 """
218 return self.session.query(Book).get(id)206 return self.session.query(Book).get(id)
219207
220 def get_book_by_name(self, name):
221 """
222 Details of the Books
223 """
224 return self.session.query(Book).filter_by(name = name).first()
225
226 def save_book(self, book):208 def save_book(self, book):
227 """209 """
228 Save the Book210 Save the Book
229211
=== modified file 'openlp/plugins/songs/lib/mediaitem.py'
--- openlp/plugins/songs/lib/mediaitem.py 2009-06-14 07:25:39 +0000
+++ openlp/plugins/songs/lib/mediaitem.py 2009-06-14 13:50:56 +0000
@@ -23,12 +23,11 @@
23from openlp.core.lib import MediaManagerItem, translate, ServiceItem, SongXMLParser23from openlp.core.lib import MediaManagerItem, translate, ServiceItem, SongXMLParser
2424
25from openlp.plugins.songs.forms import EditSongForm25from openlp.plugins.songs.forms import EditSongForm
26from openlp.plugins.songs.lib import TextListData
2726
28class SongList(QtGui.QListView):27class SongList(QtGui.QListWidget):
2928
30 def __init__(self,parent=None,name=None):29 def __init__(self,parent=None,name=None):
31 QtGui.QListView.__init__(self,parent)30 QtGui.QListWidget.__init__(self,parent)
3231
33 def mouseMoveEvent(self, event):32 def mouseMoveEvent(self, event):
34 """33 """
@@ -119,14 +118,12 @@
119 self.SearchLayout.addWidget(self.SearchTextButton, 3, 2, 1, 1)118 self.SearchLayout.addWidget(self.SearchTextButton, 3, 2, 1, 1)
120 # Add the song widget to the page layout119 # Add the song widget to the page layout
121 self.PageLayout.addWidget(self.SongWidget)120 self.PageLayout.addWidget(self.SongWidget)
122 self.SongListView = SongList()121 self.SongListWidget = SongList()
123 self.SongListView.setAlternatingRowColors(True)122 self.SongListWidget.setAlternatingRowColors(True)
124 self.SongListData = TextListData()123 self.SongListWidget.setDragEnabled(True)
125 self.SongListView.setModel(self.SongListData)124 self.SongListWidget.setObjectName(u'SongListWidget')
126 self.SongListView.setDragEnabled(True)125 self.PageLayout.addWidget(self.SongListWidget)
127 self.SongListView.setObjectName(u'SongListView')126 self.SongListWidget.setDragEnabled(True)
128 self.PageLayout.addWidget(self.SongListView)
129 self.SongListView.setDragEnabled(True)
130 # Signals and slots127 # Signals and slots
131 QtCore.QObject.connect(self.SearchTextButton,128 QtCore.QObject.connect(self.SearchTextButton,
132 QtCore.SIGNAL(u'pressed()'), self.onSearchTextButtonClick)129 QtCore.SIGNAL(u'pressed()'), self.onSearchTextButtonClick)
@@ -134,21 +131,21 @@
134 QtCore.SIGNAL(u'pressed()'), self.onClearTextButtonClick)131 QtCore.SIGNAL(u'pressed()'), self.onClearTextButtonClick)
135 QtCore.QObject.connect(self.SearchTextEdit,132 QtCore.QObject.connect(self.SearchTextEdit,
136 QtCore.SIGNAL(u'textChanged(const QString&)'), self.onSearchTextEditChanged)133 QtCore.SIGNAL(u'textChanged(const QString&)'), self.onSearchTextEditChanged)
137 QtCore.QObject.connect(self.SongListView,134 QtCore.QObject.connect(self.SongListWidget,
138 QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.onSongPreviewClick)135 QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.onSongPreviewClick)
139 #define and add the context menu136 #define and add the context menu
140 self.SongListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)137 self.SongListWidget.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
141 self.SongListView.addAction(self.contextMenuAction(self.SongListView,138 self.SongListWidget.addAction(self.contextMenuAction(self.SongListWidget,
142 ':/songs/song_new.png', translate(u'SongMediaItem', u'&Edit Song'),139 ':/songs/song_new.png', translate(u'SongMediaItem', u'&Edit Song'),
143 self.onSongEditClick))140 self.onSongEditClick))
144 self.SongListView.addAction(self.contextMenuSeparator(self.SongListView))141 self.SongListWidget.addAction(self.contextMenuSeparator(self.SongListWidget))
145 self.SongListView.addAction(self.contextMenuAction(self.SongListView,142 self.SongListWidget.addAction(self.contextMenuAction(self.SongListWidget,
146 ':/system/system_preview.png', translate(u'SongMediaItem', u'&Preview Song'),143 ':/system/system_preview.png', translate(u'SongMediaItem', u'&Preview Song'),
147 self.onSongPreviewClick))144 self.onSongPreviewClick))
148 self.SongListView.addAction(self.contextMenuAction(self.SongListView,145 self.SongListWidget.addAction(self.contextMenuAction(self.SongListWidget,
149 ':/system/system_live.png', translate(u'SongMediaItem', u'&Show Live'),146 ':/system/system_live.png', translate(u'SongMediaItem', u'&Show Live'),
150 self.onSongLiveClick))147 self.onSongLiveClick))
151 self.SongListView.addAction(self.contextMenuAction(self.SongListView,148 self.SongListWidget.addAction(self.contextMenuAction(self.SongListWidget,
152 ':/system/system_add.png', translate(u'SongMediaItem', u'&Add to Service'),149 ':/system/system_add.png', translate(u'SongMediaItem', u'&Add to Service'),
153 self.onSongAddClick))150 self.onSongAddClick))
154151
@@ -165,7 +162,7 @@
165162
166 def displayResults(self, searchresults):163 def displayResults(self, searchresults):
167 log.debug(u'display results')164 log.debug(u'display results')
168 self.SongListData.resetStore()165 self.SongListWidget.clear()
169 #log.debug(u'Records returned from search %s", len(searchresults))166 #log.debug(u'Records returned from search %s", len(searchresults))
170 for song in searchresults:167 for song in searchresults:
171 author_list = u''168 author_list = u''
@@ -174,7 +171,9 @@
174 author_list = author_list + u', '171 author_list = author_list + u', '
175 author_list = author_list + author.display_name172 author_list = author_list + author.display_name
176 song_detail = unicode(u'%s (%s)' % (unicode(song.title), unicode(author_list)))173 song_detail = unicode(u'%s (%s)' % (unicode(song.title), unicode(author_list)))
177 self.SongListData.addRow(song.id,song_detail)174 song_name = QtGui.QListWidgetItem(song_detail)
175 song_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(song.id))
176 self.SongListWidget.addItem(song_name)
178177
179 def onClearTextButtonClick(self):178 def onClearTextButtonClick(self):
180 """179 """
@@ -209,18 +208,16 @@
209 self.edit_song_form.exec_()208 self.edit_song_form.exec_()
210209
211 def onSongEditClick(self):210 def onSongEditClick(self):
212 indexes = self.SongListView.selectedIndexes()211 item = self.SongListWidget.currentItem()
213 for index in indexes:212 item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
214 id = self.SongListData.getId(index)213 self.edit_song_form.loadSong(item_id)
215 self.edit_song_form.loadSong(id)214 self.edit_song_form.exec_()
216 self.edit_song_form.exec_()
217215
218 def onSongDeleteClick(self):216 def onSongDeleteClick(self):
219 indexes = self.SongListView.selectedIndexes()217 item = self.SongListWidget.currentItem()
220 for index in indexes:218 item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
221 id = self.SongListData.getId(index)219 self.parent.songmanager.delete_song(id)
222 self.parent.songmanager.delete_song(id)220 self.SongListWidget.removeItem(item)
223 self.SongListData.deleteRow(index)
224221
225 def onSongPreviewClick(self):222 def onSongPreviewClick(self):
226 service_item = ServiceItem(self.parent)223 service_item = ServiceItem(self.parent)
@@ -233,29 +230,28 @@
233 raw_footer = []230 raw_footer = []
234 author_list = u''231 author_list = u''
235 ccl = u''232 ccl = u''
236 indexes = self.SongListView.selectedIndexes()233 item = self.SongListWidget.currentItem()
237 for index in indexes:234 item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
238 id = self.SongListData.getId(index)235 song = self.parent.songmanager.get_song(item_id)
239 song = self.parent.songmanager.get_song(id)236 service_item.theme = song.theme_name
240 service_item.theme = song.theme_name237 if song.lyrics.startswith(u'<?xml version='):
241 if song.lyrics.startswith(u'<?xml version='):238 songXML=SongXMLParser(song.lyrics)
242 songXML=SongXMLParser(song.lyrics)239 verseList = songXML.get_verses()
243 verseList = songXML.get_verses()240 for verse in verseList:
244 for verse in verseList:241 service_item.add_from_text(verse[1][:30], verse[1])
245 service_item.add_from_text(verse[1][:30], verse[1])242 else:
246 else:243 verses = song.lyrics.split(u'\n\n')
247 verses = song.lyrics.split(u'\n\n')244 for slide in verses:
248 for slide in verses:245 service_item.add_from_text(slide[:30], slide)
249 service_item.add_from_text(slide[:30], slide)246 service_item.title = song.title
250 service_item.title = song.title247 for author in song.authors:
251 for author in song.authors:248 if len(author_list) > 1:
252 if len(author_list) > 1:249 author_list = author_list + u', '
253 author_list = author_list + u', '250 author_list = author_list + unicode(author.display_name)
254 author_list = author_list + unicode(author.display_name)251 if song.ccli_number == None or len(song.ccli_number) == 0:
255 if song.ccli_number == None or len(song.ccli_number) == 0:252 ccl = self.parent.settings.GeneralTab.CCLNumber
256 ccl = self.parent.settings.GeneralTab.CCLNumber253 else:
257 else:254 ccl = unicode(song.ccli_number)
258 ccl = unicode(song.ccli_number)
259 raw_footer.append(song.title)255 raw_footer.append(song.title)
260 raw_footer.append(author_list)256 raw_footer.append(author_list)
261 raw_footer.append(song.copyright )257 raw_footer.append(song.copyright )
262258
=== removed file 'openlp/plugins/songs/lib/textlistdata.py'
--- openlp/plugins/songs/lib/textlistdata.py 2009-06-13 16:15:55 +0000
+++ openlp/plugins/songs/lib/textlistdata.py 1970-01-01 00:00:00 +0000
@@ -1,81 +0,0 @@
1# -*- coding: utf-8 -*-
2# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
3"""
4OpenLP - Open Source Lyrics Projection
5Copyright (c) 2008 Raoul Snyman
6Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley
7
8This program is free software; you can redistribute it and/or modify it under
9the terms of the GNU General Public License as published by the Free Software
10Foundation; version 2 of the License.
11
12This program is distributed in the hope that it will be useful, but WITHOUT ANY
13WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
14PARTICULAR PURPOSE. See the GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License along with
17this program; if not, write to the Free Software Foundation, Inc., 59 Temple
18Place, Suite 330, Boston, MA 02111-1307 USA
19"""
20import logging
21
22from PyQt4 import QtCore, QtGui
23
24class TextListData(QtCore.QAbstractListModel):
25 """
26 An abstract list of strings
27 """
28 global log
29 log = logging.getLogger(u'TextListData')
30 log.info(u'started')
31
32 def __init__(self):
33 QtCore.QAbstractListModel.__init__(self)
34 self.items = [] # will be a list of (database id , title) tuples
35
36 def resetStore(self):
37 #reset list so can be reloaded
38 self.items = []
39
40 def rowCount(self, parent):
41 return len(self.items)
42
43 def insertRow(self, row, id, title):
44 self.beginInsertRows(QtCore.QModelIndex(),row,row)
45 self.items.insert(row, (id, title))
46 self.endInsertRows()
47
48 def removeRow(self, row):
49 self.beginRemoveRows(QtCore.QModelIndex(), row,row)
50 self.items.pop(row)
51 self.endRemoveRows()
52
53 def addRow(self, id, title):
54 self.insertRow(len(self.items), id, title)
55
56 def data(self, index, role):
57 row = index.row()
58 if row > len(self.items): # if the last row is selected and deleted, we then get called with an empty row!
59 return QtCore.QVariant()
60 if role == QtCore.Qt.DisplayRole:
61 if row == self.rowCount(None):
62 row -= 1
63 retval = self.items[row][1]
64 else:
65 retval = QtCore.QVariant()
66 if type(retval) is not type(QtCore.QVariant):
67 return QtCore.QVariant(retval)
68 else:
69 return retval
70
71 def getIdList(self):
72 filelist = [item[0] for item in self.items];
73 return filelist
74
75 def getId(self, index):
76 row = index.row()
77 return self.items[row][0]
78
79 def deleteRow(self, index):
80 row = index.row()
81 self.removeRow(row)