Form to send a survey

git-svn-id: http://galileo.dmi.unict.it/svn/relational/trunk@57 014f5005-505e-4b48-8d0a-63407b615a7c
master
LtWorf 2008-11-11 13:15:12 +07:00
parent 3f6c989212
commit 4bf2f915c6
5 changed files with 577 additions and 3 deletions

@ -42,4 +42,5 @@
- Changed internal rename method. Now uses a dictionary
- Optimized saving of relations
- Can save relations from gui
- Outer join methods simplified
- Outer join methods simplified
- Form to send a survey

@ -22,11 +22,14 @@ import relation
import parser
import sys
import about
import survey
import os
import surveyForm
class Ui_Form(object):
def __init__(self):
self.About=None
self.Survey=None
self.relations={} #Dictionary for relations
def execute(self):
try:
@ -101,6 +104,13 @@ class Ui_Form(object):
for i in self.lstRelations.selectedItems():
del self.relations[str(i.text().toUtf8())]
self.updateRelations()
def showSurvey(self):
if self.Survey==None:
self.Survey=surveyForm.surveyForm()
ui = survey.Ui_Form()
self.Survey.setUi(ui)
ui.setupUi(self.Survey)
self.Survey.show()
def showAbout(self):
if self.About==None:
self.About = QtGui.QDialog()
@ -180,8 +190,11 @@ class Ui_Form(object):
self.verticalLayout_8 = QtGui.QVBoxLayout(self.groupBox_4)
self.verticalLayout_8.setObjectName("verticalLayout_8")
self.cmdAbout = QtGui.QPushButton(self.groupBox_4)
self.cmdSurvey = QtGui.QPushButton(self.groupBox_4)
self.cmdAbout.setObjectName("cmdAbout")
self.cmdSurvey.setObjectName("cmdSurvey")
self.verticalLayout_8.addWidget(self.cmdAbout)
self.verticalLayout_8.addWidget(self.cmdSurvey)
self.verticalLayout_4.addWidget(self.groupBox_4)
self.groupBox = QtGui.QGroupBox(Form)
self.groupBox.setObjectName("groupBox")
@ -310,6 +323,7 @@ class Ui_Form(object):
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.cmdSurvey,QtCore.SIGNAL("clicked()"),self.showSurvey)
QtCore.QObject.connect(self.cmdProduct,QtCore.SIGNAL("clicked()"),self.addProduct)
QtCore.QObject.connect(self.cmdDifference,QtCore.SIGNAL("clicked()"),self.addDifference)
QtCore.QObject.connect(self.cmdUnion,QtCore.SIGNAL("clicked()"),self.addUnion)
@ -344,11 +358,13 @@ class Ui_Form(object):
Form.setTabOrder(self.cmdOuterLeft,self.cmdProjection)
Form.setTabOrder(self.cmdProjection,self.cmdRename)
Form.setTabOrder(self.cmdRename,self.cmdAbout)
Form.setTabOrder(self.cmdAbout,self.cmdSurvey)
def retranslateUi(self, Form):
Form.setWindowTitle(QtGui.QApplication.translate("Form", "Relational", None, QtGui.QApplication.UnicodeUTF8))
self.groupBox_4.setTitle(QtGui.QApplication.translate("Form", "Menu", None, QtGui.QApplication.UnicodeUTF8))
self.cmdAbout.setText(QtGui.QApplication.translate("Form", "Docs", None, QtGui.QApplication.UnicodeUTF8))
self.cmdSurvey.setText(QtGui.QApplication.translate("Form", "Survey", None, QtGui.QApplication.UnicodeUTF8))
self.groupBox.setTitle(QtGui.QApplication.translate("Form", "Operators", None, QtGui.QApplication.UnicodeUTF8))
self.cmdProduct.setToolTip(QtGui.QApplication.translate("Form", "Product operator", None, QtGui.QApplication.UnicodeUTF8))
self.cmdProduct.setText(QtGui.QApplication.translate("Form", "*", None, QtGui.QApplication.UnicodeUTF8))
@ -387,8 +403,7 @@ 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.cmdExecute.setText(QtGui.QApplication.translate("Form", "Execute", None, QtGui.QApplication.UnicodeUTF8))
if __name__ == "__main__":
import sys

@ -0,0 +1,114 @@
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'survey.ui'
#
# Created: Tue Nov 11 11:46:10 2008
# by: PyQt4 UI code generator 4.4.2
#
# WARNING! All changes made in this file will be lost!
from PyQt4 import QtCore, QtGui
class Ui_Form(object):
def setupUi(self, Form):
Form.setObjectName("Form")
Form.resize(400,322)
self.verticalLayout = QtGui.QVBoxLayout(Form)
self.verticalLayout.setObjectName("verticalLayout")
self.formLayout = QtGui.QGridLayout()
self.formLayout.setObjectName("formLayout")
self.txtSystem = QtGui.QLineEdit(Form)
self.txtSystem.setObjectName("txtSystem")
self.formLayout.addWidget(self.txtSystem,0,1,1,1)
self.label = QtGui.QLabel(Form)
self.label.setObjectName("label")
self.formLayout.addWidget(self.label,1,0,1,1)
self.txtCountry = QtGui.QLineEdit(Form)
self.txtCountry.setObjectName("txtCountry")
self.formLayout.addWidget(self.txtCountry,1,1,1,1)
self.label_2 = QtGui.QLabel(Form)
self.label_2.setObjectName("label_2")
self.formLayout.addWidget(self.label_2,2,0,1,1)
self.txtSchool = QtGui.QLineEdit(Form)
self.txtSchool.setObjectName("txtSchool")
self.formLayout.addWidget(self.txtSchool,2,1,1,1)
self.label_3 = QtGui.QLabel(Form)
self.label_3.setObjectName("label_3")
self.formLayout.addWidget(self.label_3,3,0,1,1)
self.txtAge = QtGui.QLineEdit(Form)
self.txtAge.setObjectName("txtAge")
self.formLayout.addWidget(self.txtAge,3,1,1,1)
self.label_4 = QtGui.QLabel(Form)
self.label_4.setObjectName("label_4")
self.formLayout.addWidget(self.label_4,4,0,1,1)
self.txtFind = QtGui.QLineEdit(Form)
self.txtFind.setObjectName("txtFind")
self.formLayout.addWidget(self.txtFind,4,1,1,1)
self.label_5 = QtGui.QLabel(Form)
self.label_5.setObjectName("label_5")
self.formLayout.addWidget(self.label_5,0,0,1,1)
self.label_6 = QtGui.QLabel(Form)
self.label_6.setObjectName("label_6")
self.formLayout.addWidget(self.label_6,5,0,1,1)
self.txtComments = QtGui.QTextEdit(Form)
self.txtComments.setTabChangesFocus(True)
self.txtComments.setObjectName("txtComments")
self.formLayout.addWidget(self.txtComments,5,1,1,1)
self.verticalLayout.addLayout(self.formLayout)
self.horizontalLayout = QtGui.QHBoxLayout()
self.horizontalLayout.setObjectName("horizontalLayout")
spacerItem = QtGui.QSpacerItem(40,20,QtGui.QSizePolicy.Expanding,QtGui.QSizePolicy.Minimum)
self.horizontalLayout.addItem(spacerItem)
self.cmdCancel = QtGui.QPushButton(Form)
self.cmdCancel.setObjectName("cmdCancel")
self.horizontalLayout.addWidget(self.cmdCancel)
self.cmdClear = QtGui.QPushButton(Form)
self.cmdClear.setObjectName("cmdClear")
self.horizontalLayout.addWidget(self.cmdClear)
self.cmdSend = QtGui.QPushButton(Form)
self.cmdSend.setObjectName("cmdSend")
self.horizontalLayout.addWidget(self.cmdSend)
self.verticalLayout.addLayout(self.horizontalLayout)
self.label.setBuddy(self.txtCountry)
self.label_2.setBuddy(self.txtSchool)
self.label_3.setBuddy(self.txtAge)
self.label_4.setBuddy(self.txtFind)
self.label_5.setBuddy(self.txtSystem)
self.label_6.setBuddy(self.txtComments)
self.retranslateUi(Form)
QtCore.QObject.connect(self.cmdCancel,QtCore.SIGNAL("clicked()"),Form.close)
QtCore.QObject.connect(self.cmdClear,QtCore.SIGNAL("clicked()"),self.txtComments.clear)
QtCore.QObject.connect(self.cmdClear,QtCore.SIGNAL("clicked()"),self.txtFind.clear)
QtCore.QObject.connect(self.cmdClear,QtCore.SIGNAL("clicked()"),self.txtAge.clear)
QtCore.QObject.connect(self.cmdClear,QtCore.SIGNAL("clicked()"),self.txtSchool.clear)
QtCore.QObject.connect(self.cmdClear,QtCore.SIGNAL("clicked()"),self.txtCountry.clear)
QtCore.QObject.connect(self.cmdClear,QtCore.SIGNAL("clicked()"),self.txtSystem.clear)
QtCore.QObject.connect(self.txtSystem,QtCore.SIGNAL("returnPressed()"),self.txtCountry.setFocus)
QtCore.QObject.connect(self.txtCountry,QtCore.SIGNAL("returnPressed()"),self.txtSchool.setFocus)
QtCore.QObject.connect(self.txtSchool,QtCore.SIGNAL("returnPressed()"),self.txtAge.setFocus)
QtCore.QObject.connect(self.txtAge,QtCore.SIGNAL("returnPressed()"),self.txtFind.setFocus)
QtCore.QObject.connect(self.txtFind,QtCore.SIGNAL("returnPressed()"),self.txtComments.setFocus)
QtCore.QObject.connect(self.cmdSend,QtCore.SIGNAL("clicked()"),Form.send)
QtCore.QMetaObject.connectSlotsByName(Form)
Form.setTabOrder(self.txtSystem,self.txtCountry)
Form.setTabOrder(self.txtCountry,self.txtSchool)
Form.setTabOrder(self.txtSchool,self.txtAge)
Form.setTabOrder(self.txtAge,self.txtFind)
Form.setTabOrder(self.txtFind,self.txtComments)
Form.setTabOrder(self.txtComments,self.cmdSend)
Form.setTabOrder(self.cmdSend,self.cmdClear)
Form.setTabOrder(self.cmdClear,self.cmdCancel)
def retranslateUi(self, Form):
Form.setWindowTitle(QtGui.QApplication.translate("Form", "Survey", None, QtGui.QApplication.UnicodeUTF8))
self.label.setText(QtGui.QApplication.translate("Form", "Country", None, QtGui.QApplication.UnicodeUTF8))
self.label_2.setText(QtGui.QApplication.translate("Form", "School", None, QtGui.QApplication.UnicodeUTF8))
self.label_3.setText(QtGui.QApplication.translate("Form", "Age", None, QtGui.QApplication.UnicodeUTF8))
self.label_4.setText(QtGui.QApplication.translate("Form", "How did you find relational", None, QtGui.QApplication.UnicodeUTF8))
self.label_5.setText(QtGui.QApplication.translate("Form", "System", None, QtGui.QApplication.UnicodeUTF8))
self.label_6.setText(QtGui.QApplication.translate("Form", "Comments", None, QtGui.QApplication.UnicodeUTF8))
self.cmdCancel.setText(QtGui.QApplication.translate("Form", "Cancel", None, QtGui.QApplication.UnicodeUTF8))
self.cmdClear.setText(QtGui.QApplication.translate("Form", "Clear", None, QtGui.QApplication.UnicodeUTF8))
self.cmdSend.setText(QtGui.QApplication.translate("Form", "Send", None, QtGui.QApplication.UnicodeUTF8))

@ -0,0 +1,388 @@
<ui version="4.0" >
<class>Form</class>
<widget class="QWidget" name="Form" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>322</height>
</rect>
</property>
<property name="windowTitle" >
<string>Survey</string>
</property>
<property name="locale" >
<locale country="UnitedStates" language="English" />
</property>
<layout class="QVBoxLayout" name="verticalLayout" >
<item>
<layout class="QGridLayout" name="formLayout" >
<item row="0" column="1" >
<widget class="QLineEdit" name="txtSystem" />
</item>
<item row="1" column="0" >
<widget class="QLabel" name="label" >
<property name="locale" >
<locale country="UnitedStates" language="English" />
</property>
<property name="text" >
<string>Country</string>
</property>
<property name="buddy" >
<cstring>txtCountry</cstring>
</property>
</widget>
</item>
<item row="1" column="1" >
<widget class="QLineEdit" name="txtCountry" />
</item>
<item row="2" column="0" >
<widget class="QLabel" name="label_2" >
<property name="locale" >
<locale country="UnitedStates" language="English" />
</property>
<property name="text" >
<string>School</string>
</property>
<property name="buddy" >
<cstring>txtSchool</cstring>
</property>
</widget>
</item>
<item row="2" column="1" >
<widget class="QLineEdit" name="txtSchool" />
</item>
<item row="3" column="0" >
<widget class="QLabel" name="label_3" >
<property name="locale" >
<locale country="UnitedStates" language="English" />
</property>
<property name="text" >
<string>Age</string>
</property>
<property name="buddy" >
<cstring>txtAge</cstring>
</property>
</widget>
</item>
<item row="3" column="1" >
<widget class="QLineEdit" name="txtAge" />
</item>
<item row="4" column="0" >
<widget class="QLabel" name="label_4" >
<property name="locale" >
<locale country="UnitedStates" language="English" />
</property>
<property name="text" >
<string>How did you find relational</string>
</property>
<property name="buddy" >
<cstring>txtFind</cstring>
</property>
</widget>
</item>
<item row="4" column="1" >
<widget class="QLineEdit" name="txtFind" />
</item>
<item row="0" column="0" >
<widget class="QLabel" name="label_5" >
<property name="locale" >
<locale country="UnitedStates" language="English" />
</property>
<property name="text" >
<string>System</string>
</property>
<property name="buddy" >
<cstring>txtSystem</cstring>
</property>
</widget>
</item>
<item row="5" column="0" >
<widget class="QLabel" name="label_6" >
<property name="text" >
<string>Comments</string>
</property>
<property name="buddy" >
<cstring>txtComments</cstring>
</property>
</widget>
</item>
<item row="5" column="1" >
<widget class="QTextEdit" name="txtComments" >
<property name="tabChangesFocus" >
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout" >
<item>
<spacer name="horizontalSpacer" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="cmdCancel" >
<property name="text" >
<string>Cancel</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cmdClear" >
<property name="text" >
<string>Clear</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cmdSend" >
<property name="text" >
<string>Send</string>
</property>
<property name="default" >
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<tabstops>
<tabstop>txtSystem</tabstop>
<tabstop>txtCountry</tabstop>
<tabstop>txtSchool</tabstop>
<tabstop>txtAge</tabstop>
<tabstop>txtFind</tabstop>
<tabstop>txtComments</tabstop>
<tabstop>cmdSend</tabstop>
<tabstop>cmdClear</tabstop>
<tabstop>cmdCancel</tabstop>
</tabstops>
<resources/>
<connections>
<connection>
<sender>cmdCancel</sender>
<signal>clicked()</signal>
<receiver>Form</receiver>
<slot>close()</slot>
<hints>
<hint type="sourcelabel" >
<x>228</x>
<y>294</y>
</hint>
<hint type="destinationlabel" >
<x>180</x>
<y>319</y>
</hint>
</hints>
</connection>
<connection>
<sender>cmdClear</sender>
<signal>clicked()</signal>
<receiver>txtComments</receiver>
<slot>clear()</slot>
<hints>
<hint type="sourcelabel" >
<x>288</x>
<y>298</y>
</hint>
<hint type="destinationlabel" >
<x>291</x>
<y>248</y>
</hint>
</hints>
</connection>
<connection>
<sender>cmdClear</sender>
<signal>clicked()</signal>
<receiver>txtFind</receiver>
<slot>clear()</slot>
<hints>
<hint type="sourcelabel" >
<x>270</x>
<y>294</y>
</hint>
<hint type="destinationlabel" >
<x>284</x>
<y>153</y>
</hint>
</hints>
</connection>
<connection>
<sender>cmdClear</sender>
<signal>clicked()</signal>
<receiver>txtAge</receiver>
<slot>clear()</slot>
<hints>
<hint type="sourcelabel" >
<x>269</x>
<y>299</y>
</hint>
<hint type="destinationlabel" >
<x>257</x>
<y>123</y>
</hint>
</hints>
</connection>
<connection>
<sender>cmdClear</sender>
<signal>clicked()</signal>
<receiver>txtSchool</receiver>
<slot>clear()</slot>
<hints>
<hint type="sourcelabel" >
<x>310</x>
<y>299</y>
</hint>
<hint type="destinationlabel" >
<x>317</x>
<y>87</y>
</hint>
</hints>
</connection>
<connection>
<sender>cmdClear</sender>
<signal>clicked()</signal>
<receiver>txtCountry</receiver>
<slot>clear()</slot>
<hints>
<hint type="sourcelabel" >
<x>298</x>
<y>303</y>
</hint>
<hint type="destinationlabel" >
<x>326</x>
<y>47</y>
</hint>
</hints>
</connection>
<connection>
<sender>cmdClear</sender>
<signal>clicked()</signal>
<receiver>txtSystem</receiver>
<slot>clear()</slot>
<hints>
<hint type="sourcelabel" >
<x>287</x>
<y>303</y>
</hint>
<hint type="destinationlabel" >
<x>302</x>
<y>18</y>
</hint>
</hints>
</connection>
<connection>
<sender>txtSystem</sender>
<signal>returnPressed()</signal>
<receiver>txtCountry</receiver>
<slot>setFocus()</slot>
<hints>
<hint type="sourcelabel" >
<x>213</x>
<y>22</y>
</hint>
<hint type="destinationlabel" >
<x>224</x>
<y>52</y>
</hint>
</hints>
</connection>
<connection>
<sender>txtCountry</sender>
<signal>returnPressed()</signal>
<receiver>txtSchool</receiver>
<slot>setFocus()</slot>
<hints>
<hint type="sourcelabel" >
<x>268</x>
<y>54</y>
</hint>
<hint type="destinationlabel" >
<x>276</x>
<y>89</y>
</hint>
</hints>
</connection>
<connection>
<sender>txtSchool</sender>
<signal>returnPressed()</signal>
<receiver>txtAge</receiver>
<slot>setFocus()</slot>
<hints>
<hint type="sourcelabel" >
<x>355</x>
<y>85</y>
</hint>
<hint type="destinationlabel" >
<x>358</x>
<y>118</y>
</hint>
</hints>
</connection>
<connection>
<sender>txtAge</sender>
<signal>returnPressed()</signal>
<receiver>txtFind</receiver>
<slot>setFocus()</slot>
<hints>
<hint type="sourcelabel" >
<x>375</x>
<y>123</y>
</hint>
<hint type="destinationlabel" >
<x>375</x>
<y>156</y>
</hint>
</hints>
</connection>
<connection>
<sender>txtFind</sender>
<signal>returnPressed()</signal>
<receiver>txtComments</receiver>
<slot>setFocus()</slot>
<hints>
<hint type="sourcelabel" >
<x>332</x>
<y>154</y>
</hint>
<hint type="destinationlabel" >
<x>335</x>
<y>200</y>
</hint>
</hints>
</connection>
<connection>
<sender>cmdSend</sender>
<signal>clicked()</signal>
<receiver>Form</receiver>
<slot>send()</slot>
<hints>
<hint type="sourcelabel" >
<x>381</x>
<y>309</y>
</hint>
<hint type="destinationlabel" >
<x>396</x>
<y>320</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>send()</slot>
</slots>
</ui>

@ -0,0 +1,56 @@
# Relational
# Copyright (C) 2008 Salvo "LtWorf" Tomaselli
#
# Relation is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# author Salvo "LtWorf" Tomaselli <tiposchi@tiscali.it>
from PyQt4 import QtCore, QtGui
import httplib
import urllib
class surveyForm (QtGui.QWidget):
'''This class is the form used for the survey, needed to intercept the events'''
def setUi(self,ui):
self.ui=ui
def send(self):
#Creates the string
post="Relational algebra\n"
post+="system:" + str(self.ui.txtSystem.text().toUtf8())+ "\n"
post+="country:" + str(self.ui.txtCountry.text().toUtf8())+ "\n"
post+="school:" + str(self.ui.txtSchool.text().toUtf8())+ "\n"
post+="age:" + str(self.ui.txtAge.text().toUtf8())+ "\n"
post+="find:" + str(self.ui.txtFind.text().toUtf8())+ "\n"
post+="comments:" + str(self.ui.txtComments.toPlainText().toUtf8())
self.ui.txtSystem.clear()
self.ui.txtCountry.clear()
self.ui.txtSchool.clear()
self.ui.txtAge.clear()
self.ui.txtFind.clear()
self.ui.txtComments.clear()
#sends the string
params = urllib.urlencode({'survey':post})
headers = {"Content-type": "application/x-www-form-urlencoded","Accept": "text/plain"}
connection = httplib.HTTPConnection('galileo.dmi.unict.it')
connection.request("POST","/~ltworf/survey.php",params,headers)
response=connection.getresponse()
if response.status!=200:
QtGui.QMessageBox.information(None,QtGui.QApplication.translate("Form", "Error"),QtGui.QApplication.translate("Form", "Unable to send the data!") )
else:
QtGui.QMessageBox.information(None,QtGui.QApplication.translate("Form", "Thanks"),QtGui.QApplication.translate("Form", "Thanks for sending!") )
self.hide()