Add new features and edit validation

Text can be added , cleared and edited.

bzr-revno: 392
This commit is contained in:
Tim Bentley 2009-03-07 17:13:19 +00:00
parent 749590386d
commit b5550abda9
2 changed files with 34 additions and 6 deletions

View File

@ -57,6 +57,9 @@ class Ui_customEditDialog(object):
self.DeleteButton = QtGui.QPushButton(self.ButtonWidge) self.DeleteButton = QtGui.QPushButton(self.ButtonWidge)
self.DeleteButton.setObjectName("DeleteButton") self.DeleteButton.setObjectName("DeleteButton")
self.ButtonLayout_3.addWidget(self.DeleteButton) self.ButtonLayout_3.addWidget(self.DeleteButton)
self.ClearButton = QtGui.QPushButton(self.ButtonWidge)
self.ClearButton.setObjectName("ClearButton")
self.ButtonLayout_3.addWidget(self.ClearButton)
spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
self.ButtonLayout_3.addItem(spacerItem) self.ButtonLayout_3.addItem(spacerItem)
self.EditLayout_3.addWidget(self.ButtonWidge) self.EditLayout_3.addWidget(self.ButtonWidge)
@ -102,5 +105,6 @@ class Ui_customEditDialog(object):
self.EditButton_3.setText(QtGui.QApplication.translate("customEditDialog", "Edit", None, QtGui.QApplication.UnicodeUTF8)) self.EditButton_3.setText(QtGui.QApplication.translate("customEditDialog", "Edit", None, QtGui.QApplication.UnicodeUTF8))
self.SaveButton_3.setText(QtGui.QApplication.translate("customEditDialog", "Save", None, QtGui.QApplication.UnicodeUTF8)) self.SaveButton_3.setText(QtGui.QApplication.translate("customEditDialog", "Save", None, QtGui.QApplication.UnicodeUTF8))
self.DeleteButton.setText(QtGui.QApplication.translate("customEditDialog", "Delete", None, QtGui.QApplication.UnicodeUTF8)) self.DeleteButton.setText(QtGui.QApplication.translate("customEditDialog", "Delete", None, QtGui.QApplication.UnicodeUTF8))
self.ClearButton.setText(QtGui.QApplication.translate("customEditDialog", "Clear", None, QtGui.QApplication.UnicodeUTF8))
self.ThemeLabel.setText(QtGui.QApplication.translate("customEditDialog", "Theme:", None, QtGui.QApplication.UnicodeUTF8)) self.ThemeLabel.setText(QtGui.QApplication.translate("customEditDialog", "Theme:", None, QtGui.QApplication.UnicodeUTF8))
self.CreditLabel.setText(QtGui.QApplication.translate("customEditDialog", "Credits:", None, QtGui.QApplication.UnicodeUTF8)) self.CreditLabel.setText(QtGui.QApplication.translate("customEditDialog", "Credits:", None, QtGui.QApplication.UnicodeUTF8))

View File

@ -38,20 +38,32 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog):
QtCore.QObject.connect(self.EditButton_3, QtCore.SIGNAL("pressed()"), self.onEditButtonPressed) QtCore.QObject.connect(self.EditButton_3, QtCore.SIGNAL("pressed()"), self.onEditButtonPressed)
QtCore.QObject.connect(self.SaveButton_3, QtCore.SIGNAL("pressed()"), self.onSaveButtonPressed) QtCore.QObject.connect(self.SaveButton_3, QtCore.SIGNAL("pressed()"), self.onSaveButtonPressed)
QtCore.QObject.connect(self.DeleteButton, QtCore.SIGNAL("pressed()"), self.onDeleteButtonPressed) QtCore.QObject.connect(self.DeleteButton, QtCore.SIGNAL("pressed()"), self.onDeleteButtonPressed)
QtCore.QObject.connect(self.ClearButton, QtCore.SIGNAL("pressed()"), self.onClearButtonPressed)
QtCore.QObject.connect(self.TitleEdit, QtCore.SIGNAL("lostFocus()"), self.validate)
QtCore.QObject.connect(self.VerseListView, QtCore.SIGNAL("itemDoubleClicked(QListWidgetItem*)"), self.onVerseListViewSelected)
# Create other objects and forms # Create other objects and forms
self.custommanager = custommanager self.custommanager = custommanager
self.initialise() self.initialise()
self.VerseListView.setAlternatingRowColors(True)
#self.savebutton = self.ButtonBox.button(QtGui.QDialogButtonBox.Save) #self.savebutton = self.ButtonBox.button(QtGui.QDialogButtonBox.Save)
def accept(self): def accept(self):
pass self.validate()
if self.valid:
self.close()
def rejected(self): def rejected(self):
self.close() self.close()
def onClearButtonPressed(self):
self.VerseTextEdit_3.clear()
def onVerseListViewSelected(self, item):
self.VerseTextEdit_3.setPlainText(item.text())
def onAddButtonPressed(self): def onAddButtonPressed(self):
pass print self.VerseTextEdit_3
self.VerseListView.addItem(self.VerseTextEdit_3.toPlainText())
def onEditButtonPressed(self): def onEditButtonPressed(self):
pass pass
@ -62,16 +74,28 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog):
def onDeleteButtonPressed(self): def onDeleteButtonPressed(self):
pass pass
def validate(self):
invalid = 0
self.valid = True
if len(self.TitleEdit.displayText()) == 0:
invalid += 1
self.TitleLabel.setStyleSheet('color: red')
else:
self.TitleLabel.setStyleSheet('color: black')
if invalid == 1:
self.valid = False
def initialise(self): def initialise(self):
self.valid = True
pass pass
# list = self.songmanager.get_authors() # list = self.songmanager.get_authors()
# self.AuthorsSelectionComboItem.clear() # self.AuthorsSelectionComboItem.clear()
# for i in list: # for i in list:
# self.AuthorsSelectionComboItem.addItem( i.display_name) # self.AuthorsSelectionComboItem.addItem( i.display_name)
def loadSong(self, id): def loadCustomItem(self, id):
pass pass
# self.song = self.songmanager.get_song(id) #self.item = self.songmanager.get_song(id)
# self.TitleEditItem.setText(self.song.title) # self.TitleEditItem.setText(self.song.title)
# self.LyricsTextEdit.setText(self.song.lyrics) # self.LyricsTextEdit.setText(self.song.lyrics)
# self.CopyrightEditItem.setText(self.song.copyright) # self.CopyrightEditItem.setText(self.song.copyright)