added button to undo optimization

git-svn-id: http://galileo.dmi.unict.it/svn/relational/trunk@149 014f5005-505e-4b48-8d0a-63407b615a7c
master
LtWorf 2009-05-06 14:10:42 +07:00
parent 23740eea4d
commit 195ef42596
1 changed files with 22 additions and 4 deletions

@ -30,10 +30,18 @@ class Ui_Form(object):
self.About=None
self.Survey=None
self.relations={} #Dictionary for relations
self.undo=[] #UndoQueue for relations
self.selectedRelation=None
def undo_optimize(self):
try:
self.txtQuery.setText(self.undo.pop())
except:#Nothing to restore
pass
def optimize(self):
self.undo.insert(len(self.undo),self.txtQuery.text()) #Storing the query in undo list
result=optimizer.general_optimize(str(self.txtQuery.text().toUtf8()))
self.txtQuery.setText(QtCore.QString.fromUtf8(result))
#self.txtQuery.setText(result)
def execute(self):
try:
@ -43,6 +51,8 @@ class Ui_Form(object):
print query,"-->" , expr #Printing debug
result=eval(expr,self.relations) #Evaluating the expression
#self.undo.insert(len(self.undo),self.txtQuery.text()) #Storing the query in undo list
res_rel=str(self.txtResult.text())#result relation's name
self.txtResult.setText("") #Sets the result relation name to none
if len(res_rel)==0: #If no name is set use the default last_
@ -385,6 +395,13 @@ class Ui_Form(object):
self.cmdOptimize.setObjectName("cmdOptimize")
self.horizontalLayout.addWidget(self.cmdOptimize)
self.cmdUndoOptimize = QtGui.QPushButton(Form)
self.cmdUndoOptimize.setAutoDefault(False)
self.cmdUndoOptimize.setDefault(True)
self.cmdUndoOptimize.setFlat(False)
self.cmdUndoOptimize.setObjectName("cmdUndoOptimize")
self.horizontalLayout.addWidget(self.cmdUndoOptimize)
self.verticalLayout_7.addLayout(self.horizontalLayout)
self.label.setBuddy(self.txtResult)
@ -408,6 +425,7 @@ class Ui_Form(object):
QtCore.QObject.connect(self.cmdArrow,QtCore.SIGNAL("clicked()"),self.addArrow)
QtCore.QObject.connect(self.cmdExecute,QtCore.SIGNAL("clicked()"),self.execute)
QtCore.QObject.connect(self.cmdOptimize,QtCore.SIGNAL("clicked()"),self.optimize)
QtCore.QObject.connect(self.cmdUndoOptimize,QtCore.SIGNAL("clicked()"),self.undo_optimize)
QtCore.QObject.connect(self.cmdLoad,QtCore.SIGNAL("clicked()"),self.loadRelation)
QtCore.QObject.connect(self.cmdSave,QtCore.SIGNAL("clicked()"),self.saveRelation)
QtCore.QObject.connect(self.cmdUnload,QtCore.SIGNAL("clicked()"),self.unloadRelation)
@ -419,8 +437,7 @@ class Ui_Form(object):
Form.setTabOrder(self.txtResult,self.txtQuery)
Form.setTabOrder(self.txtQuery,self.cmdExecute)
Form.setTabOrder(self.txtQuery,self.cmdOptimize)
Form.setTabOrder(self.cmdExecute,self.lstRelations)
Form.setTabOrder(self.cmdOptimize,self.lstRelations)
Form.setTabOrder(self.txtQuery,self.cmdUndoOptimize)
Form.setTabOrder(self.lstRelations,self.cmdLoad)
Form.setTabOrder(self.cmdLoad,self.cmdUnload)
Form.setTabOrder(self.cmdLoad,self.cmdSave)
@ -480,8 +497,9 @@ class Ui_Form(object):
self.lstAttributes.setToolTip(QtGui.QApplication.translate("Form", "Shows the attributes of the current relation", None, QtGui.QApplication.UnicodeUTF8))
self.label.setText(QtGui.QApplication.translate("Form", "Query", None, QtGui.QApplication.UnicodeUTF8))
self.label_2.setText(QtGui.QApplication.translate("Form", "=", None, QtGui.QApplication.UnicodeUTF8))
self.cmdExecute.setText(QtGui.QApplication.translate("Form", "Execute", None, QtGui.QApplication.UnicodeUTF8))
self.cmdOptimize.setText(QtGui.QApplication.translate("Form", "Optimize", None, QtGui.QApplication.UnicodeUTF8))
self.cmdExecute.setText(QtGui.QApplication.translate("Form", "Execute", None, QtGui.QApplication.UnicodeUTF8))
self.cmdOptimize.setText(QtGui.QApplication.translate("Form", "Optimize", None, QtGui.QApplication.UnicodeUTF8))
self.cmdUndoOptimize.setText(QtGui.QApplication.translate("Form", "Undo optimize", None, QtGui.QApplication.UnicodeUTF8))
if __name__ == "__main__":
import sys