Skip to content
Permalink
Browse files

switch DB Manager's SQL editor to QgsCodeEditorSQL

  • Loading branch information
alexbruy committed Nov 13, 2014
1 parent 9a2327c commit 22619996b569ec226662d6033b16ce1ded381474
@@ -24,6 +24,7 @@

from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4.Qsci import *
from qgis.core import *

from .db_plugins.plugin import BaseError
@@ -49,7 +50,7 @@ def __init__(self, iface, db, parent=None):

self.editSql.setFocus()
self.editSql.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
self.editSql.initCompleter(self.db)
self.initCompleter()

# allow to copy results
copyAction = QAction("copy", self)
@@ -284,3 +285,23 @@ def copySelectedResults(self):
QApplication.clipboard().setText( text, QClipboard.Selection )
QApplication.clipboard().setText( text, QClipboard.Clipboard )

def initCompleter(self):
dictionary = None
if self.db:
dictionary = self.db.connector.getSqlDictionary()
if not dictionary:
# use the generic sql dictionary
from .sql_dictionary import getSqlDictionary
dictionary = getSqlDictionary()

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

api = QsciAPIs(self.editSql.lexer())
for word in wordlist:
api.add(word)

api.prepare()
self.editSql.lexer().setAPIs(api)

This file was deleted.

@@ -70,7 +70,7 @@
</layout>
</item>
<item>
<widget class="SqlEdit" name="editSql"/>
<widget class="QgsCodeEditorSQL" name="editSql"/>
</item>
<item>
<layout class="QHBoxLayout">
@@ -356,9 +356,9 @@ columns</string>
</widget>
<customwidgets>
<customwidget>
<class>SqlEdit</class>
<class>QgsCodeEditorSQL</class>
<extends>QTextEdit</extends>
<header>..sqledit</header>
<header>qgscodeeditorsql.h</header>
</customwidget>
</customwidgets>
<tabstops>

0 comments on commit 2261999

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