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