add lang when exporting, file dialog

This commit is contained in:
Andreas Preikschat 2011-01-25 20:27:46 +01:00
commit ff2dc95123
2 changed files with 25 additions and 9 deletions

View File

@ -30,7 +30,7 @@ import logging
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.lib import Receiver, translate from openlp.core.lib import Receiver, SettingsManager, translate
from openlp.core.ui import criticalErrorMessageBox from openlp.core.ui import criticalErrorMessageBox
from openlp.core.ui.wizard import OpenLPWizard from openlp.core.ui.wizard import OpenLPWizard
from openlp.plugins.songs.lib.db import Song from openlp.plugins.songs.lib.db import Song
@ -158,6 +158,19 @@ class SongExportForm(OpenLPWizard):
self.selectedListWidget.setSortingEnabled(True) self.selectedListWidget.setSortingEnabled(True)
self.verticalLayout.addWidget(self.selectedListWidget) self.verticalLayout.addWidget(self.selectedListWidget)
self.sourceLayout.addWidget(self.selectedGroupBox) self.sourceLayout.addWidget(self.selectedGroupBox)
#
self.horizontalLayout = QtGui.QHBoxLayout()
self.horizontalLayout.setObjectName(u'horizontalLayout')
self.pathLabel = QtGui.QLabel()
self.pathLabel.setObjectName(u'pathLabel')
self.horizontalLayout.addWidget(self.pathLabel)
self.pathEdit = QtGui.QLineEdit()
self.pathEdit.setObjectName(u'pathEdit')
self.horizontalLayout.addWidget(self.pathEdit)
self.browseButton = QtGui.QToolButton()
self.browseButton.setObjectName(u'browseButton')
self.horizontalLayout.addWidget(self.browseButton)
#
self.addPage(self.sourcePage) self.addPage(self.sourcePage)
#TODO: Add save dialog and maybe a search box. #TODO: Add save dialog and maybe a search box.
@ -209,13 +222,9 @@ class SongExportForm(OpenLPWizard):
Receiver.send_message(u'cursor_busy') Receiver.send_message(u'cursor_busy')
songs = self.plugin.manager.get_all_objects(Song) songs = self.plugin.manager.get_all_objects(Song)
for song in songs: for song in songs:
author_list = u'' authors = u', '.join([author.display_name
for author in song.authors: for author in song.authors])
if author_list != u'': song_detail = u'%s (%s)' % (unicode(song.title), authors)
author_list = author_list + u', '
author_list = author_list + author.display_name
song_title = unicode(song.title)
song_detail = u'%s (%s)' % (song_title, author_list)
song_name = QtGui.QListWidgetItem(song_detail) song_name = QtGui.QListWidgetItem(song_detail)
song_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(song)) song_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(song))
self.availableListWidget.addItem(song_name) self.availableListWidget.addItem(song_name)
@ -266,9 +275,14 @@ class SongExportForm(OpenLPWizard):
class, and then runs the ``do_export`` method of the exporter to do class, and then runs the ``do_export`` method of the exporter to do
the actual exporting. the actual exporting.
""" """
path = unicode(QtGui.QFileDialog.getExistingDirectory(self, translate(
'SongsPlugin.ExportWizardForm', 'Selecte to Folder'),
SettingsManager.get_last_dir(self.plugin.settingsSection, 1),
options=QtGui.QFileDialog.ShowDirsOnly))
SettingsManager.set_last_dir(self.plugin.settingsSection, path, 1)
songs = [item.data(QtCore.Qt.UserRole).toPyObject() songs = [item.data(QtCore.Qt.UserRole).toPyObject()
for item in self.selectedListWidget.selectedItems()] for item in self.selectedListWidget.selectedItems()]
exporter = OpenLyricsExport(self, songs, u'/tmp/') exporter = OpenLyricsExport(self, songs, path)
if exporter.do_export(): if exporter.do_export():
self.progressLabel.setText( self.progressLabel.setText(
translate('SongsPlugin.SongExportForm', 'Finished export.')) translate('SongsPlugin.SongExportForm', 'Finished export.'))

View File

@ -271,6 +271,8 @@ class OpenLyrics(object):
verse[0][u'type'][0].lower(), verse[0][u'label']) verse[0][u'type'][0].lower(), verse[0][u'label'])
element = \ element = \
self._add_text_to_element(u'verse', lyrics, None, verse_tag) self._add_text_to_element(u'verse', lyrics, None, verse_tag)
if verse[0].has_key(u'lang'):
element.set(u'lang', verse[0][u'lang'])
element = self._add_text_to_element(u'lines', element) element = self._add_text_to_element(u'lines', element)
for line in unicode(verse[1]).split(u'\n'): for line in unicode(verse[1]).split(u'\n'):
self._add_text_to_element(u'line', element, line) self._add_text_to_element(u'line', element, line)