← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~googol-hush/openlp/trivial2 into lp:openlp

 

Andreas Preikschat has proposed merging lp:~googol-hush/openlp/trivial2 into lp:openlp.

Requested reviews:
  OpenLP Core (openlp-core)

For more details, see:
https://code.launchpad.net/~googol-hush/openlp/trivial2/+merge/53867

Hello

- save some indents to make code more readable
- fixed the "verse tag" column resizing after saving verses in the "Edit All" dialog. (The "Verse Tag" column becomes smaller and then becomes as large as normal again. I do not know if you will be able to reproduce this... Here you see this just happening while repainting the screen: http://img585.imageshack.us/img585/4327/bildschirmfoto170320111.png)
-- 
https://code.launchpad.net/~googol-hush/openlp/trivial2/+merge/53867
Your team OpenLP Core is requested to review the proposed merge of lp:~googol-hush/openlp/trivial2 into lp:openlp.
=== modified file 'openlp/plugins/songs/forms/editsongform.py'
--- openlp/plugins/songs/forms/editsongform.py	2011-03-15 20:12:28 +0000
+++ openlp/plugins/songs/forms/editsongform.py	2011-03-17 17:59:26 +0000
@@ -297,7 +297,6 @@
             self.verseOrderEdit.setText(u' '.join(translated))
         else:
             self.verseOrderEdit.setText(u'')
-        self.verseListWidget.resizeRowsToContents()
         self.tagRows()
         # clear the results
         self.authorsListView.clear()
@@ -312,10 +311,8 @@
             topic_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(topic.id))
             self.topicsListView.addItem(topic_name)
         self.titleEdit.setFocus(QtCore.Qt.OtherFocusReason)
-        # if not preview hide the preview button
-        self.previewButton.setVisible(False)
-        if preview:
-            self.previewButton.setVisible(True)
+        # Hide or show the preview button.
+        self.previewButton.setVisible(preview)
 
     def tagRows(self):
         """
@@ -329,6 +326,9 @@
             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()
 
     def onAuthorAddButtonClicked(self):
         item = int(self.authorsComboBox.currentIndex())
@@ -453,9 +453,7 @@
             self.verseListWidget.setRowCount(
                 self.verseListWidget.rowCount() + 1)
             self.verseListWidget.setItem(
-                int(self.verseListWidget.rowCount() - 1), 0, item)
-        self.verseListWidget.setColumnWidth(0, self.width)
-        self.verseListWidget.resizeRowsToContents()
+                self.verseListWidget.rowCount() - 1, 0, item)
         self.tagRows()
 
     def onVerseEditButtonClicked(self):
@@ -482,8 +480,6 @@
                         item = QtGui.QTableWidgetItem(tempList[row], 0)
                         item.setData(QtCore.Qt.UserRole, tempId[row])
                         self.verseListWidget.setItem(row, 0, item)
-                    self.verseListWidget.resizeRowsToContents()
-                    self.verseListWidget.repaint()
         self.tagRows()
 
     def onVerseEditAllButtonClicked(self):
@@ -500,53 +496,50 @@
             self.verse_form.setVerse(verse_list)
         else:
             self.verse_form.setVerse(u'')
-        if self.verse_form.exec_():
-            verse_list = self.verse_form.getVerseAll()
-            verse_list = unicode(verse_list.replace(u'\r\n', u'\n'))
-            self.verseListWidget.clear()
-            self.verseListWidget.setRowCount(0)
-            for row in self.findVerseSplit.split(verse_list):
-                for match in row.split(u'---['):
-                    for count, parts in enumerate(match.split(u']---\n')):
-                        if len(parts) > 1:
-                            if count == 0:
-                                # handling carefully user inputted versetags
-                                separator = parts.find(u':')
-                                if separator >= 0:
-                                    verse_name = parts[0:separator].strip()
-                                    verse_num = parts[separator+1:].strip()
-                                else:
-                                    verse_name = parts
-                                    verse_num = u'1'
-                                verse_index = \
-                                    VerseType.from_loose_input(verse_name)
-                                verse_tag = VerseType.Tags[verse_index]
-                                # Later we need to handle v1a as well.
-                                #regex = re.compile(r'(\d+\w.)')
-                                regex = re.compile(r'\D*(\d+)\D*')
-                                match = regex.match(verse_num)
-                                if match:
-                                    verse_num = match.group(1)
-                                else:
-                                    verse_num = u'1'
-                                verse_def = u'%s%s' % (verse_tag, verse_num)
-                            else:
-                                if parts.endswith(u'\n'):
-                                    parts = parts.rstrip(u'\n')
-                                item = QtGui.QTableWidgetItem(parts)
-                                item.setData(QtCore.Qt.UserRole,
-                                    QtCore.QVariant(verse_def))
-                                self.verseListWidget.setRowCount(
-                                    self.verseListWidget.rowCount() + 1)
-                                self.verseListWidget.setItem(
-                                    int(self.verseListWidget.rowCount() - 1),
-                                    0, item)
-            self.verseListWidget.setColumnWidth(0, self.width)
-            self.verseListWidget.resizeRowsToContents()
-            self.verseListWidget.repaint()
-            self.tagRows()
-            self.verseEditButton.setEnabled(False)
-            self.verseDeleteButton.setEnabled(False)
+        if not self.verse_form.exec_():
+            return
+        verse_list = self.verse_form.getVerseAll()
+        verse_list = unicode(verse_list.replace(u'\r\n', u'\n'))
+        self.verseListWidget.clear()
+        self.verseListWidget.setRowCount(0)
+        for row in self.findVerseSplit.split(verse_list):
+            for match in row.split(u'---['):
+                for count, parts in enumerate(match.split(u']---\n')):
+                    if len(parts) <= 1:
+                        continue
+                    if count == 0:
+                        # handling carefully user inputted versetags
+                        separator = parts.find(u':')
+                        if separator >= 0:
+                            verse_name = parts[0:separator].strip()
+                            verse_num = parts[separator+1:].strip()
+                        else:
+                            verse_name = parts
+                            verse_num = u'1'
+                        verse_index = VerseType.from_loose_input(verse_name)
+                        verse_tag = VerseType.Tags[verse_index]
+                        # Later we need to handle v1a as well.
+                        #regex = re.compile(r'(\d+\w.)')
+                        regex = re.compile(r'\D*(\d+)\D*')
+                        match = regex.match(verse_num)
+                        if match:
+                            verse_num = match.group(1)
+                        else:
+                            verse_num = u'1'
+                        verse_def = u'%s%s' % (verse_tag, verse_num)
+                    else:
+                        if parts.endswith(u'\n'):
+                            parts = parts.rstrip(u'\n')
+                        item = QtGui.QTableWidgetItem(parts)
+                        item.setData(QtCore.Qt.UserRole,
+                            QtCore.QVariant(verse_def))
+                        self.verseListWidget.setRowCount(
+                            self.verseListWidget.rowCount() + 1)
+                        self.verseListWidget.setItem(
+                            self.verseListWidget.rowCount() - 1, 0, item)
+        self.tagRows()
+        self.verseEditButton.setEnabled(False)
+        self.verseDeleteButton.setEnabled(False)
 
     def onVerseDeleteButtonClicked(self):
         self.verseListWidget.removeRow(self.verseListWidget.currentRow())
@@ -728,7 +721,7 @@
         self.song.title = unicode(self.titleEdit.text())
         self.song.alternate_title = unicode(self.alternativeEdit.text())
         self.song.copyright = unicode(self.copyrightEdit.text())
-         # Values will be set when cleaning the song.
+        # Values will be set when cleaning the song.
         self.song.search_title = u''
         self.song.search_lyrics = u''
         self.song.verse_order = u''
@@ -753,7 +746,7 @@
             self.song.theme_name = theme_name
         else:
             self.song.theme_name = None
-        self.processLyrics()
+        self._processLyrics()
         self.song.authors = []
         for row in range(self.authorsListView.count()):
             item = self.authorsListView.item(row)
@@ -769,12 +762,12 @@
         if not preview:
             self.song = None
 
-    def processLyrics(self):
+    def _processLyrics(self):
         """
         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.
-        log.debug(u'processLyrics')
+        log.debug(u'_processLyrics')
         try:
             sxml = SongXML()
             multiple = []


Follow ups