Skip to content

Commit

Permalink
some minor code cleanup in dbmanager
Browse files Browse the repository at this point in the history
  • Loading branch information
Gustry authored and nyalldawson committed Feb 4, 2019
1 parent fd42980 commit ac9c6f1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 20 deletions.
3 changes: 1 addition & 2 deletions python/plugins/db_manager/dlg_import_vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
from builtins import range

from qgis.PyQt.QtCore import Qt, QFileInfo
from qgis.PyQt.QtWidgets import QDialog, QFileDialog, QMessageBox, QApplication
from qgis.PyQt.QtGui import QCursor
from qgis.PyQt.QtWidgets import QDialog, QFileDialog, QMessageBox

from qgis.core import (QgsDataSourceUri,
QgsVectorLayer,
Expand Down
9 changes: 1 addition & 8 deletions python/plugins/db_manager/dlg_sql_layer_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def __init__(self, iface, layer, parent=None):
self.setWindowTitle(
u"%s - %s [%s]" % (self.windowTitle(), db.connection().connectionName(), db.connection().typeNameString()))

self.defaultLayerName = 'QueryLayer'
self.defaultLayerName = self.tr('QueryLayer')

if self.allowMultiColumnPk:
self.uniqueColumnCheck.setText(self.tr("Column(s) with unique values"))
Expand Down Expand Up @@ -230,7 +230,6 @@ def deletePreset(self):

def loadPreset(self, name):
query = QgsProject.instance().readEntry('DBManager', 'savedQueries/' + self.getQueryHash(name) + '/query')[0]
name = QgsProject.instance().readEntry('DBManager', 'savedQueries/' + self.getQueryHash(name) + '/name')[0]
self.editSql.setText(query)

def clearSql(self):
Expand All @@ -252,7 +251,6 @@ def executeSql(self):
if old_model:
old_model.deleteLater()

cols = []
quotedCols = []

try:
Expand Down Expand Up @@ -368,7 +366,6 @@ def fillColumnCombos(self):
query = query.strip()[:-1]

# get all the columns
cols = []
quotedCols = []
connector = self.db.connector
if self.aliasSubQuery:
Expand Down Expand Up @@ -462,10 +459,6 @@ def setColumnCombos(self, cols, quotedCols):
items[0].setCheckState(Qt.Checked)
else:
self.uniqueCombo.setEditText(defaultUniqueCol)
try:
pass
except:
pass

def copySelectedResults(self):
if len(self.viewResult.selectedIndexes()) <= 0:
Expand Down
12 changes: 2 additions & 10 deletions python/plugins/db_manager/dlg_sql_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def __init__(self, iface, db, parent=None):
self.setWindowTitle(
self.tr(u"{0} - {1} [{2}]").format(self.windowTitle(), self.connectionName, self.dbType))

self.defaultLayerName = 'QueryLayer'
self.defaultLayerName = self.tr('QueryLayer')

if self.allowMultiColumnPk:
self.uniqueColumnCheck.setText(self.tr("Column(s) with unique values"))
Expand Down Expand Up @@ -277,7 +277,6 @@ def deletePreset(self):

def loadPreset(self, name):
query = QgsProject.instance().readEntry('DBManager', 'savedQueries/' + self.getQueryHash(name) + '/query')[0]
name = QgsProject.instance().readEntry('DBManager', 'savedQueries/' + self.getQueryHash(name) + '/name')[0]
self.editSql.setText(query)

def loadAsLayerToggled(self, checked):
Expand Down Expand Up @@ -334,7 +333,6 @@ def executeSqlCompleted(self):
with OverrideCursor(Qt.WaitCursor):
if self.modelAsync.task.status() == QgsTask.Complete:
model = self.modelAsync.model
cols = []
quotedCols = []

self.viewResult.setModel(model)
Expand All @@ -351,7 +349,6 @@ def executeSqlCompleted(self):
DlgDbError.showError(self.modelAsync.error, self)
self.uniqueModel.clear()
self.geomCombo.clear()
pass

def executeSql(self):

Expand Down Expand Up @@ -452,7 +449,6 @@ def fillColumnCombos(self):
query = query.strip()[:-1]

# get all the columns
cols = []
quotedCols = []
connector = self.db.connector
if self.aliasSubQuery:
Expand Down Expand Up @@ -546,10 +542,6 @@ def setColumnCombos(self, cols, quotedCols):
items[0].setCheckState(Qt.Checked)
else:
self.uniqueCombo.setEditText(defaultUniqueCol)
try:
pass
except:
pass

def copySelectedResults(self):
if len(self.viewResult.selectedIndexes()) <= 0:
Expand All @@ -575,7 +567,7 @@ def initCompleter(self):
dictionary = getSqlDictionary()

wordlist = []
for _, value in dictionary.items():
for value in dictionary.values():
wordlist += value # concat lists
wordlist = list(set(wordlist)) # remove duplicates

Expand Down

0 comments on commit ac9c6f1

Please sign in to comment.