fixed Verse Tag' column; clean up

This commit is contained in:
Andreas Preikschat 2011-03-17 13:32:45 +01:00
parent 84175d232b
commit e9bcab13de

View File

@ -297,7 +297,6 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
self.verseOrderEdit.setText(u' '.join(translated)) self.verseOrderEdit.setText(u' '.join(translated))
else: else:
self.verseOrderEdit.setText(u'') self.verseOrderEdit.setText(u'')
self.verseListWidget.resizeRowsToContents()
self.tagRows() self.tagRows()
# clear the results # clear the results
self.authorsListView.clear() self.authorsListView.clear()
@ -312,10 +311,8 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
topic_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(topic.id)) topic_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(topic.id))
self.topicsListView.addItem(topic_name) self.topicsListView.addItem(topic_name)
self.titleEdit.setFocus(QtCore.Qt.OtherFocusReason) self.titleEdit.setFocus(QtCore.Qt.OtherFocusReason)
# if not preview hide the preview button # Hide or show the preview button.
self.previewButton.setVisible(False) self.previewButton.setVisible(preview)
if preview:
self.previewButton.setVisible(True)
def tagRows(self): def tagRows(self):
""" """
@ -329,6 +326,9 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
row_def = u'%s%s' % (verse_tag, verse_def[1:]) row_def = u'%s%s' % (verse_tag, verse_def[1:])
row_label.append(row_def) row_label.append(row_def)
self.verseListWidget.setVerticalHeaderLabels(row_label) self.verseListWidget.setVerticalHeaderLabels(row_label)
self.verseListWidget.setColumnWidth(0, self.width)
self.verseListWidget.resizeRowsToContents()
self.verseListWidget.repaint()
def onAuthorAddButtonClicked(self): def onAuthorAddButtonClicked(self):
item = int(self.authorsComboBox.currentIndex()) item = int(self.authorsComboBox.currentIndex())
@ -453,9 +453,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
self.verseListWidget.setRowCount( self.verseListWidget.setRowCount(
self.verseListWidget.rowCount() + 1) self.verseListWidget.rowCount() + 1)
self.verseListWidget.setItem( self.verseListWidget.setItem(
int(self.verseListWidget.rowCount() - 1), 0, item) self.verseListWidget.rowCount() - 1, 0, item)
self.verseListWidget.setColumnWidth(0, self.width)
self.verseListWidget.resizeRowsToContents()
self.tagRows() self.tagRows()
def onVerseEditButtonClicked(self): def onVerseEditButtonClicked(self):
@ -482,8 +480,6 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
item = QtGui.QTableWidgetItem(tempList[row], 0) item = QtGui.QTableWidgetItem(tempList[row], 0)
item.setData(QtCore.Qt.UserRole, tempId[row]) item.setData(QtCore.Qt.UserRole, tempId[row])
self.verseListWidget.setItem(row, 0, item) self.verseListWidget.setItem(row, 0, item)
self.verseListWidget.resizeRowsToContents()
self.verseListWidget.repaint()
self.tagRows() self.tagRows()
def onVerseEditAllButtonClicked(self): def onVerseEditAllButtonClicked(self):
@ -500,7 +496,8 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
self.verse_form.setVerse(verse_list) self.verse_form.setVerse(verse_list)
else: else:
self.verse_form.setVerse(u'') self.verse_form.setVerse(u'')
if self.verse_form.exec_(): if not self.verse_form.exec_():
return
verse_list = self.verse_form.getVerseAll() verse_list = self.verse_form.getVerseAll()
verse_list = unicode(verse_list.replace(u'\r\n', u'\n')) verse_list = unicode(verse_list.replace(u'\r\n', u'\n'))
self.verseListWidget.clear() self.verseListWidget.clear()
@ -508,7 +505,8 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
for row in self.findVerseSplit.split(verse_list): for row in self.findVerseSplit.split(verse_list):
for match in row.split(u'---['): for match in row.split(u'---['):
for count, parts in enumerate(match.split(u']---\n')): for count, parts in enumerate(match.split(u']---\n')):
if len(parts) > 1: if len(parts) <= 1:
continue
if count == 0: if count == 0:
# handling carefully user inputted versetags # handling carefully user inputted versetags
separator = parts.find(u':') separator = parts.find(u':')
@ -518,8 +516,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
else: else:
verse_name = parts verse_name = parts
verse_num = u'1' verse_num = u'1'
verse_index = \ verse_index = VerseType.from_loose_input(verse_name)
VerseType.from_loose_input(verse_name)
verse_tag = VerseType.Tags[verse_index] verse_tag = VerseType.Tags[verse_index]
# Later we need to handle v1a as well. # Later we need to handle v1a as well.
#regex = re.compile(r'(\d+\w.)') #regex = re.compile(r'(\d+\w.)')
@ -539,11 +536,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
self.verseListWidget.setRowCount( self.verseListWidget.setRowCount(
self.verseListWidget.rowCount() + 1) self.verseListWidget.rowCount() + 1)
self.verseListWidget.setItem( self.verseListWidget.setItem(
int(self.verseListWidget.rowCount() - 1), self.verseListWidget.rowCount() - 1, 0, item)
0, item)
self.verseListWidget.setColumnWidth(0, self.width)
self.verseListWidget.resizeRowsToContents()
self.verseListWidget.repaint()
self.tagRows() self.tagRows()
self.verseEditButton.setEnabled(False) self.verseEditButton.setEnabled(False)
self.verseDeleteButton.setEnabled(False) self.verseDeleteButton.setEnabled(False)
@ -753,7 +746,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
self.song.theme_name = theme_name self.song.theme_name = theme_name
else: else:
self.song.theme_name = None self.song.theme_name = None
self.processLyrics() self._processLyrics()
self.song.authors = [] self.song.authors = []
for row in range(self.authorsListView.count()): for row in range(self.authorsListView.count()):
item = self.authorsListView.item(row) item = self.authorsListView.item(row)
@ -769,12 +762,12 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
if not preview: if not preview:
self.song = None self.song = None
def processLyrics(self): def _processLyrics(self):
""" """
Process the lyric data entered by the user into the OpenLP XML format. Process the lyric data entered by the user into the OpenLP XML format.
""" """
# This method must only be run after the self.song = Song() assignment. # This method must only be run after the self.song = Song() assignment.
log.debug(u'processLyrics') log.debug(u'_processLyrics')
try: try:
sxml = SongXML() sxml = SongXML()
multiple = [] multiple = []