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