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