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 openlp.core.lib import Receiver, translate
from openlp.core.lib import Receiver, SettingsManager, translate
from openlp.core.ui import criticalErrorMessageBox
from openlp.core.ui.wizard import OpenLPWizard
from openlp.plugins.songs.lib.db import Song
@ -158,6 +158,19 @@ class SongExportForm(OpenLPWizard):
self.selectedListWidget.setSortingEnabled(True)
self.verticalLayout.addWidget(self.selectedListWidget)
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)
#TODO: Add save dialog and maybe a search box.
@ -209,13 +222,9 @@ class SongExportForm(OpenLPWizard):
Receiver.send_message(u'cursor_busy')
songs = self.plugin.manager.get_all_objects(Song)
for song in songs:
author_list = u''
for author in song.authors:
if author_list != u'':
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)
authors = u', '.join([author.display_name
for author in song.authors])
song_detail = u'%s (%s)' % (unicode(song.title), authors)
song_name = QtGui.QListWidgetItem(song_detail)
song_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(song))
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
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()
for item in self.selectedListWidget.selectedItems()]
exporter = OpenLyricsExport(self, songs, u'/tmp/')
exporter = OpenLyricsExport(self, songs, path)
if exporter.do_export():
self.progressLabel.setText(
translate('SongsPlugin.SongExportForm', 'Finished export.'))

View File

@ -271,6 +271,8 @@ class OpenLyrics(object):
verse[0][u'type'][0].lower(), verse[0][u'label'])
element = \
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)
for line in unicode(verse[1]).split(u'\n'):
self._add_text_to_element(u'line', element, line)