@ -240,12 +240,7 @@ class relForm(QtWidgets.QMainWindow):
self . relations [ i . text ( ) ] = result
self . relations [ i . text ( ) ] = result
self . updateRelations ( )
self . updateRelations ( )
def newRelation ( self ) :
def promptRelationName ( self ) :
from relational_gui import creator
result = creator . edit_relation ( )
if result == None :
return
while True :
while True :
res = QtWidgets . QInputDialog . getText (
res = QtWidgets . QInputDialog . getText (
self ,
self ,
@ -255,9 +250,8 @@ class relForm(QtWidgets.QMainWindow):
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 None
name = res [ 0 ]
name = 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 )
@ -266,16 +260,25 @@ class relForm(QtWidgets.QMainWindow):
self , QtWidgets . QApplication . translate ( " Form " , " Error " ) , r
self , QtWidgets . QApplication . translate ( " Form " , " Error " ) , r
)
)
continue
continue
return name
try :
def newRelation ( self ) :
self . relations [ name ] = result
from relational_gui import creator
self . updateRelations ( )
result = creator . edit_relation ( )
except Exception as e :
print ( e )
if result == None :
QtWidgets . QMessageBox . information ( None , QtWidgets . QApplication . translate ( " Form " , " Error " ) , " %s \n %s " %
return
( QtWidgets . QApplication . translate ( " Form " , " Check your query! " ) , e . __str__ ( ) ) )
name = self . promptRelationName ( )
finally :
return
try :
self . relations [ name ] = result
self . updateRelations ( )
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__ ( ) ) )
finally :
return
def closeEvent ( self , event ) :
def closeEvent ( self , event ) :
self . save_settings ( )
self . save_settings ( )
@ -330,14 +333,11 @@ class relForm(QtWidgets.QMainWindow):
if ( name . endswith ( " .csv " ) ) : # removes the extension
if ( name . endswith ( " .csv " ) ) : # removes the extension
name = name [ : - 4 ]
name = name [ : - 4 ]
else :
name . replace ( ' . ' , ' ' )
if not rtypes . is_valid_relation_name ( name ) :
if not rtypes . is_valid_relation_name ( name ) :
r = QtWidgets . QApplication . translate (
name = self . promptRelationName ( )
" Form " , str ( " Wrong name for destination relation: %s . " % name ) )
QtWidgets . QMessageBox . information (
if name is None :
self , QtWidgets . QApplication . translate ( " Form " , " Error " ) , r )
continue
continue
try :
try :