diff --git a/openlp/plugins/custom/lib/manager.py b/openlp/plugins/custom/lib/manager.py index e8dcf9e36..130cd4de3 100644 --- a/openlp/plugins/custom/lib/manager.py +++ b/openlp/plugins/custom/lib/manager.py @@ -70,15 +70,6 @@ class CustomManager(): """ return self.session.query(CustomSlide).order_by(CustomSlide.title).all() - def get_custom(self, id=None): - """ - Returns the details of a song - """ - if id is None: - return CustomSlide() - else: - return self.session.query(CustomSlide).get(id) - def save_slide(self, customslide): """ Saves a song to the database @@ -101,45 +92,15 @@ class CustomManager(): return CustomSlide() else: return self.session.query(CustomSlide).get(id) -# -# def delete_song(self, song): -# try: -# self.session.delete(song) -# self.session.commit() -# return True -# except: -# return False -# -# def get_authors(self): -# """ -# Returns a list of all the authors -# """ -# return self.session.query(Author).order_by(Author.display_name).all() -# -# def get_author(self, id): -# """ -# Details of the Author -# """ -# return self.session.query(Author).get(id) -# -# def save_author(self, author): -# """ -# Save the Author and refresh the cache -# """ -# try: -# self.session.add(author) -# self.session.commit() -# return True -# except: -# return False -# -# def delete_author(self, authorid): -# """ -# Delete the author and refresh the author cache -# """ -# try: -# self.session.delete(author) -# self.session.commit() -# return True -# except: -# return False + + def delete_custom(self, id): + if id !=0: + customslide = self.get_custom(id) + try: + self.session.delete(customslide) + self.session.commit() + return True + except: + return False + else: + return True diff --git a/openlp/plugins/custom/lib/mediaitem.py b/openlp/plugins/custom/lib/mediaitem.py index af69bb89a..953f1f096 100644 --- a/openlp/plugins/custom/lib/mediaitem.py +++ b/openlp/plugins/custom/lib/mediaitem.py @@ -182,7 +182,12 @@ class CustomMediaItem(MediaManagerItem): self.initialise() def onCustomDeleteClick(self): - pass + print 'delete pressed' + indexes = self.CustomListView.selectedIndexes() + for index in indexes: + id = self.CustomListData.getId(index) + self.parent.custommanager.delete_custom(id) + self.CustomListData.deleteRow(index) def onCustomPreviewClick(self): pass diff --git a/openlp/plugins/custom/lib/textlistdata.py b/openlp/plugins/custom/lib/textlistdata.py index 0f87bbcb1..4900aaef1 100644 --- a/openlp/plugins/custom/lib/textlistdata.py +++ b/openlp/plugins/custom/lib/textlistdata.py @@ -61,5 +61,9 @@ class TextListData(QAbstractListModel): row = index.row() return self.items[row][0] + def deleteRow(self, index): + row = index.row() + self.removeRow(row) + if __name__=="__main__": sxml=TextListData()