Skip to content
Permalink
Browse files
Fix #6995 (db manager's SQL window freezes with long query)
  • Loading branch information
wonder-sk committed Feb 11, 2014
2 parents 7e1c1b9 + 6b74fee commit 61ff7432107da0a7ce991f68094b9f42dd1027a5
@@ -6,8 +6,6 @@ http://www.gnu.org/copyleft/gpl.html

Code:
- some code is derived from PG_Manager by Martin Dobias (GPLv2 license)
- highlighter is based on "Python Syntax Highlighting Example" by Carson J. Q. Farmer (GPLv2 license)
- autocompletion based on "QTextEdit with autocompletion using pyqt" by rowinggolfer (GPLv2 license)

Icons:
- toolbar icons are derived from gis-0.1 iconset by Robert Szczepanek (Creative Commons Attribution-Share Alike 3.0 Unported license)

This file was deleted.

@@ -31,9 +31,6 @@

from .ui.ui_DlgSqlWindow import Ui_DbManagerDlgSqlWindow as Ui_Dialog

from .highlighter import SqlHighlighter
from .completer import SqlCompleter

import re

class DlgSqlWindow(QDialog, Ui_Dialog):
@@ -50,10 +47,8 @@ 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)

# allow to copy results
copyAction = QAction("copy", self)
@@ -95,7 +90,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 +123,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 61ff743

Please sign in to comment.