Skip to content
Permalink
Browse files

some minor code cleanup in dbmanager

  • Loading branch information
Gustry authored and nyalldawson committed Feb 4, 2019
1 parent fd42980 commit ac9c6f1e18624b6e2d1fac4d27811ace7a92afe0
@@ -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,
@@ -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"))
@@ -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):
@@ -252,7 +251,6 @@ def executeSql(self):
if old_model:
old_model.deleteLater()

cols = []
quotedCols = []

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

# get all the columns
cols = []
quotedCols = []
connector = self.db.connector
if self.aliasSubQuery:
@@ -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:
@@ -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"))
@@ -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):
@@ -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)
@@ -351,7 +349,6 @@ def executeSqlCompleted(self):
DlgDbError.showError(self.modelAsync.error, self)
self.uniqueModel.clear()
self.geomCombo.clear()
pass

def executeSql(self):

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

# get all the columns
cols = []
quotedCols = []
connector = self.db.connector
if self.aliasSubQuery:
@@ -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:
@@ -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

0 comments on commit ac9c6f1

Please sign in to comment.
You can’t perform that action at this time.