- apparently it works, needs further testing

git-svn-id: http://galileo.dmi.unict.it/svn/relational/trunk@319 014f5005-505e-4b48-8d0a-63407b615a7c
This commit is contained in:
LtWorf 2011-10-08 22:35:24 +00:00
parent f02f54d58d
commit c5af23d05c
5 changed files with 29 additions and 48 deletions

View File

@ -5,6 +5,7 @@
- Can send email in survey
- Can check for new version online
- Can use both PySide and PyQt
- Removed buttons for adding and deleting tuples
1.0
- Adds history in the GUI

View File

@ -32,14 +32,27 @@ def get_py_str(a):
'''Returns a python string out of a QString'''
if pyqt:
return str(a.toUtf8())
return a #Already a python string in PySide
return str(a.encode("utf-8")) #Already a python string in PySide
def set_utf8_text(component,text):
if pyqt:
if not pyqt:
component.setText(text.decode("utf-8"))
else:
component.setText(QtCore.QString.fromUtf8(text))
def get_filename(filename):
if pyqt:
return str(filename.toUtf8())
return filename[0]
return filename[0]
def add_list_item(l,item):
if pyqt:
history_item=QtCore.QString()
history_item.append(item)
hitem=QtGui.QListWidgetItem(None,0)
hitem.setText(history_item)
l.addItem (hitem)
l.setCurrentItem(hitem)
else:
hitem=QtGui.QListWidgetItem(None,0)
hitem.setText(item)
l.addItem (hitem)
l.setCurrentItem(hitem)

View File

@ -68,27 +68,26 @@ class relForm(QtGui.QMainWindow):
'''Performs all the possible optimizations on the query'''
self.undo=self.ui.txtQuery.text() #Storing the query in undo list
query=compatibility.get_py_str(self.ui.txtQuery.text()).encode("utf-8")
query=compatibility.get_py_str(self.ui.txtQuery.text())
result=optimizer.optimize_all(query,self.relations)
compatibility.set_utf8_text(self.ui.TxtQuery,result)
compatibility.set_utf8_text(self.ui.txtQuery,result)
def resumeHistory(self,item):
itm=compatibility.get_py_str(item.text()).split(' = ',1)
compatibility.set_utf8_text(self.ui.txtResult,itm[0])
compatibility.set_utf8_text(self.ui.txtQuery,itm[1])
compatibility.set_utf8_text(self.ui.txtQuery,itm[1])
def execute(self):
'''Executes the query'''
query=compatibility.get_py_str(self.ui.txtQuery.text())
res_rel=compatibility.get_py_str(self.ui.txtResult.text())#result relation's name
if not rtypes.is_valid_relation_name(res_rel):
QtGui.QMessageBox.information(self,QtGui.QApplication.translate("Form", "Error"),QtGui.QApplication.translate("Form", "Wrong name for destination relation."))
return
try:
#Converting string to utf8 and then from qstring to normal string
expr=parser.parse(query)#Converting expression to python code
@ -103,16 +102,11 @@ class relForm(QtGui.QMainWindow):
print e
QtGui.QMessageBox.information(None,QtGui.QApplication.translate("Form", "Error"),"%s\n%s" % (QtGui.QApplication.translate("Form", "Check your query!"),e.__str__()) )
return
#Query was executed normally
#TODO fix THAT
#history_item=QtCore.QString()
#history_item.append(self.ui.txtResult.text())
#history_item.append(u' = ')
#history_item.append(self.ui.txtQuery.text())
#hitem=QtGui.QListWidgetItem(None,0)
#hitem.setText(history_item)
#self.ui.lstHistory.addItem (hitem)
#self.ui.lstHistory.setCurrentItem(hitem)
#Adds to history
item='%s = %s' % (compatibility.get_py_str(self.ui.txtResult.text()),compatibility.get_py_str(self.ui.txtQuery.text()))
item=unicode(item.decode('utf-8'))
compatibility.add_list_item(self.ui.lstHistory,item)
self.qcounter+=1
compatibility.set_utf8_text(self.ui.txtResult,u"_last%d"% self.qcounter) #Sets the result relation name to none
@ -226,33 +220,6 @@ class relForm(QtGui.QMainWindow):
self.updateRelations()
def insertTuple(self):
'''Shows an input dialog and inserts the inserted tuple into the selected relation'''
res=QtGui.QInputDialog.getText(self, QtGui.QApplication.translate("Form", "New relation"),QtGui.QApplication.translate("Form", "Insert the values, comma separated"),
QtGui.QLineEdit.Normal,"")
if res[1]==False:
return
t=[]
for i in str(res[0].toUtf8()).split(","):
t.append(i.strip())
if self.selectedRelation!=None and self.selectedRelation.insert(t) > 0:
self.showRelation(self.selectedRelation)
return
def deleteTuple(self):
'''Shows an input dialog and removes the tuples corresponding to the condition.'''
res=QtGui.QInputDialog.getText(self, QtGui.QApplication.translate("Form", "New relation"),QtGui.QApplication.translate("Form", "Remove tuples: insert where condition"),
QtGui.QLineEdit.Normal,"")
if res[1]==False:
return
if self.selectedRelation!=None and self.selectedRelation.delete(str(res[0].toUtf8())) > 0:
self.showRelation(self.selectedRelation)
return
def addProduct(self):
self.addSymbolInQuery(u"*")
def addDifference(self):

View File

@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'relational_gui/survey.ui'
#
# Created: Sat Oct 8 20:14:44 2011
# Created: Sun Oct 9 00:27:00 2011
# by: PyQt4 UI code generator 4.8.3
#
# WARNING! All changes made in this file will be lost!

View File

@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'relational_pyside/survey.ui'
#
# Created: Sat Oct 8 20:14:44 2011
# Created: Sun Oct 9 00:27:00 2011
# by: pyside-uic 0.2.13 running on PySide 1.0.7
#
# WARNING! All changes made in this file will be lost!