diff --git a/openlp/plugins/custom/forms/editcustomform.py b/openlp/plugins/custom/forms/editcustomform.py index 6f3a059b0..bb892cbb2 100644 --- a/openlp/plugins/custom/forms/editcustomform.py +++ b/openlp/plugins/custom/forms/editcustomform.py @@ -60,19 +60,26 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog): self.DeleteButton.setEnabled(False) self.EditButton.setEnabled(False) self.SaveButton.setEnabled(False) + self.TitleEdit.setText('') + self.CreditEdit.setText('') self.VerseTextEdit.clear() - self.VerseListView.clear() + self.VerseListView.clear() + #make sure we have a new item + self.customSlide = CustomSlide() def loadCustom(self, id): - self.customSlide = self.custommanager.get_custom(id) - self.TitleEdit.setText(self.customSlide.title) - self.CreditEdit.setText(self.customSlide.title) - - songXML=SongXMLParser(self.customSlide.text) - verseList = songXML.get_verses() - for verse in verseList: - self.VerseListView.addItem(verse[1]) - self.validate() + if id == 0: + self.initialise() + else: + self.customSlide = self.custommanager.get_custom(id) + self.TitleEdit.setText(self.customSlide.title) + self.CreditEdit.setText(self.customSlide.title) + + songXML=SongXMLParser(self.customSlide.text) + verseList = songXML.get_verses() + for verse in verseList: + self.VerseListView.addItem(verse[1]) + self.validate() def accept(self): self.validate() @@ -84,9 +91,6 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog): for i in range (0, self.VerseListView.count()): sxml.add_verse_to_lyrics(u'custom', str(count), str(self.VerseListView.item(i).text())) count += 1 - sxml.dump_xml() - if self.customSlide == None: - self.customSlide = CustomSlide() self.customSlide.title = unicode(self.TitleEdit.displayText()) self.customSlide.text = unicode(sxml.extract_xml()) self.customSlide.credits = unicode(self.CreditEdit.displayText()) diff --git a/openlp/plugins/custom/lib/mediaitem.py b/openlp/plugins/custom/lib/mediaitem.py index 5e6c67d41..af69bb89a 100644 --- a/openlp/plugins/custom/lib/mediaitem.py +++ b/openlp/plugins/custom/lib/mediaitem.py @@ -84,23 +84,23 @@ class CustomMediaItem(MediaManagerItem): self.CustomWidget.setSizePolicy(sizePolicy) self.CustomWidget.setObjectName('CustomWidget') - self.SearchLayout = QtGui.QGridLayout(self.CustomWidget) - self.SearchLayout.setObjectName('SearchLayout') - self.SearchTextLabel = QtGui.QLabel(self.CustomWidget) - self.SearchTextLabel.setObjectName('SearchTextLabel') - self.SearchTextLabel.setText('Search Text:') - self.SearchLayout.addWidget(self.SearchTextLabel, 2, 0, 1, 1) - self.SearchTextEdit = QtGui.QLineEdit(self.CustomWidget) - self.SearchTextEdit.setObjectName('SearchTextEdit') - self.SearchLayout.addWidget(self.SearchTextEdit, 2, 1, 1, 2) - - self.ClearTextButton = QtGui.QPushButton(self.CustomWidget) - self.ClearTextButton.setObjectName('ClearTextButton') - - self.SearchLayout.addWidget(self.ClearTextButton, 3, 1, 1, 1) - self.SearchTextButton = QtGui.QPushButton(self.CustomWidget) - self.SearchTextButton.setObjectName('SearchTextButton') - self.SearchLayout.addWidget(self.SearchTextButton, 3, 2, 1, 1) +# self.SearchLayout = QtGui.QGridLayout(self.CustomWidget) +# self.SearchLayout.setObjectName('SearchLayout') +# self.SearchTextLabel = QtGui.QLabel(self.CustomWidget) +# self.SearchTextLabel.setObjectName('SearchTextLabel') +# self.SearchTextLabel.setText('Search Text:') +# self.SearchLayout.addWidget(self.SearchTextLabel, 2, 0, 1, 1) +# self.SearchTextEdit = QtGui.QLineEdit(self.CustomWidget) +# self.SearchTextEdit.setObjectName('SearchTextEdit') +# self.SearchLayout.addWidget(self.SearchTextEdit, 2, 1, 1, 2) +# +# self.ClearTextButton = QtGui.QPushButton(self.CustomWidget) +# self.ClearTextButton.setObjectName('ClearTextButton') +# +# self.SearchLayout.addWidget(self.ClearTextButton, 3, 1, 1, 1) +# self.SearchTextButton = QtGui.QPushButton(self.CustomWidget) +# self.SearchTextButton.setObjectName('SearchTextButton') +# self.SearchLayout.addWidget(self.SearchTextButton, 3, 2, 1, 1) # Add the Custom widget to the page layout self.PageLayout.addWidget(self.CustomWidget) @@ -112,14 +112,14 @@ class CustomMediaItem(MediaManagerItem): self.PageLayout.addWidget(self.CustomListView) # Signals - QtCore.QObject.connect(self.SearchTextButton, - QtCore.SIGNAL("pressed()"), self.onSearchTextButtonClick) - QtCore.QObject.connect(self.ClearTextButton, - QtCore.SIGNAL("pressed()"), self.onClearTextButtonClick) - QtCore.QObject.connect(self.SearchTextEdit, - QtCore.SIGNAL("textChanged(const QString&)"), self.onSearchTextEditChanged) - QtCore.QObject.connect(self.CustomListView, - QtCore.SIGNAL("itemPressed(QTableWidgetItem * item)"), self.onCustomSelected) +# QtCore.QObject.connect(self.SearchTextButton, +# QtCore.SIGNAL("pressed()"), self.onSearchTextButtonClick) +# QtCore.QObject.connect(self.ClearTextButton, +# QtCore.SIGNAL("pressed()"), self.onClearTextButtonClick) +# QtCore.QObject.connect(self.SearchTextEdit, +# QtCore.SIGNAL("textChanged(const QString&)"), self.onSearchTextEditChanged) +# QtCore.QObject.connect(self.CustomListView, +# QtCore.SIGNAL("itemPressed(QTableWidgetItem * item)"), self.onCustomSelected) #define and add the context menu self.CustomListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) @@ -137,14 +137,15 @@ class CustomMediaItem(MediaManagerItem): self.CustomListView, ':/system/system_add.png', "&Add to Service", self.onCustomEditClick)) - def retranslateUi(self): - self.ClearTextButton.setText(translate('CustomMediaItem', u'Clear')) - self.SearchTextButton.setText(translate('CustomMediaItem', u'Search')) +# def retranslateUi(self): +# self.ClearTextButton.setText(translate('CustomMediaItem', u'Clear')) +# self.SearchTextButton.setText(translate('CustomMediaItem', u'Search')) def initialise(self): self.loadCustomList(self.parent.custommanager.get_all_slides()) def loadCustomList(self, list): + self.CustomListData.resetStore() for CustomSlide in list: self.CustomListData.addRow(CustomSlide.id,CustomSlide.title) @@ -169,6 +170,7 @@ class CustomMediaItem(MediaManagerItem): print item def onCustomNewClick(self): + self.parent.edit_custom_form.loadCustom(0) self.parent.edit_custom_form.exec_() self.initialise() diff --git a/openlp/plugins/custom/lib/textlistdata.py b/openlp/plugins/custom/lib/textlistdata.py index 70f4634f6..0f87bbcb1 100644 --- a/openlp/plugins/custom/lib/textlistdata.py +++ b/openlp/plugins/custom/lib/textlistdata.py @@ -9,13 +9,17 @@ class TextListData(QAbstractListModel): An abstract list of strings """ global log - log=logging.getLogger("TextListData") - log.info("started") + log=logging.getLogger(u'TextListData') + log.info(u'started') def __init__(self): QAbstractListModel.__init__(self) self.items=[] # will be a list of (database id , title) tuples + def resetStore(self): + #reset list so can be reloaded + self.items=[] + def rowCount(self, parent): return len(self.items) @@ -32,15 +36,15 @@ class TextListData(QAbstractListModel): def addRow(self, id, title): self.insertRow(len(self.items), id, title) - + def data(self, index, role): row=index.row() if row > len(self.items): # if the last row is selected and deleted, we then get called with an empty row! return QVariant() if role==Qt.DisplayRole: retval= self.items[row][1] - elif role == Qt.ToolTipRole: - retval= self.items[row][0] +# elif role == Qt.ToolTipRole: #not sure if need as it shows the database row number +# retval= self.items[row][0] else: retval= QVariant() # log.info("Returning"+ str(retval))