Removed obj_prefix (old code from r1055 and even < r990)

This commit is contained in:
Samuel Findlay 2012-06-01 00:24:24 +10:00
parent 606da7ab76
commit d9ed9aaa5c
2 changed files with 26 additions and 40 deletions

View File

@ -401,36 +401,34 @@ class SongImportForm(OpenLPWizard):
def addFileSelectItem(self): def addFileSelectItem(self):
format = self.currentFormat format = self.currentFormat
prefix, obj_prefix, can_disable, select_mode = SongFormatAttr.get( prefix, can_disable, select_mode = SongFormatAttr.get(
format, SongFormatAttr.prefix, SongFormatAttr.obj_prefix, format, SongFormatAttr.prefix, SongFormatAttr.can_disable,
SongFormatAttr.can_disable, SongFormatAttr.select_mode) SongFormatAttr.select_mode)
if not obj_prefix:
obj_prefix = prefix
page = QtGui.QWidget() page = QtGui.QWidget()
page.setObjectName(obj_prefix + u'Page') page.setObjectName(prefix + u'Page')
if can_disable: if can_disable:
importWidget = self.disablableWidget(page, obj_prefix) importWidget = self.disablableWidget(page, prefix)
else: else:
importWidget = page importWidget = page
importLayout = QtGui.QVBoxLayout(importWidget) importLayout = QtGui.QVBoxLayout(importWidget)
importLayout.setMargin(0) importLayout.setMargin(0)
importLayout.setObjectName(obj_prefix + u'ImportLayout') importLayout.setObjectName(prefix + u'ImportLayout')
if select_mode == SongFormatSelect.SingleFile or \ if select_mode == SongFormatSelect.SingleFile or \
select_mode == SongFormatSelect.SingleFolder: select_mode == SongFormatSelect.SingleFolder:
filepathLayout = QtGui.QHBoxLayout() filepathLayout = QtGui.QHBoxLayout()
filepathLayout.setObjectName(obj_prefix + u'FilepathLayout') filepathLayout.setObjectName(prefix + u'FilepathLayout')
filepathLabel = QtGui.QLabel(importWidget) filepathLabel = QtGui.QLabel(importWidget)
filepathLabel.setObjectName(obj_prefix + u'FilepathLabel') filepathLabel.setObjectName(prefix + u'FilepathLabel')
filepathLayout.addWidget(filepathLabel) filepathLayout.addWidget(filepathLabel)
filepathSpacer = QtGui.QSpacerItem(0, 0, QtGui.QSizePolicy.Fixed, filepathSpacer = QtGui.QSpacerItem(0, 0, QtGui.QSizePolicy.Fixed,
QtGui.QSizePolicy.Fixed) QtGui.QSizePolicy.Fixed)
filepathLayout.addSpacerItem(filepathSpacer) filepathLayout.addSpacerItem(filepathSpacer)
filepathEdit = QtGui.QLineEdit(importWidget) filepathEdit = QtGui.QLineEdit(importWidget)
filepathEdit.setObjectName(obj_prefix + u'FilepathEdit') filepathEdit.setObjectName(prefix + u'FilepathEdit')
filepathLayout.addWidget(filepathEdit) filepathLayout.addWidget(filepathEdit)
browseButton = QtGui.QToolButton(importWidget) browseButton = QtGui.QToolButton(importWidget)
browseButton.setIcon(self.openIcon) browseButton.setIcon(self.openIcon)
browseButton.setObjectName(obj_prefix + u'BrowseButton') browseButton.setObjectName(prefix + u'BrowseButton')
filepathLayout.addWidget(browseButton) filepathLayout.addWidget(browseButton)
importLayout.addLayout(filepathLayout) importLayout.addLayout(filepathLayout)
importLayout.addSpacerItem(self.stackSpacer) importLayout.addSpacerItem(self.stackSpacer)
@ -443,18 +441,18 @@ class SongImportForm(OpenLPWizard):
fileListWidget = QtGui.QListWidget(importWidget) fileListWidget = QtGui.QListWidget(importWidget)
fileListWidget.setSelectionMode( fileListWidget.setSelectionMode(
QtGui.QAbstractItemView.ExtendedSelection) QtGui.QAbstractItemView.ExtendedSelection)
fileListWidget.setObjectName(obj_prefix + u'FileListWidget') fileListWidget.setObjectName(prefix + u'FileListWidget')
importLayout.addWidget(fileListWidget) importLayout.addWidget(fileListWidget)
buttonLayout = QtGui.QHBoxLayout() buttonLayout = QtGui.QHBoxLayout()
buttonLayout.setObjectName(obj_prefix + u'ButtonLayout') buttonLayout.setObjectName(prefix + u'ButtonLayout')
addButton = QtGui.QPushButton(importWidget) addButton = QtGui.QPushButton(importWidget)
addButton.setIcon(self.openIcon) addButton.setIcon(self.openIcon)
addButton.setObjectName(obj_prefix + u'AddButton') addButton.setObjectName(prefix + u'AddButton')
buttonLayout.addWidget(addButton) buttonLayout.addWidget(addButton)
buttonLayout.addStretch() buttonLayout.addStretch()
removeButton = QtGui.QPushButton(importWidget) removeButton = QtGui.QPushButton(importWidget)
removeButton.setIcon(self.deleteIcon) removeButton.setIcon(self.deleteIcon)
removeButton.setObjectName(obj_prefix + u'RemoveButton') removeButton.setObjectName(prefix + u'RemoveButton')
buttonLayout.addWidget(removeButton) buttonLayout.addWidget(removeButton)
importLayout.addLayout(buttonLayout) importLayout.addLayout(buttonLayout)
self.formatWidgets[format][u'fileListWidget'] = fileListWidget self.formatWidgets[format][u'fileListWidget'] = fileListWidget
@ -466,27 +464,27 @@ class SongImportForm(OpenLPWizard):
self.formatWidgets[format][u'importLayout'] = importLayout self.formatWidgets[format][u'importLayout'] = importLayout
self.formatComboBox.addItem(u'') self.formatComboBox.addItem(u'')
def disablableWidget(self, page, obj_prefix): def disablableWidget(self, page, prefix):
format = self.currentFormat format = self.currentFormat
self.disablableFormats.append(format) self.disablableFormats.append(format)
layout = QtGui.QVBoxLayout(page) layout = QtGui.QVBoxLayout(page)
layout.setMargin(0) layout.setMargin(0)
layout.setSpacing(0) layout.setSpacing(0)
layout.setObjectName(obj_prefix + u'Layout') layout.setObjectName(prefix + u'Layout')
disabledWidget = QtGui.QWidget(page) disabledWidget = QtGui.QWidget(page)
disabledWidget.setVisible(False) disabledWidget.setVisible(False)
disabledWidget.setObjectName(obj_prefix + u'DisabledWidget') disabledWidget.setObjectName(prefix + u'DisabledWidget')
disabledLayout = QtGui.QVBoxLayout(disabledWidget) disabledLayout = QtGui.QVBoxLayout(disabledWidget)
disabledLayout.setMargin(0) disabledLayout.setMargin(0)
disabledLayout.setObjectName(obj_prefix + u'DisabledLayout') disabledLayout.setObjectName(prefix + u'DisabledLayout')
disabledLabel = QtGui.QLabel(disabledWidget) disabledLabel = QtGui.QLabel(disabledWidget)
disabledLabel.setWordWrap(True) disabledLabel.setWordWrap(True)
disabledLabel.setObjectName(obj_prefix + u'DisabledLabel') disabledLabel.setObjectName(prefix + u'DisabledLabel')
disabledLayout.addWidget(disabledLabel) disabledLayout.addWidget(disabledLabel)
disabledLayout.addSpacerItem(self.stackSpacer) disabledLayout.addSpacerItem(self.stackSpacer)
layout.addWidget(disabledWidget) layout.addWidget(disabledWidget)
importWidget = QtGui.QWidget(page) importWidget = QtGui.QWidget(page)
importWidget.setObjectName(obj_prefix + u'ImportWidget') importWidget.setObjectName(prefix + u'ImportWidget')
layout.addWidget(importWidget) layout.addWidget(importWidget)
self.formatWidgets[format][u'layout'] = layout self.formatWidgets[format][u'layout'] = layout
self.formatWidgets[format][u'disabledWidget'] = disabledWidget self.formatWidgets[format][u'disabledWidget'] = disabledWidget

View File

@ -133,8 +133,6 @@ class SongFormatAttr(object):
See ``SongImportForm.addFileSelectItem()``. See ``SongImportForm.addFileSelectItem()``.
Optional attributes for each song format: Optional attributes for each song format:
* ``obj_prefix`` Alternate prefix for objects.
See ``SongImportForm.addFileSelectItem()``.
* ``can_disable`` Whether song format is disablable. * ``can_disable`` Whether song format is disablable.
* ``availability`` Whether song format is available. * ``availability`` Whether song format is available.
* ``select_mode`` Whether format accepts single file, multiple files, or * ``select_mode`` Whether format accepts single file, multiple files, or
@ -154,11 +152,10 @@ class SongFormatAttr(object):
name = 1 name = 1
prefix = 2 prefix = 2
# Optional attributes # Optional attributes
obj_prefix = 10 can_disable = 10
can_disable = 11 availability = 11
availability = 12 select_mode = 12
select_mode = 13 filter = 13
filter = 14
# Optional/custom text values # Optional/custom text values
combo_box_text = 20 combo_box_text = 20
disabled_label_text = 21 disabled_label_text = 21
@ -167,7 +164,6 @@ class SongFormatAttr(object):
# Set optional attribute defaults # Set optional attribute defaults
_defaults = { _defaults = {
obj_prefix: None,
can_disable: False, can_disable: False,
availability: True, availability: True,
select_mode: SongFormatSelect.MultipleFiles, select_mode: SongFormatSelect.MultipleFiles,
@ -184,16 +180,10 @@ class SongFormatAttr(object):
class_: OpenLyricsImport, class_: OpenLyricsImport,
name: u'OpenLyrics', name: u'OpenLyrics',
prefix: u'openLyrics', prefix: u'openLyrics',
obj_prefix: u'OpenLyrics',
can_disable: True,
filter: u'%s (*.xml)' % translate('SongsPlugin.ImportWizardForm', filter: u'%s (*.xml)' % translate('SongsPlugin.ImportWizardForm',
'OpenLyrics Files'), 'OpenLyrics Files'),
combo_box_text: translate('SongsPlugin.ImportWizardForm', combo_box_text: translate('SongsPlugin.ImportWizardForm',
'OpenLyrics or OpenLP 2.0 Exported Song'), 'OpenLyrics or OpenLP 2.0 Exported Song')
disabled_label_text: translate('SongsPlugin.ImportWizardForm',
'The OpenLyrics importer has not yet been developed, but as '
'you can see, we are still intending to do so. Hopefully it '
'will be in the next release.')
}, },
SongFormat.OpenLP2: { SongFormat.OpenLP2: {
class_: OpenLPSongImport, class_: OpenLPSongImport,
@ -263,8 +253,7 @@ class SongFormatAttr(object):
SongFormat.OpenSong: { SongFormat.OpenSong: {
class_: OpenSongImport, class_: OpenSongImport,
name: WizardStrings.OS, name: WizardStrings.OS,
prefix: u'openSong', prefix: u'openSong'
obj_prefix: u'OpenSong'
}, },
SongFormat.PowerSong: { SongFormat.PowerSong: {
class_: PowerSongImport, class_: PowerSongImport,
@ -309,7 +298,6 @@ class SongFormatAttr(object):
# class_: CSVImport, # class_: CSVImport,
# name: WizardStrings.CSV, # name: WizardStrings.CSV,
# prefix: u'csv', # prefix: u'csv',
# obj_prefix: u'CSV',
# select_mode: SongFormatSelect.SingleFile # select_mode: SongFormatSelect.SingleFile
} }
} }