Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c5c4c7e
commit 3c5b3bb
Showing
101 changed files
with
12,723 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
*.pyc | ||
*~ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
SET (DB_MANAGER_PLUGIN_DIR ${QGIS_DATA_DIR}/python/plugins/db_manager) | ||
|
||
FILE(GLOB OTHER_FILES LICENCE README TODO) | ||
FILE(GLOB PY_FILES *.py) | ||
|
||
FILE(GLOB UI_FILES ui/*.ui) | ||
PYQT4_WRAP_UI(PYUI_FILES ${UI_FILES}) | ||
PYQT4_ADD_RESOURCES(PYRC_FILES resources.qrc) | ||
ADD_CUSTOM_TARGET(db_manager ALL DEPENDS ${PYUI_FILES} ${PYRC_FILES}) | ||
|
||
INSTALL(FILES ${OTHER_FILES} DESTINATION ${DB_MANAGER_PLUGIN_DIR}) | ||
INSTALL(FILES ${PY_FILES} DESTINATION ${DB_MANAGER_PLUGIN_DIR}) | ||
INSTALL(FILES ui/__init__.py ${PYUI_FILES} DESTINATION ${DB_MANAGER_PLUGIN_DIR}/ui) | ||
INSTALL(FILES ${PYRC_FILES} DESTINATION ${DB_MANAGER_PLUGIN_DIR}) | ||
|
||
ADD_SUBDIRECTORY(db_plugins) | ||
ADD_SUBDIRECTORY(icons) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
CREDITS: 2011/10/13 | ||
|
||
DB Manager plugin for QuantumGIS | ||
|
||
Author and maintainer: | ||
Giuseppe Sucameli <brush.tyler@gmail.com> | ||
|
||
|
||
The following is a list of contributors who have participated in the project: | ||
|
||
Version 0.1.18 includes: | ||
- autocompletion based on "QTextEdit with autocompletion using pyqt" by rowinggolfer (see http://rowinggolfer.blogspot.com/2010/08/qtextedit-with-autocompletion-using.html) | ||
|
||
Version 0.1.5 includes patches from: | ||
- Sandro Santilli <strk@keybit.net> for plugin icon. | ||
|
||
Version 0.1.2 includes: | ||
- syntax highlighting based on "Python Syntax Highlighting Example" by Carson J. Q. Farmer (see http://www.carsonfarmer.com/?p=333) | ||
- TopoViewer plugin based on qgis_pgis_topoview by Sandro Santilli <strk@keybit.net> (see at https://github.com/strk/qgis_pgis_topoview/) | ||
|
||
Version 0.1.0 includes patches from: | ||
- Mauricio de Paulo <mauricio.dev@gmail.com> for PostGIS Rasters support. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
DB Manager * Copyright (c) 2011 Giuseppe Sucameli | ||
|
||
Licensed under the terms of GNU GPL v2 (or any layer) | ||
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) | ||
- refresh toolbar icon is from Tango project (public domain) | ||
- table, view and namespace icons in database view are from pgAdmin3 (BSD license) | ||
- other icons are from QGIS project (GPLv2 license) | ||
- plugin icon by Sandro Santilli, using qgis icon and database icon by Dracos - http://commons.wikimedia.org/wiki/File:Applications-database.svg (Creative Commons Attribution-Share Alike 3.0 Unported license) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
DB Manager * Copyright (c) 2011 Giuseppe Sucameli | ||
|
||
DB Manager is a database manager plugin for QuantumGIS. | ||
It allows to you to show the DBs contents and run query on them. | ||
|
||
In this moment DB Manager supports the following DBMS backends: | ||
- PostgreSQL/PostGIS through the psycopg2 pymodule | ||
- SQLite/SpatiaLite using the pyspatialite pymodule | ||
|
||
|
||
For more info about the project, see at the wiki page: | ||
http://www.qgis.org/wiki/DB_Manager_plugin_GSoC_2011 | ||
|
||
or visit my GitHub repository: | ||
https://github.com/brushtyler/db_manager | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
DB Manager TODO and DONE list. | ||
|
||
|
||
DONE: | ||
* run only the selected part of a query (v0.1.20) | ||
* add versioning support to PostgreSQL dbs (v0.1.19) | ||
* completer for sql keywords/functions (v0.1.18) | ||
* highlights PG and SL functions, fix slow connection to PG db (v0.1.17) | ||
* add contestual menu to db tree, use service param when available to connect to PG dbs (v0.1.16) | ||
* close transactions before doing changes to tables (v0.1.15) | ||
* improve error handling running a query in sql window (v0.1.14) | ||
* fix error dialog (v0.1.13) | ||
* improve error handling, add Re-connect button (v0.1.12) | ||
* add "Run Vacuum" and "Move to schema" to menu (v0.1.11) | ||
* fix encoding support and import layer on Win (v0.1.10) | ||
* allow to copy contents from views (v0.1.9) | ||
* GUI to import data by drag'n'drop (v0.1.8) | ||
* edit table (v0.1.8) | ||
* create table (v0.1.7) | ||
* display schemas and tables comments (v0.1.6) | ||
* SQL syntax highlighting (v0.1.5) | ||
* load a query as layer into canvas (v0.1.4) | ||
* import/export OGR layers and non-spatial data using Import Vector Layer feature (v.0.1.0) | ||
|
||
|
||
TODO: | ||
- PGManager | ||
* GUI to import/export data (from shapefiles) | ||
- RT_Sql_Layer | ||
* query builder | ||
* query manager | ||
- QSpatialite | ||
* GUI to import QGis layer | ||
- SPIT | ||
* mass import of shapefiles |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
""" | ||
/*************************************************************************** | ||
Name : DB Manager | ||
Description : Database manager plugin for QuantumGIS | ||
Date : May 23, 2011 | ||
copyright : (C) 2011 by Giuseppe Sucameli | ||
email : brush.tyler@gmail.com | ||
***************************************************************************/ | ||
/*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
""" | ||
|
||
def name(): | ||
return "DB Manager" | ||
|
||
def description(): | ||
return "Manage your databases within QGis" | ||
|
||
def version(): | ||
return "0.1.19" | ||
|
||
def qgisMinimumVersion(): | ||
return "1.5.0" | ||
|
||
def icon(): | ||
return "icons/dbmanager.png" | ||
|
||
def authorName(): | ||
return "Giuseppe Sucameli" | ||
|
||
def classFactory(iface): | ||
from .db_manager_plugin import DBManagerPlugin | ||
return DBManagerPlugin(iface) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
""" | ||
/*************************************************************************** | ||
Name : DB Manager | ||
Description : Database manager plugin for QuantumGIS | ||
Date : May 23, 2011 | ||
copyright : (C) 2011 by Giuseppe Sucameli | ||
email : brush.tyler@gmail.com | ||
The content of this file is based on | ||
- QTextEdit with autocompletion using pyqt by rowinggolfer (GPLv2 license) | ||
see http://rowinggolfer.blogspot.com/2010/08/qtextedit-with-autocompletion-using.html | ||
***************************************************************************/ | ||
/*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
""" | ||
|
||
from PyQt4.QtGui import * | ||
from PyQt4.QtCore import * | ||
|
||
class SqlCompleter(QCompleter): | ||
def __init__(self, editor, db=None): | ||
# get the wordlist | ||
dictionary = None | ||
if db: | ||
dictionary = db.connector.getSqlDictionary() | ||
if not dictionary: | ||
# use the generic sql dictionary | ||
from .sql_dictionary import getSqlDictionary | ||
dictionary = getSqlDictionary() | ||
|
||
wordlist = QStringList() | ||
for name, value in dictionary.iteritems(): | ||
wordlist << value | ||
|
||
# setup the completer | ||
QCompleter.__init__(self, sorted(wordlist), editor) | ||
self.setModelSorting(QCompleter.CaseInsensitivelySortedModel) | ||
self.setWrapAround(False) | ||
|
||
if isinstance(editor, CompletionTextEdit): | ||
editor.setCompleter(self) | ||
|
||
|
||
class CompletionTextEdit(QTextEdit): | ||
def __init__(self, *args, **kwargs): | ||
QTextEdit.__init__(self, *args, **kwargs) | ||
self.completer = None | ||
|
||
def setCompleter(self, completer): | ||
if self.completer: | ||
self.disconnect(self.completer, 0, self, 0) | ||
if not completer: | ||
return | ||
|
||
completer.setWidget(self) | ||
completer.setCompletionMode(QCompleter.PopupCompletion) | ||
completer.setCaseSensitivity(Qt.CaseInsensitive) | ||
self.completer = completer | ||
self.connect(self.completer, SIGNAL("activated(const QString&)"), self.insertCompletion) | ||
|
||
def insertCompletion(self, completion): | ||
tc = self.textCursor() | ||
extra = completion.length() - self.completer.completionPrefix().length() | ||
tc.movePosition(QTextCursor.Left) | ||
tc.movePosition(QTextCursor.EndOfWord) | ||
tc.insertText(completion.right(extra)) | ||
self.setTextCursor(tc) | ||
|
||
def textUnderCursor(self): | ||
tc = self.textCursor() | ||
tc.select(QTextCursor.WordUnderCursor) | ||
return tc.selectedText() | ||
|
||
def focusInEvent(self, event): | ||
if self.completer: | ||
self.completer.setWidget(self) | ||
QTextEdit.focusInEvent(self, event) | ||
|
||
def keyPressEvent(self, event): | ||
if self.completer and self.completer.popup().isVisible(): | ||
if event.key() in (Qt.Key_Enter, Qt.Key_Return, Qt.Key_Escape, Qt.Key_Tab, Qt.Key_Backtab): | ||
event.ignore() | ||
return | ||
|
||
# has ctrl-E or ctrl-space been pressed?? | ||
isShortcut = event.modifiers() == Qt.ControlModifier and event.key() in (Qt.Key_E, Qt.Key_Space) | ||
if not self.completer or not isShortcut: | ||
QTextEdit.keyPressEvent(self, event) | ||
|
||
# ctrl or shift key on it's own?? | ||
ctrlOrShift = event.modifiers() in (Qt.ControlModifier, Qt.ShiftModifier) | ||
if ctrlOrShift and event.text().isEmpty(): | ||
# ctrl or shift key on it's own | ||
return | ||
|
||
eow = QString("~!@#$%^&*()+{}|:\"<>?,./;'[]\\-=") # end of word | ||
|
||
hasModifier = event.modifiers() != Qt.NoModifier and not ctrlOrShift | ||
|
||
completionPrefix = self.textUnderCursor() | ||
|
||
if not isShortcut and (hasModifier or event.text().isEmpty() or | ||
completionPrefix.length() < 3 or eow.contains(event.text().right(1))): | ||
self.completer.popup().hide() | ||
return | ||
|
||
if completionPrefix != self.completer.completionPrefix(): | ||
self.completer.setCompletionPrefix(completionPrefix) | ||
popup = self.completer.popup() | ||
popup.setCurrentIndex(self.completer.completionModel().index(0,0)) | ||
|
||
cr = self.cursorRect() | ||
cr.setWidth(self.completer.popup().sizeHintForColumn(0) | ||
+ self.completer.popup().verticalScrollBar().sizeHint().width()) | ||
self.completer.complete(cr) # popup it up! | ||
|
||
#if __name__ == "__main__": | ||
# app = QApplication([]) | ||
# te = CompletionTextEdit() | ||
# SqlCompleter( te ) | ||
# te.show() | ||
# app.exec_() |
Oops, something went wrong.