Ask again if the relation name is incorrect

When creating a new relation, if the name is incorrect, ask again rather than
drop entirely the new relation.
master
Salvo 'LtWorf' Tomaselli 2015-02-23 14:19:28 +07:00
parent 0a562ff603
commit 5bfbe4f4af
1 changed files with 28 additions and 26 deletions

@ -197,35 +197,37 @@ class relForm(QtWidgets.QMainWindow):
if result == None: if result == None:
return return
while True:
res = QtWidgets.QInputDialog.getText( res = QtWidgets.QInputDialog.getText(
self, self,
QtWidgets.QApplication.translate("Form", "New relation"), QtWidgets.QApplication.translate("Form", "New relation"),
QtWidgets.QApplication.translate( QtWidgets.QApplication.translate(
"Form", "Insert the name for the new relation"), "Form", "Insert the name for the new relation"),
QtWidgets.QLineEdit.Normal, '') QtWidgets.QLineEdit.Normal, ''
if res[1] == False or len(res[0]) == 0: )
if res[1] == False:# or len(res[0]) == 0:
return return
# Patch provided by Angelo 'Havoc' Puglisi
name = compatibility.get_py_str(res[0]) name = compatibility.get_py_str(res[0])
if not rtypes.is_valid_relation_name(name): if not rtypes.is_valid_relation_name(name):
r = QtWidgets.QApplication.translate( r = QtWidgets.QApplication.translate(
"Form", str("Wrong name for destination relation: %s." % name)) "Form", str("Wrong name for destination relation: %s." % name)
)
QtWidgets.QMessageBox.information( QtWidgets.QMessageBox.information(
self, QtWidgets.QApplication.translate("Form", "Error"), r) self, QtWidgets.QApplication.translate("Form", "Error"), r
return )
continue
try: try:
self.relations[name] = result self.relations[name] = result
self.updateRelations()
except Exception as e: except Exception as e:
print (e) print (e)
QtWidgets.QMessageBox.information(None, QtWidgets.QApplication.translate("Form", "Error"), "%s\n%s" % QtWidgets.QMessageBox.information(None, QtWidgets.QApplication.translate("Form", "Error"), "%s\n%s" %
(QtWidgets.QApplication.translate("Form", "Check your query!"), e.__str__())) (QtWidgets.QApplication.translate("Form", "Check your query!"), e.__str__()))
finally:
return return
self.updateRelations()
def closeEvent(self, event): def closeEvent(self, event):
self.save_settings() self.save_settings()
event.accept() event.accept()