Re-unite query execution functions

For multi-line and single-line. After the change with the assignment
they are basically the same and there was no longer need
to have them separate in two functions.
master
Salvo 'LtWorf' Tomaselli 2016-01-03 09:18:31 +07:00
parent 03ae3e0bab
commit 474bea6ff5
1 changed files with 16 additions and 25 deletions

@ -168,45 +168,36 @@ class relForm(QtWidgets.QMainWindow):
itm = item.text()
self.ui.txtQuery.setText(itm)
def _run_multiline(self):
query = self.ui.txtMultiQuery.toPlainText()
self.settings.setValue('multiline/query', query)
try:
result = self.user_interface.multi_execute(query)
except Exception as e:
return self.error(e)
finally:
self.updateRelations()
self.selectedRelation = result
self.showRelation(self.selectedRelation)
def execute(self):
# Show the 'Processing' frame
self.ui.stackedWidget.setCurrentIndex(2)
QtCore.QCoreApplication.processEvents()
try:
'''Executes the query'''
if self.multiline:
return self._run_multiline()
# Single line query
res_rel,query = self.user_interface.split_query(self.ui.txtQuery.text())
query = self.ui.txtMultiQuery.toPlainText()
self.settings.setValue('multiline/query', query)
else:
query = self.ui.txtQuery.text()
try:
self.selectedRelation = self.user_interface.execute(query, res_rel)
self.updateRelations() # update the list
self.showRelation(self.selectedRelation)
self.selectedRelation = self.user_interface.multi_execute(query)
except Exception as e:
return self.error(e)
finally:
self.updateRelations() # update the list
self.showRelation(self.selectedRelation)
# Adds to history
hitem = QtWidgets.QListWidgetItem(None, 0)
hitem.setText(self.ui.txtQuery.text())
self.ui.lstHistory.addItem(hitem)
self.ui.lstHistory.setCurrentItem(hitem)
if not self.multiline:
# Adds to history
hitem = QtWidgets.QListWidgetItem(None, 0)
hitem.setText(query)
self.ui.lstHistory.addItem(hitem)
self.ui.lstHistory.setCurrentItem(hitem)
finally:
# Restore the normal frame
self.setMultiline(self.multiline)