Added ui buttons to use multi line optimization

This commit is contained in:
Salvo 'LtWorf' Tomaselli 2016-05-25 15:29:32 +02:00
parent 57ea58e516
commit 03d05cf7a8
2 changed files with 113 additions and 39 deletions

View File

@ -35,6 +35,7 @@ class relForm(QtWidgets.QMainWindow):
self.About = None self.About = None
self.Survey = None self.Survey = None
self.undo = None # UndoQueue for queries self.undo = None # UndoQueue for queries
self.undo_program = None
self.selectedRelation = None self.selectedRelation = None
self.ui = maingui.Ui_MainWindow() self.ui = maingui.Ui_MainWindow()
self.user_interface = UserInterface() self.user_interface = UserInterface()
@ -149,6 +150,19 @@ class relForm(QtWidgets.QMainWindow):
if self.undo != None: if self.undo != None:
self.ui.txtQuery.setText(self.undo) self.ui.txtQuery.setText(self.undo)
def undoOptimizeProgram(self):
if self.undo_program:
self.ui.txtMultiQuery.setPlainText(self.undo_program)
def optimizeProgram(self):
self.undo_program = self.ui.txtMultiQuery.toPlainText()
result = optimizer.optimize_program(
self.ui.txtMultiQuery.toPlainText(),
self.user_interface.relations
)
self.ui.txtMultiQuery.setPlainText(result)
def optimize(self): def optimize(self):
'''Performs all the possible optimizations on the query''' '''Performs all the possible optimizations on the query'''
self.undo = self.ui.txtQuery.text() # Storing the query in undo list self.undo = self.ui.txtQuery.text() # Storing the query in undo list

View File

@ -8,7 +8,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>637</width> <width>637</width>
<height>495</height> <height>496</height>
</rect> </rect>
</property> </property>
<property name="minimumSize"> <property name="minimumSize">
@ -172,6 +172,20 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QPushButton" name="cmdOptimizeProgram">
<property name="text">
<string>Optimize</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cmdUndoOptimizeProgram">
<property name="text">
<string>Undo optimize</string>
</property>
</widget>
</item>
<item> <item>
<spacer name="verticalSpacer"> <spacer name="verticalSpacer">
<property name="orientation"> <property name="orientation">
@ -1174,6 +1188,18 @@
<tabstop>cmdEdit</tabstop> <tabstop>cmdEdit</tabstop>
<tabstop>cmdUnload</tabstop> <tabstop>cmdUnload</tabstop>
<tabstop>cmdNewSession</tabstop> <tabstop>cmdNewSession</tabstop>
<tabstop>txtMultiQuery</tabstop>
<tabstop>cmdClearMultilineQuery</tabstop>
<tabstop>cmdExecuteMultiline</tabstop>
<tabstop>cmdOptimizeProgram</tabstop>
<tabstop>cmdUndoOptimizeProgram</tabstop>
<tabstop>cmdUndoOptimize</tabstop>
<tabstop>cmdClearHistory</tabstop>
<tabstop>txtQuery</tabstop>
<tabstop>cmdClearQuery</tabstop>
<tabstop>cmdExecute</tabstop>
<tabstop>lstHistory</tabstop>
<tabstop>cmdOptimize</tabstop>
</tabstops> </tabstops>
<resources/> <resources/>
<connections> <connections>
@ -1189,7 +1215,7 @@
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>79</x> <x>79</x>
<y>597</y> <y>495</y>
</hint> </hint>
</hints> </hints>
</connection> </connection>
@ -1205,7 +1231,7 @@
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>99</x> <x>99</x>
<y>605</y> <y>495</y>
</hint> </hint>
</hints> </hints>
</connection> </connection>
@ -1217,11 +1243,11 @@
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>516</x> <x>516</x>
<y>490</y> <y>491</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>773</x> <x>636</x>
<y>599</y> <y>495</y>
</hint> </hint>
</hints> </hints>
</connection> </connection>
@ -1233,11 +1259,11 @@
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>631</x> <x>631</x>
<y>422</y> <y>423</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>760</x> <x>636</x>
<y>610</y> <y>495</y>
</hint> </hint>
</hints> </hints>
</connection> </connection>
@ -1249,11 +1275,11 @@
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>516</x> <x>516</x>
<y>422</y> <y>423</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>753</x> <x>636</x>
<y>594</y> <y>495</y>
</hint> </hint>
</hints> </hints>
</connection> </connection>
@ -1268,8 +1294,8 @@
<y>328</y> <y>328</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>643</x> <x>636</x>
<y>611</y> <y>495</y>
</hint> </hint>
</hints> </hints>
</connection> </connection>
@ -1285,7 +1311,7 @@
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>510</x> <x>510</x>
<y>611</y> <y>495</y>
</hint> </hint>
</hints> </hints>
</connection> </connection>
@ -1377,7 +1403,7 @@
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>631</x> <x>631</x>
<y>456</y> <y>457</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>399</x> <x>399</x>
@ -1409,7 +1435,7 @@
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>516</x> <x>516</x>
<y>456</y> <y>457</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>399</x> <x>399</x>
@ -1472,8 +1498,8 @@
<slot>clear()</slot> <slot>clear()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>251</x> <x>394</x>
<y>256</y> <y>262</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>221</x> <x>221</x>
@ -1488,12 +1514,12 @@
<slot>execute()</slot> <slot>execute()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>251</x> <x>394</x>
<y>256</y> <y>296</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>795</x> <x>636</x>
<y>650</y> <y>495</y>
</hint> </hint>
</hints> </hints>
</connection> </connection>
@ -1505,11 +1531,11 @@
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>310</x> <x>310</x>
<y>491</y> <y>494</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>260</x> <x>260</x>
<y>490</y> <y>493</y>
</hint> </hint>
</hints> </hints>
</connection> </connection>
@ -1521,7 +1547,7 @@
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>394</x> <x>394</x>
<y>453</y> <y>459</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>395</x> <x>395</x>
@ -1537,11 +1563,11 @@
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>186</x> <x>186</x>
<y>453</y> <y>459</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>130</x> <x>130</x>
<y>623</y> <y>495</y>
</hint> </hint>
</hints> </hints>
</connection> </connection>
@ -1553,11 +1579,11 @@
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>296</x> <x>296</x>
<y>453</y> <y>459</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>544</x> <x>544</x>
<y>624</y> <y>495</y>
</hint> </hint>
</hints> </hints>
</connection> </connection>
@ -1569,11 +1595,11 @@
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>394</x> <x>394</x>
<y>491</y> <y>494</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>797</x> <x>636</x>
<y>627</y> <y>495</y>
</hint> </hint>
</hints> </hints>
</connection> </connection>
@ -1585,11 +1611,11 @@
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>260</x> <x>260</x>
<y>490</y> <y>493</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>796</x> <x>636</x>
<y>514</y> <y>495</y>
</hint> </hint>
</hints> </hints>
</connection> </connection>
@ -1605,7 +1631,7 @@
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>297</x> <x>297</x>
<y>620</y> <y>495</y>
</hint> </hint>
</hints> </hints>
</connection> </connection>
@ -1825,10 +1851,10 @@
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>631</x> <x>631</x>
<y>490</y> <y>491</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>796</x> <x>636</x>
<y>396</y> <y>396</y>
</hint> </hint>
</hints> </hints>
@ -1849,6 +1875,38 @@
</hint> </hint>
</hints> </hints>
</connection> </connection>
<connection>
<sender>cmdOptimizeProgram</sender>
<signal>clicked()</signal>
<receiver>MainWindow</receiver>
<slot>optimizeProgram()</slot>
<hints>
<hint type="sourcelabel">
<x>357</x>
<y>313</y>
</hint>
<hint type="destinationlabel">
<x>398</x>
<y>360</y>
</hint>
</hints>
</connection>
<connection>
<sender>cmdUndoOptimizeProgram</sender>
<signal>clicked()</signal>
<receiver>MainWindow</receiver>
<slot>undoOptimizeProgram()</slot>
<hints>
<hint type="sourcelabel">
<x>371</x>
<y>353</y>
</hint>
<hint type="destinationlabel">
<x>397</x>
<y>44</y>
</hint>
</hints>
</connection>
</connections> </connections>
<slots> <slots>
<slot>execute()</slot> <slot>execute()</slot>
@ -1886,5 +1944,7 @@
<slot>manageSessions()</slot> <slot>manageSessions()</slot>
<slot>setMultiline(bool)</slot> <slot>setMultiline(bool)</slot>
<slot>setHistoryShown(bool)</slot> <slot>setHistoryShown(bool)</slot>
<slot>optimizeProgram()</slot>
<slot>undoOptimizeProgram()</slot>
</slots> </slots>
</ui> </ui>