forked from openlp/openlp
clean ups, added missing file
This commit is contained in:
parent
cfb896e3b1
commit
909fa25e7b
@ -314,15 +314,14 @@ class SongMediaItem(MediaManagerItem):
|
||||
translate('SongsPlugin.MediaItem',
|
||||
'You must select an item to delete.')):
|
||||
items = self.listView.selectedIndexes()
|
||||
ans = QtGui.QMessageBox.question(self,
|
||||
if QtGui.QMessageBox.question(self,
|
||||
translate('SongsPlugin.MediaItem', 'Delete Song(s)?'),
|
||||
translate('SongsPlugin.MediaItem',
|
||||
'Are you sure you want to delete the %n selected song(s)?', '',
|
||||
QtCore.QCoreApplication.CodecForTr, len(items)),
|
||||
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok|
|
||||
QtGui.QMessageBox.Cancel),
|
||||
QtGui.QMessageBox.Ok)
|
||||
if ans == QtGui.QMessageBox.Cancel:
|
||||
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok |
|
||||
QtGui.QMessageBox.Cancel),
|
||||
QtGui.QMessageBox.Ok) == QtGui.QMessageBox.Cancel:
|
||||
return
|
||||
for item in items:
|
||||
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
|
||||
@ -396,8 +395,8 @@ class SongMediaItem(MediaManagerItem):
|
||||
service_item.audit = [
|
||||
song.title, author_audit, song.copyright, unicode(song.ccli_number)
|
||||
]
|
||||
service_item.data_string = {u'title':song.search_title,
|
||||
u'authors':author_list}
|
||||
service_item.data_string = {u'title': song.search_title,
|
||||
u'authors': author_list}
|
||||
service_item.xml_version = self.openLyrics.song_to_xml(song)
|
||||
return True
|
||||
|
||||
|
77
openlp/plugins/songs/lib/openlyricsimport.py
Normal file
77
openlp/plugins/songs/lib/openlyricsimport.py
Normal file
@ -0,0 +1,77 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
||||
|
||||
###############################################################################
|
||||
# OpenLP - Open Source Lyrics Projection #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# Copyright (c) 2008-2011 Raoul Snyman #
|
||||
# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael #
|
||||
# Gorven, Scott Guerrieri, Meinert Jordan, Andreas Preikschat, Christian #
|
||||
# Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon Tibble, #
|
||||
# Carsten Tinggaard, Frode Woldsund #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# This program is free software; you can redistribute it and/or modify it #
|
||||
# under the terms of the GNU General Public License as published by the Free #
|
||||
# Software Foundation; version 2 of the License. #
|
||||
# #
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT #
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
|
||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
|
||||
# more details. #
|
||||
# #
|
||||
# You should have received a copy of the GNU General Public License along #
|
||||
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
|
||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||
###############################################################################
|
||||
"""
|
||||
The :mod:`openlyricsimport` module provides the functionality for importing
|
||||
songs which are saved as OpenLyrics files.
|
||||
"""
|
||||
|
||||
#import logging
|
||||
import os
|
||||
|
||||
from openlp.core.lib import translate
|
||||
from openlp.plugins.songs.lib.songimport import SongImport
|
||||
from openlp.plugins.songs.lib import OpenLyricsParser
|
||||
|
||||
#log = logging.getLogger(__name__)
|
||||
|
||||
class OpenLyricsImport(SongImport):
|
||||
"""
|
||||
This provides the Openlyrics import.
|
||||
"""
|
||||
def __init__(self, master_manager, **kwargs):
|
||||
"""
|
||||
Initialise the import.
|
||||
"""
|
||||
SongImport.__init__(self, master_manager)
|
||||
self.master_manager = master_manager
|
||||
self.openLyricsParser = OpenLyricsParser(master_manager)
|
||||
if kwargs.has_key(u'filename'):
|
||||
self.import_source = kwargs[u'filename']
|
||||
if kwargs.has_key(u'filenames'):
|
||||
self.import_source = kwargs[u'filenames']
|
||||
|
||||
def do_import(self):
|
||||
"""
|
||||
Imports the songs.
|
||||
"""
|
||||
success = True
|
||||
self.import_wizard.importProgressBar.setMaximum(len(self.import_source))
|
||||
for file_path in self.import_source:
|
||||
if self.stop_import_flag:
|
||||
success = False
|
||||
break
|
||||
file = open(file_path)
|
||||
xml = file.read()
|
||||
file.close()
|
||||
self.import_wizard.incrementProgressBar(unicode(translate(
|
||||
'SongsPlugin.OpenLyricsImport', 'Importing %s...')) %
|
||||
os.path.basename(file_path))
|
||||
if self.openLyricsParser.xml_to_song(xml) == 0:
|
||||
success = false
|
||||
break
|
||||
if success:
|
||||
return True
|
||||
return False
|
@ -367,6 +367,7 @@ class OpenLyricsParser(object):
|
||||
# No Author in XML so ignore
|
||||
pass
|
||||
self.manager.save_object(song)
|
||||
# TODO: better return song itself, instead of song.id
|
||||
return song.id
|
||||
|
||||
def _add_text_to_element(self, tag, parent, text=None, label=None):
|
||||
|
Loading…
Reference in New Issue
Block a user