- 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
This commit is contained in:
LtWorf 2011-03-20 21:49:02 +00:00
parent 6a93efd198
commit 4d78540440
4 changed files with 46 additions and 33 deletions

View File

@ -15,6 +15,8 @@
- Float type recognition is more robust, now handled using a regexp - 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 - 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 - 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 0.11
- Font is set only on windows (Rev 206) - Font is set only on windows (Rev 206)

View File

@ -85,7 +85,10 @@ class relForm(QtGui.QMainWindow):
history_item.append(self.ui.txtResult.text()) history_item.append(self.ui.txtResult.text())
history_item.append(u' = ') history_item.append(u' = ')
history_item.append(self.ui.txtQuery.text()) 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.qcounter+=1
self.ui.txtResult.setText(QtCore.QString(u"_last%d"% self.qcounter)) #Sets the result relation name to none 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 self.ui.table.resizeColumnToContents(i) #Must be done in order to avoid too small columns
def printRelation(self,*rel): def printRelation(self,item):
for i in rel: self.selectedRelation=self.relations[str(item.text().toUtf8())]
self.selectedRelation=self.relations[str(i.text().toUtf8())] self.showRelation(self.selectedRelation)
self.showRelation(self.selectedRelation)
def showAttributes(self,*other): def showAttributes(self,item):
'''Shows the attributes of the selected relation''' '''Shows the attributes of the selected relation'''
for i in other: rel=str(item.text().toUtf8())
rel=str(i.text().toUtf8()) self.ui.lstAttributes.clear()
self.ui.lstAttributes.clear() for j in self.relations[rel].header.attributes:
for j in self.relations[rel].header.attributes: self.ui.lstAttributes.addItem (j)
self.ui.lstAttributes.addItem (j)
def updateRelations(self): def updateRelations(self):
self.ui.lstRelations.clear() self.ui.lstRelations.clear()
@ -132,17 +133,16 @@ class relForm(QtGui.QMainWindow):
if i != "__builtins__": if i != "__builtins__":
self.ui.lstRelations.addItem(i) self.ui.lstRelations.addItem(i)
def saveRelation(self): 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 filename=str(filename.toUtf8()) #Converts QString to string
if (len(filename)==0):#Returns if no file was selected 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 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): def unloadRelation(self):
for i in self.ui.lstRelations.selectedItems(): for i in self.ui.lstRelations.selectedItems():
del self.relations[str(i.text().toUtf8())] del self.relations[str(i.text().toUtf8())]
@ -180,12 +180,7 @@ class relForm(QtGui.QMainWindow):
if len(defname)==0: if len(defname)==0:
return 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 if (defname.endswith(".csv")): #removes the extension
defname=defname[:-4] defname=defname[:-4]
@ -196,7 +191,7 @@ class relForm(QtGui.QMainWindow):
return return
#Patch provided by Angelo 'Havoc' Puglisi #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 else: #name was decided by caller
self.relations[name]=relation.relation(filename) self.relations[name]=relation.relation(filename)

View File

@ -1,8 +1,8 @@
# -*- coding: utf-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 # 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!
@ -96,6 +96,7 @@ class Ui_MainWindow(object):
self.table = QtGui.QTreeWidget(self.splitter_2) self.table = QtGui.QTreeWidget(self.splitter_2)
self.table.setMinimumSize(QtCore.QSize(450, 400)) self.table.setMinimumSize(QtCore.QSize(450, 400))
self.table.setSizeIncrement(QtCore.QSize(0, 0)) self.table.setSizeIncrement(QtCore.QSize(0, 0))
self.table.setRootIsDecorated(False)
self.table.setObjectName(_fromUtf8("table")) self.table.setObjectName(_fromUtf8("table"))
self.table.headerItem().setText(0, _fromUtf8("Empty relation")) self.table.headerItem().setText(0, _fromUtf8("Empty relation"))
self.layoutWidget1 = QtGui.QWidget(self.splitter_2) self.layoutWidget1 = QtGui.QWidget(self.splitter_2)
@ -122,6 +123,9 @@ class Ui_MainWindow(object):
self.lstHistory.setSizePolicy(sizePolicy) self.lstHistory.setSizePolicy(sizePolicy)
self.lstHistory.setMaximumSize(QtCore.QSize(16777215, 16777215)) self.lstHistory.setMaximumSize(QtCore.QSize(16777215, 16777215))
self.lstHistory.setBaseSize(QtCore.QSize(0, 0)) self.lstHistory.setBaseSize(QtCore.QSize(0, 0))
font = QtGui.QFont()
font.setStrikeOut(False)
self.lstHistory.setFont(font)
self.lstHistory.setObjectName(_fromUtf8("lstHistory")) self.lstHistory.setObjectName(_fromUtf8("lstHistory"))
self.verticalLayout_6.addWidget(self.lstHistory) self.verticalLayout_6.addWidget(self.lstHistory)
self.horizontalLayout_3 = QtGui.QHBoxLayout() 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.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.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.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.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.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.cmdUnload.setText(QtGui.QApplication.translate("MainWindow", "Unload relation", None, QtGui.QApplication.UnicodeUTF8))

View File

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