Head r1689

This commit is contained in:
Jon Tibble 2011-07-17 12:56:17 +01:00
commit 60b286ca3e
3 changed files with 18 additions and 51 deletions

View File

@ -802,7 +802,6 @@ class ServiceManager(QtGui.QWidget):
# Top Item was selected so set the last one
if setLastItem:
lastItem.setSelected(True)
self.setModified()
def onMoveSelectionDown(self):
"""
@ -824,7 +823,6 @@ class ServiceManager(QtGui.QWidget):
serviceIterator += 1
if setSelected:
firstItem.setSelected(True)
self.setModified()
def onCollapseAll(self):
"""
@ -863,12 +861,12 @@ class ServiceManager(QtGui.QWidget):
Move the current ServiceItem to the top of the list.
"""
item, child = self.findServiceItem()
if item < len(self.serviceItems) and item is not -1:
if item < len(self.serviceItems) and item != -1:
temp = self.serviceItems[item]
self.serviceItems.remove(self.serviceItems[item])
self.serviceItems.insert(0, temp)
self.repaintServiceList(0, child)
self.setModified()
self.setModified()
def onServiceUp(self):
"""
@ -880,31 +878,31 @@ class ServiceManager(QtGui.QWidget):
self.serviceItems.remove(self.serviceItems[item])
self.serviceItems.insert(item - 1, temp)
self.repaintServiceList(item - 1, child)
self.setModified()
self.setModified()
def onServiceDown(self):
"""
Move the current ServiceItem one position down in the list.
"""
item, child = self.findServiceItem()
if item < len(self.serviceItems) and item is not -1:
if item < len(self.serviceItems) and item != -1:
temp = self.serviceItems[item]
self.serviceItems.remove(self.serviceItems[item])
self.serviceItems.insert(item + 1, temp)
self.repaintServiceList(item + 1, child)
self.setModified()
self.setModified()
def onServiceEnd(self):
"""
Move the current ServiceItem to the bottom of the list.
"""
item, child = self.findServiceItem()
if item < len(self.serviceItems) and item is not -1:
if item < len(self.serviceItems) and item != -1:
temp = self.serviceItems[item]
self.serviceItems.remove(self.serviceItems[item])
self.serviceItems.insert(len(self.serviceItems), temp)
self.repaintServiceList(len(self.serviceItems) - 1, child)
self.setModified()
self.setModified()
def onDeleteFromService(self):
"""
@ -914,7 +912,7 @@ class ServiceManager(QtGui.QWidget):
if item != -1:
self.serviceItems.remove(self.serviceItems[item])
self.repaintServiceList(item - 1, -1)
self.setModified()
self.setModified()
def repaintServiceList(self, serviceItem, serviceItemChild):
"""

View File

@ -28,7 +28,6 @@
import logging
import os
import re
from zipfile import ZipFile
from lxml import objectify
from lxml.etree import Error, LxmlError
@ -110,48 +109,13 @@ class OpenSongImport(SongImport):
SongImport.__init__(self, manager, **kwargs)
def do_import(self):
"""
Import either each of the files in self.import_source - each element of
which can be either a single opensong file, or a zipfile containing
multiple opensong files.
"""
numfiles = 0
for filename in self.import_source:
ext = os.path.splitext(filename)[1]
if ext.lower() == u'.zip':
z = ZipFile(filename, u'r')
numfiles += len(z.infolist())
z.close()
else:
numfiles += 1
log.debug(u'Total number of files: %d', numfiles)
self.import_wizard.progressBar.setMaximum(numfiles)
self.import_wizard.progressBar.setMaximum(len(self.import_source))
for filename in self.import_source:
if self.stop_import_flag:
return
ext = os.path.splitext(filename)[1]
if ext.lower() == u'.zip':
log.debug(u'Zipfile found %s', filename)
z = ZipFile(filename, u'r')
for song in z.infolist():
if self.stop_import_flag:
z.close()
return
parts = os.path.split(song.filename)
if parts[-1] == u'':
# No final part => directory
continue
log.info(u'Zip importing %s', parts[-1])
song_file = z.open(song)
self.do_import_file(song_file)
song_file.close()
z.close()
else:
# not a zipfile
log.info(u'Direct import %s', filename)
song_file = open(filename)
self.do_import_file(song_file)
song_file.close()
song_file = open(filename)
self.do_import_file(song_file)
song_file.close()
def do_import_file(self, file):
"""

View File

@ -5,7 +5,12 @@
###############################################################################
# OpenLP - Open Source Lyrics Projection #
# --------------------------------------------------------------------------- #
# Copyright (c) 2011 Raoul Snyman #
# Copyright (c) 2008-2011 Raoul Snyman #
# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan #
# Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, #
# Armin Köhler, Joshua Millar, Stevan Pettit, Andreas Preikschat, Mattias #
# Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, #
# Maikel Stuivenberg, Martin Thompson, Jon Tibble, 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 #