Up/Down buttons, Remove/Remove All buttons.

This commit is contained in:
Raoul Snyman 2011-08-27 01:04:54 +02:00
parent c81117991a
commit f099329217
3 changed files with 42 additions and 4 deletions

View File

@ -205,7 +205,8 @@ class Manager(object):
return return
try: try:
self.session = init_schema(self.db_url) self.session = init_schema(self.db_url)
except: except SQLAlchemyError, DBAPIError:
log.exception(u'Error loading database: %s', self.db_url)
critical_error_message_box( critical_error_message_box(
translate('OpenLP.Manager', 'Database Error'), translate('OpenLP.Manager', 'Database Error'),
unicode(translate('OpenLP.Manager', 'OpenLP cannot load your ' unicode(translate('OpenLP.Manager', 'OpenLP cannot load your '

View File

@ -100,6 +100,10 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
QtCore.SIGNAL(u'clicked()'), self.onAudioAddFromFileButtonClicked) QtCore.SIGNAL(u'clicked()'), self.onAudioAddFromFileButtonClicked)
QtCore.QObject.connect(self.audioAddFromMediaButton, QtCore.QObject.connect(self.audioAddFromMediaButton,
QtCore.SIGNAL(u'clicked()'), self.onAudioAddFromMediaButtonClicked) QtCore.SIGNAL(u'clicked()'), self.onAudioAddFromMediaButtonClicked)
QtCore.QObject.connect(self.audioRemoveButton,
QtCore.SIGNAL(u'clicked()'), self.onAudioRemoveButtonClicked)
QtCore.QObject.connect(self.audioRemoveAllButton,
QtCore.SIGNAL(u'clicked()'), self.onAudioRemoveAllButtonClicked)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'theme_update_list'), self.loadThemes) QtCore.SIGNAL(u'theme_update_list'), self.loadThemes)
self.previewButton = QtGui.QPushButton() self.previewButton = QtGui.QPushButton()
@ -718,11 +722,42 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
item.setData(QtCore.Qt.UserRole, filename) item.setData(QtCore.Qt.UserRole, filename)
self.audioListWidget.addItem(item) self.audioListWidget.addItem(item)
def onAudioRemoveButtonClicked(self):
"""
Removes a file from the list.
"""
row = self.audioListWidget.currentRow()
if row == -1:
return
self.audioListWidget.takeItem(row)
def onAudioRemoveAllButtonClicked(self):
"""
Removes all files from the list.
"""
self.audioListWidget.clear()
def onUpButtonClicked(self): def onUpButtonClicked(self):
pass """
Moves a file up when the user clicks the up button on the audio tab.
"""
row = self.audioListWidget.currentRow()
if row <= 0:
return
item = self.audioListWidget.takeItem(row)
self.audioListWidget.insertItem(row - 1, item)
self.audioListWidget.setCurrentRow(row - 1)
def onDownButtonClicked(self): def onDownButtonClicked(self):
pass """
Moves a file down when the user clicks the up button on the audio tab.
"""
row = self.audioListWidget.currentRow()
if row == -1 or row > self.audioListWidget.count() - 1:
return
item = self.audioListWidget.takeItem(row)
self.audioListWidget.insertItem(row + 1, item)
self.audioListWidget.setCurrentRow(row + 1)
def clearCaches(self): def clearCaches(self):
""" """
@ -830,6 +865,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
media_file = MediaFile() media_file = MediaFile()
media_file.file_name = filename media_file.file_name = filename
media_file.type = u'audio' media_file.type = u'audio'
media_file.weight = row
self.song.media_files.append(media_file) self.song.media_files.append(media_file)
for audio in audio_files: for audio in audio_files:
if audio not in files: if audio not in files:

View File

@ -232,7 +232,8 @@ def init_schema(url):
'authors': relation(Author, backref='songs', 'authors': relation(Author, backref='songs',
secondary=authors_songs_table, lazy=False), secondary=authors_songs_table, lazy=False),
'book': relation(Book, backref='songs'), 'book': relation(Book, backref='songs'),
'media_files': relation(MediaFile, backref='songs'), 'media_files': relation(MediaFile, backref='songs',
order_by=media_files_table.c.weight),
'topics': relation(Topic, backref='songs', 'topics': relation(Topic, backref='songs',
secondary=songs_topics_table) secondary=songs_topics_table)
}) })