-'verse' -> 'slide' -buttons name fixes

This commit is contained in:
Andreas Preikschat 2010-10-10 16:23:00 +02:00
parent 144060a74b
commit bab38de43e
4 changed files with 67 additions and 65 deletions

View File

@ -42,6 +42,7 @@ class Ui_CustomEditDialog(object):
self.themeLabel.setObjectName(u'themeLabel') self.themeLabel.setObjectName(u'themeLabel')
self.horizontalLayout3.addWidget(self.themeLabel) self.horizontalLayout3.addWidget(self.themeLabel)
self.themeComboBox = QtGui.QComboBox(customEditDialog) self.themeComboBox = QtGui.QComboBox(customEditDialog)
self.themeLabel.setBuddy(self.themeComboBox)
self.themeComboBox.setObjectName(u'themeComboBox') self.themeComboBox.setObjectName(u'themeComboBox')
self.horizontalLayout3.addWidget(self.themeComboBox) self.horizontalLayout3.addWidget(self.themeComboBox)
self.gridLayout.addLayout(self.horizontalLayout3, 2, 0, 1, 1) self.gridLayout.addLayout(self.horizontalLayout3, 2, 0, 1, 1)
@ -51,6 +52,7 @@ class Ui_CustomEditDialog(object):
self.creditLabel.setObjectName(u'creditLabel') self.creditLabel.setObjectName(u'creditLabel')
self.horizontalLayout2.addWidget(self.creditLabel) self.horizontalLayout2.addWidget(self.creditLabel)
self.creditEdit = QtGui.QLineEdit(customEditDialog) self.creditEdit = QtGui.QLineEdit(customEditDialog)
self.creditLabel.setBuddy(self.creditEdit)
self.creditEdit.setObjectName(u'creditEdit') self.creditEdit.setObjectName(u'creditEdit')
self.horizontalLayout2.addWidget(self.creditEdit) self.horizontalLayout2.addWidget(self.creditEdit)
self.gridLayout.addLayout(self.horizontalLayout2, 3, 0, 1, 1) self.gridLayout.addLayout(self.horizontalLayout2, 3, 0, 1, 1)
@ -61,10 +63,10 @@ class Ui_CustomEditDialog(object):
self.gridLayout.addWidget(self.buttonBox, 4, 0, 1, 1) self.gridLayout.addWidget(self.buttonBox, 4, 0, 1, 1)
self.horizontalLayout4 = QtGui.QHBoxLayout() self.horizontalLayout4 = QtGui.QHBoxLayout()
self.horizontalLayout4.setObjectName(u'horizontalLayout4') self.horizontalLayout4.setObjectName(u'horizontalLayout4')
self.verseListView = QtGui.QListWidget(customEditDialog) self.slideListView = QtGui.QListWidget(customEditDialog)
self.verseListView.setAlternatingRowColors(True) self.slideListView.setAlternatingRowColors(True)
self.verseListView.setObjectName(u'verseListView') self.slideListView.setObjectName(u'slideListView')
self.horizontalLayout4.addWidget(self.verseListView) self.horizontalLayout4.addWidget(self.slideListView)
self.verticalLayout = QtGui.QVBoxLayout() self.verticalLayout = QtGui.QVBoxLayout()
self.verticalLayout.setObjectName(u'verticalLayout') self.verticalLayout.setObjectName(u'verticalLayout')
self.addButton = QtGui.QPushButton(customEditDialog) self.addButton = QtGui.QPushButton(customEditDialog)
@ -104,6 +106,7 @@ class Ui_CustomEditDialog(object):
self.titleLabel.setObjectName(u'titleLabel') self.titleLabel.setObjectName(u'titleLabel')
self.horizontalLayout.addWidget(self.titleLabel) self.horizontalLayout.addWidget(self.titleLabel)
self.titleEdit = QtGui.QLineEdit(customEditDialog) self.titleEdit = QtGui.QLineEdit(customEditDialog)
self.titleLabel.setBuddy(self.titleEdit)
self.titleEdit.setObjectName(u'titleEdit') self.titleEdit.setObjectName(u'titleEdit')
self.horizontalLayout.addWidget(self.titleEdit) self.horizontalLayout.addWidget(self.titleEdit)
self.gridLayout.addLayout(self.horizontalLayout, 0, 0, 1, 1) self.gridLayout.addLayout(self.horizontalLayout, 0, 0, 1, 1)
@ -126,22 +129,22 @@ class Ui_CustomEditDialog(object):
self.titleLabel.setText( self.titleLabel.setText(
translate('CustomPlugin.EditCustomForm', '&Title:')) translate('CustomPlugin.EditCustomForm', '&Title:'))
self.addButton.setText( self.addButton.setText(
translate('CustomPlugin.EditCustomForm', 'Add New')) translate('CustomPlugin.EditCustomForm', '&Add'))
self.addButton.setToolTip( self.addButton.setToolTip(
translate('CustomPlugin.EditCustomForm', 'Add a new slide at ' translate('CustomPlugin.EditCustomForm', 'Add a new slide at '
'bottom.')) 'bottom.'))
self.editButton.setText( self.editButton.setText(
translate('CustomPlugin.EditCustomForm', 'Edit')) translate('CustomPlugin.EditCustomForm', '&Edit'))
self.editButton.setToolTip( self.editButton.setToolTip(
translate('CustomPlugin.EditCustomForm', 'Edit the selected ' translate('CustomPlugin.EditCustomForm', 'Edit the selected '
'slide.')) 'slide.'))
self.editAllButton.setText( self.editAllButton.setText(
translate('CustomPlugin.EditCustomForm', 'Edit All')) translate('CustomPlugin.EditCustomForm', 'Ed&it All'))
self.editAllButton.setToolTip( self.editAllButton.setToolTip(
translate('CustomPlugin.EditCustomForm', 'Edit all the slides at ' translate('CustomPlugin.EditCustomForm', 'Edit all the slides at '
'once.')) 'once.'))
self.deleteButton.setText( self.deleteButton.setText(
translate('CustomPlugin.EditCustomForm', 'Delete')) translate('CustomPlugin.EditCustomForm', '&Delete'))
self.deleteButton.setToolTip( self.deleteButton.setToolTip(
translate('CustomPlugin.EditCustomForm', 'Delete the selected ' translate('CustomPlugin.EditCustomForm', 'Delete the selected '
'slide.')) 'slide.'))

View File

@ -68,9 +68,9 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog):
QtCore.SIGNAL(u'pressed()'), self.onUpButtonPressed) QtCore.SIGNAL(u'pressed()'), self.onUpButtonPressed)
QtCore.QObject.connect(self.downButton, QtCore.QObject.connect(self.downButton,
QtCore.SIGNAL(u'pressed()'), self.onDownButtonPressed) QtCore.SIGNAL(u'pressed()'), self.onDownButtonPressed)
QtCore.QObject.connect(self.verseListView, QtCore.QObject.connect(self.slideListView,
QtCore.SIGNAL(u'itemClicked(QListWidgetItem*)'), QtCore.SIGNAL(u'itemClicked(QListWidgetItem*)'),
self.onVerseListViewPressed) self.onSlideListViewPressed)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'theme_update_list'), self.loadThemes) QtCore.SIGNAL(u'theme_update_list'), self.loadThemes)
# Create other objects and forms. # Create other objects and forms.
@ -91,7 +91,7 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog):
self.editAllButton.setEnabled(True) self.editAllButton.setEnabled(True)
self.titleEdit.setText(u'') self.titleEdit.setText(u'')
self.creditEdit.setText(u'') self.creditEdit.setText(u'')
self.verseListView.clear() self.slideListView.clear()
# Make sure we have a new item. # Make sure we have a new item.
self.customSlide = CustomSlide() self.customSlide = CustomSlide()
@ -119,9 +119,9 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog):
self.titleEdit.setText(self.customSlide.title) self.titleEdit.setText(self.customSlide.title)
self.creditEdit.setText(self.customSlide.credits) self.creditEdit.setText(self.customSlide.credits)
customXML = CustomXMLParser(self.customSlide.text) customXML = CustomXMLParser(self.customSlide.text)
verseList = customXML.get_verses() slideList = customXML.get_verses()
for verse in verseList: for slide in slideList:
self.verseListView.addItem(verse[1]) self.slideListView.addItem(slide[1])
theme = self.customSlide.theme_name theme = self.customSlide.theme_name
id = self.themeComboBox.findText(theme, QtCore.Qt.MatchExactly) id = self.themeComboBox.findText(theme, QtCore.Qt.MatchExactly)
if id == -1: if id == -1:
@ -158,9 +158,9 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog):
sxml.new_document() sxml.new_document()
sxml.add_lyrics_to_song() sxml.add_lyrics_to_song()
count = 1 count = 1
for i in range(0, self.verseListView.count()): for i in range(0, self.slideListView.count()):
sxml.add_verse_to_lyrics(u'custom', unicode(count), sxml.add_verse_to_lyrics(u'custom', unicode(count),
unicode(self.verseListView.item(i).text())) unicode(self.slideListView.item(i).text()))
count += 1 count += 1
self.customSlide.title = unicode(self.titleEdit.displayText(), u'utf-8') self.customSlide.title = unicode(self.titleEdit.displayText(), u'utf-8')
self.customSlide.text = unicode(sxml.extract_xml(), u'utf-8') self.customSlide.text = unicode(sxml.extract_xml(), u'utf-8')
@ -171,21 +171,21 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog):
return self.custommanager.save_object(self.customSlide) return self.custommanager.save_object(self.customSlide)
def onUpButtonPressed(self): def onUpButtonPressed(self):
selectedRow = self.verseListView.currentRow() selectedRow = self.slideListView.currentRow()
if selectedRow != 0: if selectedRow != 0:
qw = self.verseListView.takeItem(selectedRow) qw = self.slideListView.takeItem(selectedRow)
self.verseListView.insertItem(selectedRow - 1, qw) self.slideListView.insertItem(selectedRow - 1, qw)
self.verseListView.setCurrentRow(selectedRow - 1) self.slideListView.setCurrentRow(selectedRow - 1)
def onDownButtonPressed(self): def onDownButtonPressed(self):
selectedRow = self.verseListView.currentRow() selectedRow = self.slideListView.currentRow()
# zero base arrays # zero base arrays
if selectedRow != self.verseListView.count() - 1: if selectedRow != self.slideListView.count() - 1:
qw = self.verseListView.takeItem(selectedRow) qw = self.slideListView.takeItem(selectedRow)
self.verseListView.insertItem(selectedRow + 1, qw) self.slideListView.insertItem(selectedRow + 1, qw)
self.verseListView.setCurrentRow(selectedRow + 1) self.slideListView.setCurrentRow(selectedRow + 1)
def onVerseListViewPressed(self, item): def onSlideListViewPressed(self, item):
self.deleteButton.setEnabled(True) self.deleteButton.setEnabled(True)
self.editButton.setEnabled(True) self.editButton.setEnabled(True)
@ -193,32 +193,32 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog):
self.slide_form.setText(u'') self.slide_form.setText(u'')
if self.slide_form.exec_(): if self.slide_form.exec_():
for slide in self.slide_form.getText(): for slide in self.slide_form.getText():
self.verseListView.addItem(slide) self.slideListView.addItem(slide)
self.editAllButton.setEnabled(True) self.editAllButton.setEnabled(True)
def onEditButtonPressed(self): def onEditButtonPressed(self):
self.slide_form.setText(self.verseListView.currentItem().text()) self.slide_form.setText(self.slideListView.currentItem().text())
if self.slide_form.exec_(): if self.slide_form.exec_():
self.updateVerseList(self.slide_form.getText()) self.updateSlideList(self.slide_form.getText())
def onEditAllButtonPressed(self): def onEditAllButtonPressed(self):
""" """
Edits all slides. Edits all slides.
""" """
if self.verseListView.count() > 0: if self.slideListView.count() > 0:
verse_list = u'' slide_list = u''
for row in range(0, self.verseListView.count()): for row in range(0, self.slideListView.count()):
item = self.verseListView.item(row) item = self.slideListView.item(row)
verse_list += item.text() slide_list += item.text()
if row != self.verseListView.count() - 1: if row != self.slideListView.count() - 1:
verse_list += u'\n[---]\n' slide_list += u'\n[---]\n'
self.slide_form.setText(verse_list) self.slide_form.setText(slide_list)
if self.slide_form.exec_(): if self.slide_form.exec_():
self.updateVerseList(self.slide_form.getText(), True) self.updateSlideList(self.slide_form.getText(), True)
def updateVerseList(self, slides, edit_all=False): def updateSlideList(self, slides, edit_all=False):
""" """
Updates the verse list (self.verseListView) after editing slides. Updates the slide list after editing slides.
``slides`` ``slides``
A list of all slides which have been edited. A list of all slides which have been edited.
@ -227,32 +227,32 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog):
Indicates if all slides or only one slide has been edited. Indicates if all slides or only one slide has been edited.
""" """
if len(slides) == 1: if len(slides) == 1:
self.verseListView.currentItem().setText(slides[0]) self.slideListView.currentItem().setText(slides[0])
else: else:
if edit_all: if edit_all:
self.verseListView.clear() self.slideListView.clear()
for slide in slides: for slide in slides:
self.verseListView.addItem(slide) self.slideListView.addItem(slide)
else: else:
old_slides = [] old_slides = []
old_row = self.verseListView.currentRow() old_row = self.slideListView.currentRow()
# Create a list with all (old/unedited) slides. # Create a list with all (old/unedited) slides.
old_slides = [self.verseListView.item(row).text() for row in \ old_slides = [self.slideListView.item(row).text() for row in \
range(0, self.verseListView.count())] range(0, self.slideListView.count())]
self.verseListView.clear() self.slideListView.clear()
old_slides.pop(old_row) old_slides.pop(old_row)
# Insert all slides in the old_slides list, to make the list complete. # Insert all slides in the old_slides list, to make the list complete.
for slide in slides: for slide in slides:
old_slides.insert(old_row, slide) old_slides.insert(old_row, slide)
for slide in old_slides: for slide in old_slides:
self.verseListView.addItem(slide) self.slideListView.addItem(slide)
self.verseListView.repaint() self.slideListView.repaint()
def onDeleteButtonPressed(self): def onDeleteButtonPressed(self):
self.verseListView.takeItem(self.verseListView.currentRow()) self.slideListView.takeItem(self.slideListView.currentRow())
self.editButton.setEnabled(True) self.editButton.setEnabled(True)
self.editAllButton.setEnabled(True) self.editAllButton.setEnabled(True)
if self.verseListView.count() == 0: if self.slideListView.count() == 0:
self.deleteButton.setEnabled(False) self.deleteButton.setEnabled(False)
self.editButton.setEnabled(False) self.editButton.setEnabled(False)
self.editAllButton.setEnabled(False) self.editAllButton.setEnabled(False)
@ -267,7 +267,7 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog):
return False, translate('CustomPlugin.EditCustomForm', return False, translate('CustomPlugin.EditCustomForm',
'You need to type in a title.') 'You need to type in a title.')
# We must have one slide. # We must have one slide.
if self.verseListView.count() == 0: if self.slideListView.count() == 0:
return False, translate('CustomPlugin.EditCustomForm', return False, translate('CustomPlugin.EditCustomForm',
'You need to add at least one slide') 'You need to add at least one slide')
return True, u'' return True, u''

View File

@ -38,9 +38,9 @@ class Ui_CustomSlideEditDialog(object):
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel | self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel |
QtGui.QDialogButtonBox.Save) QtGui.QDialogButtonBox.Save)
self.buttonBox.setObjectName(u'buttonBox') self.buttonBox.setObjectName(u'buttonBox')
self.verseTextEdit = QtGui.QTextEdit(customSlideEditDialog) self.slideTextEdit = QtGui.QTextEdit(customSlideEditDialog)
self.verseTextEdit.setGeometry(QtCore.QRect(8, 8, 458, 349)) self.slideTextEdit.setGeometry(QtCore.QRect(8, 8, 458, 349))
self.verseTextEdit.setObjectName(u'verseTextEdit') self.slideTextEdit.setObjectName(u'slideTextEdit')
self.splitButton = QtGui.QPushButton(customSlideEditDialog) self.splitButton = QtGui.QPushButton(customSlideEditDialog)
self.splitButton.setGeometry(QtCore.QRect(380, 370, 85, 27)) self.splitButton.setGeometry(QtCore.QRect(380, 370, 85, 27))
self.splitButton.setObjectName(u'splitButton') self.splitButton.setObjectName(u'splitButton')

View File

@ -48,30 +48,29 @@ class EditCustomSlideForm(QtGui.QDialog, Ui_CustomSlideEditDialog):
QtCore.QObject.connect(self.splitButton, QtCore.QObject.connect(self.splitButton,
QtCore.SIGNAL(u'pressed()'), self.onSplitButtonPressed) QtCore.SIGNAL(u'pressed()'), self.onSplitButtonPressed)
def setText(self, text): def setText(self, text):
""" """
Set the text for verseTextEdit. Set the text for slideTextEdit.
``text`` ``text``
The text (unicode). The text (unicode).
""" """
self.verseTextEdit.clear() self.slideTextEdit.clear()
if text: if text:
self.verseTextEdit.setPlainText(text) self.slideTextEdit.setPlainText(text)
self.verseTextEdit.setFocus() self.slideTextEdit.setFocus()
def getText(self): def getText(self):
""" """
Returns a list with all slides. Returns a list with all slides.
""" """
return self.verseTextEdit.toPlainText().split(u'\n[---]\n') return self.slideTextEdit.toPlainText().split(u'\n[---]\n')
def onSplitButtonPressed(self): def onSplitButtonPressed(self):
""" """
Splits a slide in two slides. Splits a slide in two slides.
""" """
if self.verseTextEdit.textCursor().columnNumber() != 0: if self.slideTextEdit.textCursor().columnNumber() != 0:
self.verseTextEdit.insertPlainText(u'\n') self.slideTextEdit.insertPlainText(u'\n')
self.verseTextEdit.insertPlainText(u'[---]\n' ) self.slideTextEdit.insertPlainText(u'[---]\n' )
self.verseTextEdit.setFocus() self.slideTextEdit.setFocus()