- Relation list is sorted

- Selects last item of history (so it scrolls)
- Fixes saving relations
- Simplified code, removing useless iterations



git-svn-id: http://galileo.dmi.unict.it/svn/relational/trunk@281 014f5005-505e-4b48-8d0a-63407b615a7c
master
LtWorf 2011-03-20 21:49:02 +07:00
parent 6a93efd198
commit 4d78540440
4 changed files with 46 additions and 33 deletions

@ -15,6 +15,8 @@
- Float type recognition is more robust, now handled using a regexp
- Date type recognition is more robust, now using a combination of regexp plus date object
- Parsing of strings representing dates is now cached, eliminating the need for double parse
- Restyle of the GUI
- Adds history in the GUI
0.11
- Font is set only on windows (Rev 206)

@ -85,7 +85,10 @@ class relForm(QtGui.QMainWindow):
history_item.append(self.ui.txtResult.text())
history_item.append(u' = ')
history_item.append(self.ui.txtQuery.text())
self.ui.lstHistory.addItem (history_item)
hitem=QtGui.QListWidgetItem(None,0)
hitem.setText(history_item)
self.ui.lstHistory.addItem (hitem)
self.ui.lstHistory.setCurrentItem(hitem)
self.qcounter+=1
self.ui.txtResult.setText(QtCore.QString(u"_last%d"% self.qcounter)) #Sets the result relation name to none
@ -113,18 +116,16 @@ class relForm(QtGui.QMainWindow):
self.ui.table.resizeColumnToContents(i) #Must be done in order to avoid too small columns
def printRelation(self,*rel):
for i in rel:
self.selectedRelation=self.relations[str(i.text().toUtf8())]
self.showRelation(self.selectedRelation)
def printRelation(self,item):
self.selectedRelation=self.relations[str(item.text().toUtf8())]
self.showRelation(self.selectedRelation)
def showAttributes(self,*other):
def showAttributes(self,item):
'''Shows the attributes of the selected relation'''
for i in other:
rel=str(i.text().toUtf8())
self.ui.lstAttributes.clear()
for j in self.relations[rel].header.attributes:
self.ui.lstAttributes.addItem (j)
rel=str(item.text().toUtf8())
self.ui.lstAttributes.clear()
for j in self.relations[rel].header.attributes:
self.ui.lstAttributes.addItem (j)
def updateRelations(self):
self.ui.lstRelations.clear()
@ -132,17 +133,16 @@ class relForm(QtGui.QMainWindow):
if i != "__builtins__":
self.ui.lstRelations.addItem(i)
def saveRelation(self):
filename = QtGui.QFileDialog.getSaveFileName(self,QtGui.QApplication.translate("Form", "Save Relation"),"",QtGui.QApplication.translate("Form", "Relations (*.csv)"))
filename = QtGui.QFileDialog.getSaveFileName(self,QtGui.QApplication.translate("Form", "Save Relation"),"",QtGui.QApplication.translate("Form", "Relations (*.csv)"))
filename=str(filename.toUtf8()) #Converts QString to string
if (len(filename)==0):#Returns if no file was selected
filename=str(filename.toUtf8()) #Converts QString to string
if (len(filename)==0):#Returns if no file was selected
return
#if (not filename.endswith(".csv")):#Adds extension if needed
# filename+=".csv"
self.selectedRelation.save(filename)
#self.relations[str(self.ui.lstRelations.selectedItems()[0].text().toUtf8())].save(filename)
return
if (not filename.endswith(".csv")):#Adds extension if needed
filename+=".csv"
for i in self.ui.lstRelations.selectedItems():
self.ui.relations[str(i.text().toUtf8())].save(filename)
return
def unloadRelation(self):
for i in self.ui.lstRelations.selectedItems():
del self.relations[str(i.text().toUtf8())]
@ -180,12 +180,7 @@ class relForm(QtGui.QMainWindow):
if len(defname)==0:
return
use_csv=True
if defname.endswith(".tlb"):
defname=defname[:-4]
use_csv=False #Old format, not using csv
if (defname.endswith(".csv")): #removes the extension
defname=defname[:-4]
@ -196,7 +191,7 @@ class relForm(QtGui.QMainWindow):
return
#Patch provided by Angelo 'Havoc' Puglisi
self.relations[str(res[0].toUtf8())]=relation.relation(str(filename.toUtf8()),use_csv)
self.relations[str(res[0].toUtf8())]=relation.relation(str(filename.toUtf8()))
else: #name was decided by caller
self.relations[name]=relation.relation(filename)

@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'relational_gui/maingui.ui'
# Form implementation generated from reading ui file 'maingui.ui'
#
# Created: Sun Mar 20 21:59:01 2011
# Created: Sun Mar 20 22:33:26 2011
# by: PyQt4 UI code generator 4.8.3
#
# WARNING! All changes made in this file will be lost!
@ -96,6 +96,7 @@ class Ui_MainWindow(object):
self.table = QtGui.QTreeWidget(self.splitter_2)
self.table.setMinimumSize(QtCore.QSize(450, 400))
self.table.setSizeIncrement(QtCore.QSize(0, 0))
self.table.setRootIsDecorated(False)
self.table.setObjectName(_fromUtf8("table"))
self.table.headerItem().setText(0, _fromUtf8("Empty relation"))
self.layoutWidget1 = QtGui.QWidget(self.splitter_2)
@ -122,6 +123,9 @@ class Ui_MainWindow(object):
self.lstHistory.setSizePolicy(sizePolicy)
self.lstHistory.setMaximumSize(QtCore.QSize(16777215, 16777215))
self.lstHistory.setBaseSize(QtCore.QSize(0, 0))
font = QtGui.QFont()
font.setStrikeOut(False)
self.lstHistory.setFont(font)
self.lstHistory.setObjectName(_fromUtf8("lstHistory"))
self.verticalLayout_6.addWidget(self.lstHistory)
self.horizontalLayout_3 = QtGui.QHBoxLayout()
@ -301,6 +305,7 @@ class Ui_MainWindow(object):
self.cmdUndoOptimize.setText(QtGui.QApplication.translate("MainWindow", "Undo optimize", None, QtGui.QApplication.UnicodeUTF8))
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.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))

@ -182,6 +182,9 @@
<height>0</height>
</size>
</property>
<property name="rootIsDecorated">
<bool>false</bool>
</property>
<column>
<property name="text">
<string notr="true">Empty relation</string>
@ -234,6 +237,11 @@
<height>0</height>
</size>
</property>
<property name="font">
<font>
<strikeout>false</strikeout>
</font>
</property>
</widget>
</item>
<item>
@ -299,6 +307,9 @@
<height>16777215</height>
</size>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
</widget>
</item>
<item>
@ -892,7 +903,7 @@
<sender>lstRelations</sender>
<signal>itemDoubleClicked(QListWidgetItem*)</signal>
<receiver>MainWindow</receiver>
<slot>printRelation()</slot>
<slot>printRelation(QListWidgetItem*)</slot>
<hints>
<hint type="sourcelabel">
<x>708</x>
@ -908,7 +919,7 @@
<sender>lstRelations</sender>
<signal>itemClicked(QListWidgetItem*)</signal>
<receiver>MainWindow</receiver>
<slot>showAttributes()</slot>
<slot>showAttributes(QListWidgetItem*)</slot>
<hints>
<hint type="sourcelabel">
<x>615</x>
@ -977,8 +988,8 @@
<slot>saveRelation()</slot>
<slot>insertTuple()</slot>
<slot>deleteTuple()</slot>
<slot>printRelation()</slot>
<slot>showAttributes()</slot>
<slot>printRelation(QListWidgetItem*)</slot>
<slot>showAttributes(QListWidgetItem*)</slot>
<slot>loadQuery()</slot>
<slot>resumeHistory(QListWidgetItem*)</slot>
</slots>