forked from openlp/openlp
First working rev. Completed basic testing.
This commit is contained in:
parent
504145d454
commit
c4060dc04b
@ -175,9 +175,8 @@ class SongImportForm(OpenLPWizard):
|
||||
else:
|
||||
self.formatWidgets[format][u'browseButton'].setText(
|
||||
UiStrings().Browse)
|
||||
if select_mode == SongFormatSelect.SingleFile:
|
||||
f_label = 'Filename:'
|
||||
elif select_mode == SongFormatSelect.SingleFolder:
|
||||
f_label = 'Filename:'
|
||||
if select_mode == SongFormatSelect.SingleFolder:
|
||||
f_label = 'Folder:'
|
||||
self.formatWidgets[format][u'filepathLabel'].setText(
|
||||
translate('SongsPlugin.ImportWizardForm', f_label))
|
||||
@ -315,12 +314,12 @@ class SongImportForm(OpenLPWizard):
|
||||
title = custom_title if custom_title \
|
||||
else WizardStrings.OpenTypeFile % format_name
|
||||
if select_mode == SongFormatSelect.MultipleFiles:
|
||||
self.getFiles(title, self.formatWidgets[format][u'FileListWidget'],
|
||||
self.getFiles(title, self.formatWidgets[format][u'fileListWidget'],
|
||||
filter)
|
||||
|
||||
def onRemoveButtonClicked(self):
|
||||
self.removeSelectedItems(
|
||||
self.formatWidgets[self.activeFormat][u'FileListWidget'])
|
||||
self.formatWidgets[self.activeFormat][u'fileListWidget'])
|
||||
|
||||
def setDefaults(self):
|
||||
"""
|
||||
@ -364,17 +363,15 @@ class SongImportForm(OpenLPWizard):
|
||||
select_mode = SongFormatAttr.get(source_format,
|
||||
SongFormatAttr.select_mode)
|
||||
if select_mode == SongFormatSelect.SingleFile:
|
||||
importer = self.plugin.importSongs(source_format,
|
||||
filename=unicode(
|
||||
importer = self.plugin.importSongs(source_format, filename=unicode(
|
||||
self.formatWidgets[source_format][u'filepathEdit'].text()))
|
||||
elif select_mode == SongFormatSelect.MultipleFiles:
|
||||
elif select_mode == SongFormatSelect.SingleFolder:
|
||||
importer = self.plugin.importSongs(source_format, folder=unicode(
|
||||
self.formatWidgets[source_format][u'filepathEdit'].text()))
|
||||
else:
|
||||
importer = self.plugin.importSongs(source_format,
|
||||
filenames=self.getListOfFiles(
|
||||
self.formatWidgets[source_format][u'fileListWidget']))
|
||||
elif select_mode == SongFormatSelect.SingleFolder:
|
||||
importer = self.plugin.importSongs(source_format,
|
||||
folder=unicode(
|
||||
self.formatWidgets[source_format][u'filepathEdit'].text()))
|
||||
self.formatWidgets[source_format][u'fileListWidget']))
|
||||
importer.doImport()
|
||||
self.progressLabel.setText(WizardStrings.FinishedImport)
|
||||
|
||||
@ -460,6 +457,7 @@ class SongImportForm(OpenLPWizard):
|
||||
self.formatComboBox.addItem(u'')
|
||||
|
||||
def disablableWidget(self, page, obj_prefix):
|
||||
format = self.activeFormat
|
||||
self.disablableFormats.append(format)
|
||||
layout = QtGui.QVBoxLayout(page)
|
||||
layout.setMargin(0)
|
||||
@ -480,7 +478,6 @@ class SongImportForm(OpenLPWizard):
|
||||
importWidget = QtGui.QWidget(page)
|
||||
importWidget.setObjectName(obj_prefix + u'ImportWidget')
|
||||
layout.addWidget(importWidget)
|
||||
format = self.activeFormat
|
||||
self.formatWidgets[format][u'layout'] = layout
|
||||
self.formatWidgets[format][u'disabledWidget'] = disabledWidget
|
||||
self.formatWidgets[format][u'disabledLayout'] = disabledLayout
|
||||
|
@ -29,6 +29,7 @@ The :mod:`importer` modules provides the general song import functionality.
|
||||
"""
|
||||
import logging
|
||||
|
||||
from openlp.core.lib import translate
|
||||
from openlp.core.lib.ui import UiStrings
|
||||
from openlp.core.ui.wizard import WizardStrings
|
||||
from opensongimport import OpenSongImport
|
||||
@ -110,6 +111,14 @@ class SongFormat(object):
|
||||
SongFormat.WordsOfWorship
|
||||
]
|
||||
|
||||
class SongFormatSelect(object):
|
||||
"""
|
||||
This is a special enumeration class listing available file selection modes.
|
||||
"""
|
||||
SingleFile = 0
|
||||
MultipleFiles = 1
|
||||
SingleFolder = 2
|
||||
|
||||
class SongFormatAttr(object):
|
||||
"""
|
||||
This is a special static class that holds the attributes of each song format
|
||||
@ -194,7 +203,6 @@ class SongFormatAttr(object):
|
||||
'SongsPlugin.ImportWizardForm', 'OpenLP 2.0 Databases'))
|
||||
},
|
||||
SongFormat.OpenLP1: {
|
||||
class_: OpenLP1SongImport,
|
||||
name: UiStrings().OLPV1,
|
||||
prefix: u'openLP1',
|
||||
can_disable: True,
|
||||
@ -204,7 +212,6 @@ class SongFormatAttr(object):
|
||||
disabled_label_text: WizardStrings.NoSqlite
|
||||
},
|
||||
SongFormat.Generic: {
|
||||
class_: OooImport,
|
||||
name: translate('SongsPlugin.ImportWizardForm',
|
||||
'Generic Document/Presentation'),
|
||||
prefix: u'generic',
|
||||
@ -282,7 +289,6 @@ class SongFormatAttr(object):
|
||||
'SongShow Plus Song Files')
|
||||
},
|
||||
SongFormat.SongsOfFellowship: {
|
||||
class_: SofImport,
|
||||
name: u'Songs of Fellowship',
|
||||
prefix: u'songsOfFellowship',
|
||||
can_disable: True,
|
||||
@ -325,15 +331,17 @@ class SongFormatAttr(object):
|
||||
* >1 : Return tuple of requested attribute values.
|
||||
"""
|
||||
if not attributes:
|
||||
return SongFormat._attributes.get(format)
|
||||
return SongFormatAttr._attributes.get(format)
|
||||
elif len(attributes) == 1:
|
||||
default = _defaults.get(attributes[0])
|
||||
return SongFormat._attributes[format].get(attributes[0], default)
|
||||
default = SongFormatAttr._defaults.get(attributes[0])
|
||||
return SongFormatAttr._attributes[format].get(attributes[0],
|
||||
default)
|
||||
else:
|
||||
values = []
|
||||
for attr in attributes:
|
||||
default = _defaults.get(attr)
|
||||
values.append(SongFormat._attributes[format].get(attr, default))
|
||||
default = SongFormatAttr._defaults.get(attr)
|
||||
values.append(SongFormatAttr._attributes[format].get(attr,
|
||||
default))
|
||||
return tuple(values)
|
||||
|
||||
@staticmethod
|
||||
@ -341,22 +349,21 @@ class SongFormatAttr(object):
|
||||
"""
|
||||
Set specified song format attribute to the supplied value.
|
||||
"""
|
||||
SongFormat._attributes[format][attribute] = value
|
||||
SongFormatAttr._attributes[format][attribute] = value
|
||||
|
||||
class SongFormatSelect(object):
|
||||
"""
|
||||
This is a special enumeration class listing available file selection modes.
|
||||
"""
|
||||
SingleFile = 0
|
||||
MultipleFiles = 1
|
||||
SingleFolder = 2
|
||||
SongFormatAttr.set(SongFormat.OpenLP1, SongFormatAttr.availability, HAS_OPENLP1)
|
||||
if HAS_OPENLP1:
|
||||
SongFormatAttr.set(SongFormat.OpenLP1, SongFormatAttr.class_,
|
||||
OpenLP1SongImport)
|
||||
SongFormatAttr.set(SongFormat.SongsOfFellowship, SongFormatAttr.availability,
|
||||
HAS_SOF)
|
||||
if HAS_SOF:
|
||||
SongFormatAttr.set(SongFormat.SongsOfFellowship, SongFormatAttr.class_,
|
||||
SofImport)
|
||||
SongFormatAttr.set(SongFormat.Generic, SongFormatAttr.availability, HAS_OOO)
|
||||
if HAS_OOO:
|
||||
SongFormatAttr.set(SongFormat.Generic, SongFormatAttr.class_,
|
||||
OooImport)
|
||||
|
||||
SongFormatAttr.set(
|
||||
SongFormat.OpenLP1, SongFormatAttr.availability, HAS_OPENLP1)
|
||||
SongFormatAttr.set(
|
||||
SongFormat.SongsOfFellowship, SongFormatAttr.availability, HAS_SOF)
|
||||
SongFormatAttr.set(
|
||||
SongFormat.Generic, SongFormatAttr.availability, HAS_OOO)
|
||||
|
||||
__all__ = [u'SongFormat', u'SongFormatAttr', u'SongFormatSelect']
|
||||
__all__ = [u'SongFormat', u'SongFormatSelect', u'SongFormatAttr']
|
||||
|
||||
|
@ -34,7 +34,6 @@ import os
|
||||
|
||||
from openlp.core.lib import translate
|
||||
from openlp.plugins.songs.lib.songimport import SongImport
|
||||
from openlp.plugins.songs.lib.importer import SongFormat, SongFormatAttr
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@ -71,7 +70,6 @@ class PowerSongImport(SongImport):
|
||||
|
||||
* .song
|
||||
"""
|
||||
|
||||
@staticmethod
|
||||
def isValidSource(**kwargs):
|
||||
"""
|
||||
@ -91,6 +89,7 @@ class PowerSongImport(SongImport):
|
||||
"""
|
||||
Receive either a list of files or a folder (unicode) to import.
|
||||
"""
|
||||
from importer import SongFormat, SongFormatAttr
|
||||
PS_string = SongFormatAttr.get(SongFormat.PowerSong,
|
||||
SongFormatAttr.name)
|
||||
if isinstance(self.importSource, unicode):
|
||||
|
@ -55,7 +55,7 @@ class SongImport(QtCore.QObject):
|
||||
"""
|
||||
Override this method to validate the source prior to import.
|
||||
"""
|
||||
pass
|
||||
return True
|
||||
|
||||
def __init__(self, manager, **kwargs):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user