From 84ee153fecf562ba71c214d232c161b0697ae47e Mon Sep 17 00:00:00 2001 From: M2j Date: Mon, 2 Apr 2012 15:27:08 +0200 Subject: [PATCH] Bug #795068: Verse List in Song Editor did not resize properly --- openlp/plugins/songs/forms/editsongdialog.py | 27 ++++++++++++++++---- openlp/plugins/songs/forms/editsongform.py | 3 --- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/openlp/plugins/songs/forms/editsongdialog.py b/openlp/plugins/songs/forms/editsongdialog.py index 747541952..1a1517fd3 100644 --- a/openlp/plugins/songs/forms/editsongdialog.py +++ b/openlp/plugins/songs/forms/editsongdialog.py @@ -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() diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 468139164..2253ed226 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -248,8 +248,6 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): self.copyrightEdit.setText(self.song.copyright) else: self.copyrightEdit.setText(u'') - self.verseListWidget.clear() - self.verseListWidget.setRowCount(0) if self.song.comments: self.commentsEdit.setPlainText(self.song.comments) else: @@ -355,7 +353,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()