- Can create relation classes from the table

- Can add new relations and edit current ones, it apparently works



git-svn-id: http://galileo.dmi.unict.it/svn/relational/trunk@325 014f5005-505e-4b48-8d0a-63407b615a7c
master
LtWorf 2011-10-13 18:44:20 +07:00
parent 144ee8fabc
commit 2f8e604d0d
8 changed files with 92 additions and 42 deletions

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

@ -22,6 +22,7 @@ try:
except:
from PySide import QtCore, QtGui
import compatibility
from relational import relation
import rel_edit
@ -78,11 +79,30 @@ class creatorForm(QtGui.QDialog):
self.table.setItem (0,1,i01)
self.table.setItem (1,0,i10)
self.table.setItem (1,1,i11)
def create_relation(self):
hlist=[]
for i in range(self.table.columnCount()):
hlist.append(compatibility.get_py_str(self.table.item(0,i).text()))
try:
header=relation.header(hlist)
except Exception, e:
QtGui.QMessageBox.information(None,QtGui.QApplication.translate("Form", "Error"),"%s\n%s" % (QtGui.QApplication.translate("Form", "Header error!"),e.__str__()) )
r=relation.relation()
r.header=header
for i in range(1,self.table.rowCount()):
hlist=[]
for j in range(self.table.columnCount()):
hlist.append(compatibility.get_py_str(self.table.item(i,j).text()))
r.content.add(tuple(hlist))
return r
def accept(self):
self.result_relation=self.create_relation()
QtGui.QDialog.accept(self)
pass
def reject(self):

@ -165,13 +165,42 @@ class relForm(QtGui.QMainWindow):
def editRelation(self):
import creator
for i in self.ui.lstRelations.selectedItems():
self.relations[compatibility.get_py_str(i.text())]=creator.editRelation(self.relations[compatibility.get_py_str(i.text())])
result=creator.editRelation(self.relations[compatibility.get_py_str(i.text())])
if result!=None:
self.relations[compatibility.get_py_str(i.text())]=result
self.updateRelations()
def newRelation(self):
import creator
creator.editRelation()
result=creator.editRelation()
if result==None:
return
res=QtGui.QInputDialog.getText(
self,
QtGui.QApplication.translate("Form", "New relation"),
QtGui.QApplication.translate("Form", "Insert the name for the new relation"),
QtGui.QLineEdit.Normal,'')
if res[1]==False or len(res[0])==0:
return
#Patch provided by Angelo 'Havoc' Puglisi
name=compatibility.get_py_str(res[0])
if not rtypes.is_valid_relation_name(name):
r=QtGui.QApplication.translate("Form", str("Wrong name for destination relation: %s." % name))
QtGui.QMessageBox.information(self,QtGui.QApplication.translate("Form", "Error"),r)
return
try:
self.relations[name]=result
except Exception, e:
print e
QtGui.QMessageBox.information(None,QtGui.QApplication.translate("Form", "Error"),"%s\n%s" % (QtGui.QApplication.translate("Form", "Check your query!"),e.__str__()) )
return
self.updateRelations()
#TODO chose name for the relation
def showSurvey(self):
if self.Survey==None:

@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'relational_gui/maingui.ui'
#
# Created: Thu Oct 13 19:00:44 2011
# Created: Thu Oct 13 20:42:44 2011
# by: PyQt4 UI code generator 4.8.3
#
# WARNING! All changes made in this file will be lost!
@ -148,21 +148,21 @@ class Ui_MainWindow(object):
self.lstRelations.setMaximumSize(QtCore.QSize(16777215, 16777215))
self.lstRelations.setObjectName(_fromUtf8("lstRelations"))
self.verticalLayout.addWidget(self.lstRelations)
self.cmdNew = QtGui.QPushButton(self.groupBox)
self.cmdNew.setObjectName(_fromUtf8("cmdNew"))
self.verticalLayout.addWidget(self.cmdNew)
self.cmdLoad = QtGui.QPushButton(self.groupBox)
self.cmdLoad.setObjectName(_fromUtf8("cmdLoad"))
self.verticalLayout.addWidget(self.cmdLoad)
self.cmdSave = QtGui.QPushButton(self.groupBox)
self.cmdSave.setObjectName(_fromUtf8("cmdSave"))
self.verticalLayout.addWidget(self.cmdSave)
self.cmdUnload = QtGui.QPushButton(self.groupBox)
self.cmdUnload.setObjectName(_fromUtf8("cmdUnload"))
self.verticalLayout.addWidget(self.cmdUnload)
self.cmdNew = QtGui.QPushButton(self.groupBox)
self.cmdNew.setObjectName(_fromUtf8("cmdNew"))
self.verticalLayout.addWidget(self.cmdNew)
self.cmdEdit = QtGui.QPushButton(self.groupBox)
self.cmdEdit.setObjectName(_fromUtf8("cmdEdit"))
self.verticalLayout.addWidget(self.cmdEdit)
self.cmdUnload = QtGui.QPushButton(self.groupBox)
self.cmdUnload.setObjectName(_fromUtf8("cmdUnload"))
self.verticalLayout.addWidget(self.cmdUnload)
self.groupBox_2 = QtGui.QGroupBox(self.splitter)
self.groupBox_2.setMinimumSize(QtCore.QSize(0, 0))
self.groupBox_2.setMaximumSize(QtCore.QSize(300, 16777215))
@ -334,11 +334,11 @@ class Ui_MainWindow(object):
self.cmdClearHistory.setText(QtGui.QApplication.translate("MainWindow", "Clear history", None, QtGui.QApplication.UnicodeUTF8))
self.groupBox.setTitle(QtGui.QApplication.translate("MainWindow", "Relations", None, QtGui.QApplication.UnicodeUTF8))
self.lstRelations.setSortingEnabled(True)
self.cmdNew.setText(QtGui.QApplication.translate("MainWindow", "New relation", None, QtGui.QApplication.UnicodeUTF8))
self.cmdLoad.setText(QtGui.QApplication.translate("MainWindow", "Load relation", None, QtGui.QApplication.UnicodeUTF8))
self.cmdSave.setText(QtGui.QApplication.translate("MainWindow", "Save relation", None, QtGui.QApplication.UnicodeUTF8))
self.cmdUnload.setText(QtGui.QApplication.translate("MainWindow", "Unload relation", None, QtGui.QApplication.UnicodeUTF8))
self.cmdNew.setText(QtGui.QApplication.translate("MainWindow", "New relation", None, QtGui.QApplication.UnicodeUTF8))
self.cmdEdit.setText(QtGui.QApplication.translate("MainWindow", "Edit relation", None, QtGui.QApplication.UnicodeUTF8))
self.cmdUnload.setText(QtGui.QApplication.translate("MainWindow", "Unload relation", None, QtGui.QApplication.UnicodeUTF8))
self.groupBox_2.setTitle(QtGui.QApplication.translate("MainWindow", "Attributes", None, QtGui.QApplication.UnicodeUTF8))
self.txtResult.setText(QtGui.QApplication.translate("MainWindow", "_last1", None, QtGui.QApplication.UnicodeUTF8))
self.label.setText(QtGui.QApplication.translate("MainWindow", "=", None, QtGui.QApplication.UnicodeUTF8))

@ -291,6 +291,13 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cmdNew">
<property name="text">
<string>New relation</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cmdLoad">
<property name="text">
@ -305,20 +312,6 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cmdUnload">
<property name="text">
<string>Unload relation</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cmdNew">
<property name="text">
<string>New relation</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cmdEdit">
<property name="text">
@ -326,6 +319,13 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cmdUnload">
<property name="text">
<string>Unload relation</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QGroupBox" name="groupBox_2">

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

@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'relational_pyside/maingui.ui'
#
# Created: Thu Oct 13 19:00:44 2011
# Created: Thu Oct 13 20:42:44 2011
# by: pyside-uic 0.2.13 running on PySide 1.0.7
#
# WARNING! All changes made in this file will be lost!
@ -143,21 +143,21 @@ class Ui_MainWindow(object):
self.lstRelations.setMaximumSize(QtCore.QSize(16777215, 16777215))
self.lstRelations.setObjectName("lstRelations")
self.verticalLayout.addWidget(self.lstRelations)
self.cmdNew = QtGui.QPushButton(self.groupBox)
self.cmdNew.setObjectName("cmdNew")
self.verticalLayout.addWidget(self.cmdNew)
self.cmdLoad = QtGui.QPushButton(self.groupBox)
self.cmdLoad.setObjectName("cmdLoad")
self.verticalLayout.addWidget(self.cmdLoad)
self.cmdSave = QtGui.QPushButton(self.groupBox)
self.cmdSave.setObjectName("cmdSave")
self.verticalLayout.addWidget(self.cmdSave)
self.cmdUnload = QtGui.QPushButton(self.groupBox)
self.cmdUnload.setObjectName("cmdUnload")
self.verticalLayout.addWidget(self.cmdUnload)
self.cmdNew = QtGui.QPushButton(self.groupBox)
self.cmdNew.setObjectName("cmdNew")
self.verticalLayout.addWidget(self.cmdNew)
self.cmdEdit = QtGui.QPushButton(self.groupBox)
self.cmdEdit.setObjectName("cmdEdit")
self.verticalLayout.addWidget(self.cmdEdit)
self.cmdUnload = QtGui.QPushButton(self.groupBox)
self.cmdUnload.setObjectName("cmdUnload")
self.verticalLayout.addWidget(self.cmdUnload)
self.groupBox_2 = QtGui.QGroupBox(self.splitter)
self.groupBox_2.setMinimumSize(QtCore.QSize(0, 0))
self.groupBox_2.setMaximumSize(QtCore.QSize(300, 16777215))
@ -329,11 +329,11 @@ class Ui_MainWindow(object):
self.cmdClearHistory.setText(QtGui.QApplication.translate("MainWindow", "Clear history", None, QtGui.QApplication.UnicodeUTF8))
self.groupBox.setTitle(QtGui.QApplication.translate("MainWindow", "Relations", None, QtGui.QApplication.UnicodeUTF8))
self.lstRelations.setSortingEnabled(True)
self.cmdNew.setText(QtGui.QApplication.translate("MainWindow", "New relation", None, QtGui.QApplication.UnicodeUTF8))
self.cmdLoad.setText(QtGui.QApplication.translate("MainWindow", "Load relation", None, QtGui.QApplication.UnicodeUTF8))
self.cmdSave.setText(QtGui.QApplication.translate("MainWindow", "Save relation", None, QtGui.QApplication.UnicodeUTF8))
self.cmdUnload.setText(QtGui.QApplication.translate("MainWindow", "Unload relation", None, QtGui.QApplication.UnicodeUTF8))
self.cmdNew.setText(QtGui.QApplication.translate("MainWindow", "New relation", None, QtGui.QApplication.UnicodeUTF8))
self.cmdEdit.setText(QtGui.QApplication.translate("MainWindow", "Edit relation", None, QtGui.QApplication.UnicodeUTF8))
self.cmdUnload.setText(QtGui.QApplication.translate("MainWindow", "Unload relation", None, QtGui.QApplication.UnicodeUTF8))
self.groupBox_2.setTitle(QtGui.QApplication.translate("MainWindow", "Attributes", None, QtGui.QApplication.UnicodeUTF8))
self.txtResult.setText(QtGui.QApplication.translate("MainWindow", "_last1", None, QtGui.QApplication.UnicodeUTF8))
self.label.setText(QtGui.QApplication.translate("MainWindow", "=", None, QtGui.QApplication.UnicodeUTF8))

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