← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~thealok/openlp/authorform into lp:openlp

 

ALok has proposed merging lp:~thealok/openlp/authorform into lp:openlp.

Requested reviews:
    openlp.org Core (openlp-core)

Fix it so you can add authors.
-- 
https://code.launchpad.net/~thealok/openlp/authorform/+merge/9118
Your team openlp.org Core is subscribed to branch lp:openlp.
=== modified file 'openlp/plugins/songs/forms/authorsform.py'
--- openlp/plugins/songs/forms/authorsform.py	2009-07-18 05:43:50 +0000
+++ openlp/plugins/songs/forms/authorsform.py	2009-07-22 00:02:56 +0000
@@ -41,8 +41,6 @@
             QtCore.SIGNAL(u'pressed()'), self.onClearButtonClick)
         QtCore.QObject.connect(self.AddUpdateButton,
             QtCore.SIGNAL(u'pressed()'), self.onAddUpdateButtonClick)
-        QtCore.QObject.connect(self.DisplayEdit,
-            QtCore.SIGNAL(u'lostFocus()'), self.onDisplayEditLostFocus)
         QtCore.QObject.connect(self.AuthorListWidget,
             QtCore.SIGNAL(u'clicked(QModelIndex)'), self.onAuthorListWidgetItemClicked)
 
@@ -62,7 +60,6 @@
             self.AuthorListWidget.setCurrentRow(self.AuthorListWidget.count() - 1)
         else:
             self.AuthorListWidget.setCurrentRow(self.currentRow)
-        self._validate_form()
 
     def onDeleteButtonClick(self):
         """
@@ -71,33 +68,34 @@
         self.songmanager.delete_author(self.author.id)
         self.load_form()
 
-    def onDisplayEditLostFocus(self):
-        self._validate_form()
-
     def onAddUpdateButtonClick(self):
         """
         Sent New or update details to the database
         """
-        if self.author == None:
-            self.author = Author()
-        self.author.display_name = unicode(self.DisplayEdit.displayText())
-        self.author.first_name = unicode(self.FirstNameEdit.displayText())
-        self.author.last_name = unicode(self.LastNameEdit.displayText())
-        self.songmanager.save_author(self.author)
-        self.onClearButtonClick()
-        self.load_form()
-
+        if len(unicode(self.DisplayEdit.text())) > 0 :
+          if self.author == None:
+              self.author = Author()
+          self.author.display_name = unicode(self.DisplayEdit.displayText())
+          self.author.first_name = unicode(self.FirstNameEdit.displayText())
+          self.author.last_name = unicode(self.LastNameEdit.displayText())
+          self.songmanager.save_author(self.author)
+          self.onClearButtonClick()
+          self.load_form()
+          self.DisplayEdit.setStyleSheet(u'')
+        else:
+          self.DisplayEdit.setStyleSheet(u'background-color: red; color: white')
+          
     def onClearButtonClick(self):
         """
         Tidy up screen if clear button pressed
         """
         self.DisplayEdit.setText(u'')
+        self.DisplayEdit.setStyleSheet(u'')
         self.FirstNameEdit.setText(u'')
         self.LastNameEdit.setText(u'')
         self.MessageLabel.setText(u'')
         self.DeleteButton.setEnabled(False)
         self.author = None
-        self._validate_form()
         self.DisplayEdit.setFocus()
 
     def onAuthorListWidgetItemClicked(self, index):
@@ -124,15 +122,4 @@
         else:
             self.MessageLabel.setText(translate(u'AuthorForm', u'Author in not used'))
             self.DeleteButton.setEnabled(True)
-        self._validate_form()
         self.DisplayEdit.setFocus()
-
-    def _validate_form(self):
-        """
-        Validate the form and set if Add button if valid.
-        """
-        # We need at lease a display name
-        if len(self.DisplayEdit.displayText()) == 0:
-            self.AddUpdateButton.setEnabled(False)
-        else:
-            self.AddUpdateButton.setEnabled(True)


Follow ups