Add delete option to Custom plugin

bzr-revno: 420
This commit is contained in:
Tim Bentley 2009-03-15 06:35:07 +00:00
parent 55bd3cc772
commit 0d33ba5668
3 changed files with 22 additions and 52 deletions

View File

@ -70,15 +70,6 @@ class CustomManager():
""" """
return self.session.query(CustomSlide).order_by(CustomSlide.title).all() 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): def save_slide(self, customslide):
""" """
Saves a song to the database Saves a song to the database
@ -101,45 +92,15 @@ class CustomManager():
return CustomSlide() return CustomSlide()
else: else:
return self.session.query(CustomSlide).get(id) return self.session.query(CustomSlide).get(id)
#
# def delete_song(self, song): def delete_custom(self, id):
# try: if id !=0:
# self.session.delete(song) customslide = self.get_custom(id)
# self.session.commit() try:
# return True self.session.delete(customslide)
# except: self.session.commit()
# return False return True
# except:
# def get_authors(self): return False
# """ else:
# Returns a list of all the authors return True
# """
# 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

View File

@ -182,7 +182,12 @@ class CustomMediaItem(MediaManagerItem):
self.initialise() self.initialise()
def onCustomDeleteClick(self): 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): def onCustomPreviewClick(self):
pass pass

View File

@ -61,5 +61,9 @@ class TextListData(QAbstractListModel):
row = index.row() row = index.row()
return self.items[row][0] return self.items[row][0]
def deleteRow(self, index):
row = index.row()
self.removeRow(row)
if __name__=="__main__": if __name__=="__main__":
sxml=TextListData() sxml=TextListData()