completed GUI

git-svn-id: http://galileo.dmi.unict.it/svn/relational/trunk@31 014f5005-505e-4b48-8d0a-63407b615a7c
master
LtWorf 2008-07-24 22:20:04 +07:00
parent 1446e6d004
commit 2caad7a868
4 changed files with 49 additions and 31 deletions

@ -20,4 +20,7 @@
- Created recoursive function to parse expressions
0.3
- Added support for parenthesis in relational queries
- Added support for parenthesis in relational queries
0.4
- Created GUI

@ -22,7 +22,7 @@ import relational
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Documentation")
Dialog.setObjectName("Dialog")
Dialog.resize(510,453)
self.verticalLayout_2 = QtGui.QVBoxLayout(Dialog)
self.verticalLayout_2.setObjectName("verticalLayout_2")
@ -96,7 +96,7 @@ class Ui_Dialog(object):
QtCore.QMetaObject.connectSlotsByName(Dialog)
def retranslateUi(self, Dialog):
Dialog.setWindowTitle(QtGui.QApplication.translate("Dialog", "Dialog", None, QtGui.QApplication.UnicodeUTF8))
Dialog.setWindowTitle(QtGui.QApplication.translate("Dialog", "Documentation", None, QtGui.QApplication.UnicodeUTF8))
self.groupBox.setTitle(QtGui.QApplication.translate("Dialog", "Relational", None, QtGui.QApplication.UnicodeUTF8))
self.label.setText(QtGui.QApplication.translate("Dialog", "Relational", None, QtGui.QApplication.UnicodeUTF8))
self.label_3.setText(QtGui.QApplication.translate("Dialog", "Version "+relational.version, None, QtGui.QApplication.UnicodeUTF8))

@ -24,6 +24,7 @@ import about
class Ui_Form(object):
def __init__(self):
self.Dialog=None
self.relations={} #Dictionary for relations
def execute(self):
try:
@ -37,32 +38,32 @@ class Ui_Form(object):
self.txtResult.setText("")
if len(res_rel)==0:
res_rel="last_"
self.relations[res_rel]=result
self.updateRelations()
self.showRelation(result)
except:
print
#QtGui.QMessageBox.information(None,QtGui.QApplication.translate("Form", "Error"), str(traceback.print_exc()))
QtGui.QMessageBox.information(None,QtGui.QApplication.translate("Form", "Error"),QtGui.QApplication.translate("Form", "Check your query!") )
def showRelation(self,rel):
self.table.clear()
for i in range(self.table.headerItem().columnCount()):
self.table.headerItem().setText(i,"")
if rel==None:
self.table.setColumnCount(1)
self.table.headerItem().setText(0,"Empty relation")
return
for i in range(len(rel.header.attributes)):
self.table.headerItem().setText(i,rel.header.attributes[i])
self.table.setColumnCount(len(rel.header.attributes))
for i in rel.content:
item = QtGui.QTreeWidgetItem()
for j in range(len(i)):
item.setText(j, i[j])
self.table.addTopLevelItem(item)
for i in range(len(rel.header.attributes)):
self.table.headerItem().setText(i,rel.header.attributes[i])
self.table.resizeColumnToContents(i)
def printRelation(self,*rel):
for i in rel:
@ -85,11 +86,12 @@ class Ui_Form(object):
del self.relations[str(i.text().toUtf8())]
self.updateRelations()
def showAbout(self):
Dialog = QtGui.QDialog()
ui = about.Ui_Dialog()
ui.setupUi(Dialog)
Dialog.show()
sys.exit(app.exec_())
if self.Dialog==None:
self.Dialog = QtGui.QDialog()
ui = about.Ui_Dialog()
ui.setupUi(self.Dialog)
self.Dialog.show()
#sys.exit(app.exec_())
def loadRelation(self):
res=QtGui.QInputDialog.getText(None, QtGui.QApplication.translate("Form", "New relation"),QtGui.QApplication.translate("Form", "Insert the name for the new relation"))
@ -98,31 +100,43 @@ class Ui_Form(object):
filename = QtGui.QFileDialog.getOpenFileName(None,QtGui.QApplication.translate("Form", "Load Relation"),"",QtGui.QApplication.translate("Form", "Relations (*.tlb);;Text Files (*.txt);;All Files (*)"))
self.relations[str(res[0].toUtf8())]=relation.relation(filename)
self.updateRelations()
def addProduct(self):
self.txtQuery.setText(self.txtQuery.text()+"*")
self.txtQuery.insert(u"*")
self.txtQuery.setFocus()
def addDifference(self):
self.txtQuery.setText(self.txtQuery.text()+u"-")
self.txtQuery.insert(u"-")
self.txtQuery.setFocus()
def addUnion(self):
self.txtQuery.setText(self.txtQuery.text()+u"")
self.txtQuery.insert(u"")
self.txtQuery.setFocus()
def addIntersection(self):
self.txtQuery.setText(self.txtQuery.text()+u"")
self.txtQuery.insert(u"")
self.txtQuery.setFocus()
def addOLeft(self):
self.txtQuery.setText(self.txtQuery.text()+u"ᐅLEFTᐊ")
self.txtQuery.insert(u"ᐅLEFTᐊ")
self.txtQuery.setFocus()
def addJoin(self):
self.txtQuery.setText(self.txtQuery.text()+u"ᐅᐊ")
self.txtQuery.insert(u"ᐅᐊ")
self.txtQuery.setFocus()
def addORight(self):
self.txtQuery.setText(self.txtQuery.text()+u"ᐅRIGHTᐊ")
self.txtQuery.insert(u"ᐅRIGHTᐊ")
self.txtQuery.setFocus()
def addOuter(self):
self.txtQuery.setText(self.txtQuery.text()+u"ᐅFULLᐊ")
self.txtQuery.insert(u"ᐅFULLᐊ")
self.txtQuery.setFocus()
def addProjection(self):
self.txtQuery.setText(self.txtQuery.text()+u"π")
self.txtQuery.insert(u"π")
self.txtQuery.setFocus()
def addSelection(self):
self.txtQuery.setText(self.txtQuery.text()+u"σ")
self.txtQuery.insert(u"σ")
self.txtQuery.setFocus()
def addRename(self):
self.txtQuery.setText(self.txtQuery.text()+u"ρ")
self.txtQuery.insert(u"ρ")
self.txtQuery.setFocus()
def addArrow(self):
self.txtQuery.setText(self.txtQuery.text()+u"")
self.txtQuery.insert(u"")
self.txtQuery.setFocus()
def setupUi(self, Form):
Form.setObjectName("Form")
@ -263,6 +277,7 @@ class Ui_Form(object):
self.label_2.setBuddy(self.txtQuery)
self.retranslateUi(Form)
QtCore.QObject.connect(self.txtQuery,QtCore.SIGNAL("returnPressed()"),self.execute)
QtCore.QObject.connect(self.cmdAbout,QtCore.SIGNAL("clicked()"),self.showAbout)
QtCore.QObject.connect(self.cmdProduct,QtCore.SIGNAL("clicked()"),self.addProduct)
QtCore.QObject.connect(self.cmdDifference,QtCore.SIGNAL("clicked()"),self.addDifference)

@ -24,7 +24,7 @@ import parser
import relation
import maingui
version="0.4rc1"
version="0.4"
if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)