Skip to content
Permalink
Browse files
[db manager] use QScintilla for SQL window
  • Loading branch information
alexbruy committed Feb 11, 2014
1 parent e6c2ecd commit 83baa914bdc4c26ac7ec71499602a63742be570c
@@ -50,10 +50,10 @@ def __init__(self, iface, db, parent=None):
settings = QSettings()
self.restoreGeometry(settings.value("/DB_Manager/sqlWindow/geometry", QByteArray(), type=QByteArray))

self.editSql.setAcceptRichText(False)
self.editSql.setFocus()
SqlCompleter(self.editSql, self.db)
SqlHighlighter(self.editSql, self.db)
self.editSql.initCompleter(self.db)
#SqlCompleter(self.editSql, self.db)
#SqlHighlighter(self.editSql, self.db)

# allow to copy results
copyAction = QAction("copy", self)
@@ -95,7 +95,7 @@ def updatePresetsCombobox(self):
self.presetCombo.setCurrentIndex(-1)

def storePreset(self):
query = self.editSql.toPlainText()
query = self.editSql.text()
name = self.presetName.text()
QgsProject.instance().writeEntry('DBManager','savedQueries/q'+str(name.__hash__())+'/name', name )
QgsProject.instance().writeEntry('DBManager','savedQueries/q'+str(name.__hash__())+'/query', query )
@@ -128,24 +128,13 @@ def loadAsLayerToggled(self, checked):
self.loadAsLayerGroup.setChecked( checked )
self.loadAsLayerWidget.setVisible( checked )

def getSql(self):
# If the selection obtained from an editor spans a line break,
# the text will contain a Unicode U+2029 paragraph separator
# character instead of a newline \n character
# (see https://qt-project.org/doc/qt-4.8/qtextcursor.html#selectedText)
sql = self.editSql.textCursor().selectedText().replace(unichr(0x2029), "\n")
if sql == "":
sql = self.editSql.toPlainText()
# try to sanitize query
sql = re.sub( ";\\s*$", "", sql )
return sql

def clearSql(self):
self.editSql.clear()

def executeSql(self):
sql = self.getSql()
if sql == "": return
sql = self.editSql.text()
if sql == "":
return

QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))

This file was deleted.

0 comments on commit 83baa91

Please sign in to comment.