Bug #795068: Verse List in Song Editor did not resize properly

bzr-revno: 1928
Fixes: https://launchpad.net/bugs/795068
This commit is contained in:
Meinert Jordan 2012-04-02 23:11:41 +02:00 committed by Raoul Snyman
commit 1128b424e5
2 changed files with 22 additions and 8 deletions

View File

@ -69,12 +69,8 @@ class Ui_EditSongDialog(object):
self.lyricsLabel.setObjectName(u'lyricsLabel')
self.lyricsTabLayout.addWidget(self.lyricsLabel, 2, 0,
QtCore.Qt.AlignTop)
self.verseListWidget = QtGui.QTableWidget(self.lyricsTab)
self.verseListWidget.horizontalHeader().setVisible(False)
self.verseListWidget.horizontalHeader().setStretchLastSection(True)
self.verseListWidget.horizontalHeader().setMinimumSectionSize(16)
self.verseListWidget = SingleColumnTableWidget(self.lyricsTab)
self.verseListWidget.setAlternatingRowColors(True)
self.verseListWidget.setColumnCount(1)
self.verseListWidget.setSelectionBehavior(
QtGui.QAbstractItemView.SelectRows)
self.verseListWidget.setSelectionMode(
@ -373,3 +369,24 @@ def editSongDialogComboBox(parent, name):
comboBox.setInsertPolicy(QtGui.QComboBox.NoInsert)
comboBox.setObjectName(name)
return comboBox
class SingleColumnTableWidget(QtGui.QTableWidget):
"""
Class to for a single column table widget to use for the verse table widget.
"""
def __init__(self, parent):
"""
Constrctor
"""
QtGui.QTableWidget.__init__(self, parent)
self.horizontalHeader().setVisible(False)
self.setColumnCount(1)
def resizeEvent(self, event):
"""
Resize the first column together with the widget.
"""
QtGui.QTableWidget.resizeEvent(self, event)
if self.columnCount():
self.setColumnWidth(0, event.size().width())
self.resizeRowsToContents()

View File

@ -244,8 +244,6 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
self.themeComboBox, unicode(self.song.theme_name))
self.copyrightEdit.setText(
self.song.copyright if self.song.copyright else u'')
self.verseListWidget.clear()
self.verseListWidget.setRowCount(0)
self.commentsEdit.setPlainText(
self.song.comments if self.song.comments else u'')
self.CCLNumberEdit.setText(
@ -345,7 +343,6 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
row_def = u'%s%s' % (verse_tag, verse_def[1:])
row_label.append(row_def)
self.verseListWidget.setVerticalHeaderLabels(row_label)
self.verseListWidget.setColumnWidth(0, self.width)
self.verseListWidget.resizeRowsToContents()
self.verseListWidget.repaint()