- 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:
parent
f02f54d58d
commit
c5af23d05c
@ -5,6 +5,7 @@
|
|||||||
- Can send email in survey
|
- Can send email in survey
|
||||||
- Can check for new version online
|
- Can check for new version online
|
||||||
- Can use both PySide and PyQt
|
- Can use both PySide and PyQt
|
||||||
|
- Removed buttons for adding and deleting tuples
|
||||||
|
|
||||||
1.0
|
1.0
|
||||||
- Adds history in the GUI
|
- Adds history in the GUI
|
||||||
|
@ -32,14 +32,27 @@ def get_py_str(a):
|
|||||||
'''Returns a python string out of a QString'''
|
'''Returns a python string out of a QString'''
|
||||||
if pyqt:
|
if pyqt:
|
||||||
return str(a.toUtf8())
|
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):
|
def set_utf8_text(component,text):
|
||||||
if pyqt:
|
if not pyqt:
|
||||||
component.setText(text.decode("utf-8"))
|
component.setText(text.decode("utf-8"))
|
||||||
else:
|
else:
|
||||||
component.setText(QtCore.QString.fromUtf8(text))
|
component.setText(QtCore.QString.fromUtf8(text))
|
||||||
def get_filename(filename):
|
def get_filename(filename):
|
||||||
if pyqt:
|
if pyqt:
|
||||||
return str(filename.toUtf8())
|
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)
|
@ -68,27 +68,26 @@ class relForm(QtGui.QMainWindow):
|
|||||||
'''Performs all the possible optimizations on the query'''
|
'''Performs all the possible optimizations on the query'''
|
||||||
self.undo=self.ui.txtQuery.text() #Storing the query in undo list
|
self.undo=self.ui.txtQuery.text() #Storing the query in undo list
|
||||||
|
|
||||||
|
query=compatibility.get_py_str(self.ui.txtQuery.text())
|
||||||
query=compatibility.get_py_str(self.ui.txtQuery.text()).encode("utf-8")
|
|
||||||
result=optimizer.optimize_all(query,self.relations)
|
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):
|
def resumeHistory(self,item):
|
||||||
itm=compatibility.get_py_str(item.text()).split(' = ',1)
|
itm=compatibility.get_py_str(item.text()).split(' = ',1)
|
||||||
compatibility.set_utf8_text(self.ui.txtResult,itm[0])
|
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):
|
def execute(self):
|
||||||
'''Executes the query'''
|
'''Executes the query'''
|
||||||
|
|
||||||
query=compatibility.get_py_str(self.ui.txtQuery.text())
|
query=compatibility.get_py_str(self.ui.txtQuery.text())
|
||||||
|
|
||||||
res_rel=compatibility.get_py_str(self.ui.txtResult.text())#result relation's name
|
res_rel=compatibility.get_py_str(self.ui.txtResult.text())#result relation's name
|
||||||
|
|
||||||
if not rtypes.is_valid_relation_name(res_rel):
|
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."))
|
QtGui.QMessageBox.information(self,QtGui.QApplication.translate("Form", "Error"),QtGui.QApplication.translate("Form", "Wrong name for destination relation."))
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
#Converting string to utf8 and then from qstring to normal string
|
#Converting string to utf8 and then from qstring to normal string
|
||||||
expr=parser.parse(query)#Converting expression to python code
|
expr=parser.parse(query)#Converting expression to python code
|
||||||
@ -103,16 +102,11 @@ class relForm(QtGui.QMainWindow):
|
|||||||
print e
|
print e
|
||||||
QtGui.QMessageBox.information(None,QtGui.QApplication.translate("Form", "Error"),"%s\n%s" % (QtGui.QApplication.translate("Form", "Check your query!"),e.__str__()) )
|
QtGui.QMessageBox.information(None,QtGui.QApplication.translate("Form", "Error"),"%s\n%s" % (QtGui.QApplication.translate("Form", "Check your query!"),e.__str__()) )
|
||||||
return
|
return
|
||||||
#Query was executed normally
|
|
||||||
#TODO fix THAT
|
#Adds to history
|
||||||
#history_item=QtCore.QString()
|
item='%s = %s' % (compatibility.get_py_str(self.ui.txtResult.text()),compatibility.get_py_str(self.ui.txtQuery.text()))
|
||||||
#history_item.append(self.ui.txtResult.text())
|
item=unicode(item.decode('utf-8'))
|
||||||
#history_item.append(u' = ')
|
compatibility.add_list_item(self.ui.lstHistory,item)
|
||||||
#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)
|
|
||||||
|
|
||||||
self.qcounter+=1
|
self.qcounter+=1
|
||||||
compatibility.set_utf8_text(self.ui.txtResult,u"_last%d"% self.qcounter) #Sets the result relation name to none
|
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()
|
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):
|
def addProduct(self):
|
||||||
self.addSymbolInQuery(u"*")
|
self.addSymbolInQuery(u"*")
|
||||||
def addDifference(self):
|
def addDifference(self):
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
# Form implementation generated from reading ui file 'relational_gui/survey.ui'
|
# 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
|
# by: PyQt4 UI code generator 4.8.3
|
||||||
#
|
#
|
||||||
# WARNING! All changes made in this file will be lost!
|
# WARNING! All changes made in this file will be lost!
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
# Form implementation generated from reading ui file 'relational_pyside/survey.ui'
|
# 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
|
# by: pyside-uic 0.2.13 running on PySide 1.0.7
|
||||||
#
|
#
|
||||||
# WARNING! All changes made in this file will be lost!
|
# WARNING! All changes made in this file will be lost!
|
||||||
|
Loading…
x
Reference in New Issue
Block a user