Skip to content

Commit

Permalink
Fix #6995 (db manager's SQL window freezes with long query)
Browse files Browse the repository at this point in the history
  • Loading branch information
wonder-sk committed Feb 11, 2014
2 parents 7e1c1b9 + 6b74fee commit 61ff743
Show file tree
Hide file tree
Showing 6 changed files with 209 additions and 358 deletions.
2 changes: 0 additions & 2 deletions python/plugins/db_manager/LICENSE
Expand Up @@ -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)
Expand Down
132 changes: 0 additions & 132 deletions python/plugins/db_manager/completer.py

This file was deleted.

26 changes: 5 additions & 21 deletions python/plugins/db_manager/dlg_sql_window.py
Expand Up @@ -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):
Expand All @@ -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)
Expand Down Expand Up @@ -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 )
Expand Down Expand Up @@ -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))

Expand Down
185 changes: 0 additions & 185 deletions python/plugins/db_manager/highlighter.py

This file was deleted.

0 comments on commit 61ff743

Please sign in to comment.