Insert and delete from GUI are now done on the displayed relation, not on the selected one
git-svn-id: http://galileo.dmi.unict.it/svn/relational/trunk@100 014f5005-505e-4b48-8d0a-63407b615a7c
This commit is contained in:
parent
4a436f14a8
commit
e6e571f97b
@ -30,6 +30,8 @@ class Ui_Form(object):
|
|||||||
self.About=None
|
self.About=None
|
||||||
self.Survey=None
|
self.Survey=None
|
||||||
self.relations={} #Dictionary for relations
|
self.relations={} #Dictionary for relations
|
||||||
|
self.selectedRelation=None
|
||||||
|
|
||||||
def execute(self):
|
def execute(self):
|
||||||
try:
|
try:
|
||||||
#Converting string to utf8 and then from qstring to normal string
|
#Converting string to utf8 and then from qstring to normal string
|
||||||
@ -45,8 +47,8 @@ class Ui_Form(object):
|
|||||||
|
|
||||||
self.relations[res_rel]=result #Add the relation to the dictionary
|
self.relations[res_rel]=result #Add the relation to the dictionary
|
||||||
self.updateRelations() #update the list
|
self.updateRelations() #update the list
|
||||||
|
self.selectedRelation=result
|
||||||
self.showRelation(result) #Show the result in the table
|
self.showRelation(self.selectedRelation) #Show the result in the table
|
||||||
except:
|
except:
|
||||||
QtGui.QMessageBox.information(None,QtGui.QApplication.translate("Form", "Error"),QtGui.QApplication.translate("Form", "Check your query!") )
|
QtGui.QMessageBox.information(None,QtGui.QApplication.translate("Form", "Error"),QtGui.QApplication.translate("Form", "Check your query!") )
|
||||||
def showRelation(self,rel):
|
def showRelation(self,rel):
|
||||||
@ -73,7 +75,8 @@ class Ui_Form(object):
|
|||||||
|
|
||||||
def printRelation(self,*rel):
|
def printRelation(self,*rel):
|
||||||
for i in rel:
|
for i in rel:
|
||||||
self.showRelation(self.relations[str(i.text().toUtf8())])
|
self.selectedRelation=self.relations[str(i.text().toUtf8())]
|
||||||
|
self.showRelation(self.selectedRelation)
|
||||||
|
|
||||||
def showAttributes(self,*other):
|
def showAttributes(self,*other):
|
||||||
for i in other:
|
for i in other:
|
||||||
@ -154,11 +157,8 @@ class Ui_Form(object):
|
|||||||
for i in str(res[0].toUtf8()).split(","):
|
for i in str(res[0].toUtf8()).split(","):
|
||||||
t.append(i.strip())
|
t.append(i.strip())
|
||||||
|
|
||||||
|
if self.selectedRelation!=None and self.selectedRelation.insert(t) > 0:
|
||||||
for i in self.lstRelations.selectedItems():
|
self.showRelation(self.selectedRelation)
|
||||||
rel=self.relations[str(i.text().toUtf8())]
|
|
||||||
if rel.insert(t) > 0:
|
|
||||||
self.showRelation(rel)
|
|
||||||
|
|
||||||
return
|
return
|
||||||
def deleteTuple(self):
|
def deleteTuple(self):
|
||||||
@ -168,10 +168,8 @@ class Ui_Form(object):
|
|||||||
if res[1]==False:
|
if res[1]==False:
|
||||||
return
|
return
|
||||||
|
|
||||||
for i in self.lstRelations.selectedItems():
|
if self.selectedRelation!=None and self.selectedRelation.delete(str(res[0].toUtf8())) > 0:
|
||||||
rel=self.relations[str(i.text().toUtf8())]
|
self.showRelation(self.selectedRelation)
|
||||||
if rel.delete(str(res[0].toUtf8())) > 0:
|
|
||||||
self.showRelation(rel)
|
|
||||||
|
|
||||||
return
|
return
|
||||||
def addProduct(self):
|
def addProduct(self):
|
||||||
@ -302,7 +300,7 @@ class Ui_Form(object):
|
|||||||
self.table.setAlternatingRowColors(True)
|
self.table.setAlternatingRowColors(True)
|
||||||
self.table.setRootIsDecorated(False)
|
self.table.setRootIsDecorated(False)
|
||||||
self.table.setObjectName("table")
|
self.table.setObjectName("table")
|
||||||
self.showRelation(None)
|
self.showRelation(self.selectedRelation)
|
||||||
self.centerLayout.addWidget(self.table)
|
self.centerLayout.addWidget(self.table)
|
||||||
|
|
||||||
self.cmdInsert = QtGui.QPushButton(self.groupBox)
|
self.cmdInsert = QtGui.QPushButton(self.groupBox)
|
||||||
|
Loading…
Reference in New Issue
Block a user