Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #1686 from alexbruy/dbmanager-sqleditor
switch DB Manager's SQL editor to QgsCodeEditorSQL
  • Loading branch information
alexbruy committed Nov 17, 2014
2 parents 150aa53 + ad88108 commit 77328b2
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 205 deletions.
24 changes: 23 additions & 1 deletion python/plugins/db_manager/dlg_sql_window.py
Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -284,3 +285,24 @@ 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)
self.editSql.setAutoCompletionCaseSensitivity(False)
201 changes: 0 additions & 201 deletions python/plugins/db_manager/sqledit.py

This file was deleted.

6 changes: 3 additions & 3 deletions python/plugins/db_manager/ui/DlgSqlWindow.ui
Expand Up @@ -70,7 +70,7 @@
</layout>
</item>
<item>
<widget class="SqlEdit" name="editSql"/>
<widget class="QgsCodeEditorSQL" name="editSql"/>
</item>
<item>
<layout class="QHBoxLayout">
Expand Down Expand Up @@ -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>
Expand Down

0 comments on commit 77328b2

Please sign in to comment.