Skip to content

Commit

Permalink
[DBManager] fix add new SL/GPKG connection from "New connection" cont…
Browse files Browse the repository at this point in the history
…ext menu entry
  • Loading branch information
brushtyler committed Sep 3, 2015
1 parent bef84dc commit 80a13e3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 16 deletions.
7 changes: 2 additions & 5 deletions python/plugins/db_manager/db_manager.py
Expand Up @@ -270,7 +270,7 @@ def registerAction(self, action, menuName, callback=None):

return True

def invokeCallback(self, callback, params=None):
def invokeCallback(self, callback, *params):
""" Call a method passing the selected item in the database tree,
the sender (usually a QAction), the plugin mainWindow and
optionally additional parameters.
Expand All @@ -280,10 +280,7 @@ def invokeCallback(self, callback, params=None):
"""
QApplication.setOverrideCursor(Qt.WaitCursor)
try:
if params is None:
callback(self.tree.currentItem(), self.sender(), self)
else:
callback(self.tree.currentItem(), self.sender(), self, *params)
callback(self.tree.currentItem(), self.sender(), self, *params)

except BaseError as e:
# catch database errors and display the error dialog
Expand Down
19 changes: 9 additions & 10 deletions python/plugins/db_manager/db_plugins/spatialite/plugin.py
Expand Up @@ -23,8 +23,9 @@
# this will disable the dbplugin if the connector raise an ImportError
from .connector import SpatiaLiteDBConnector

from PyQt4.QtCore import Qt, QSettings
from PyQt4.QtGui import QIcon, QApplication, QAction
from PyQt4.QtCore import Qt, SIGNAL, QSettings, QFileInfo
from PyQt4.QtGui import QIcon, QApplication, QAction, QFileDialog
from qgis.core import QgsDataSourceURI
from qgis.gui import QgsMessageBar

from ..plugin import DBPlugin, Database, Table, VectorTable, RasterTable, TableField, TableIndex, TableTrigger, \
Expand Down Expand Up @@ -75,9 +76,7 @@ def connect(self, parent=None):

database = settings.value("sqlitepath")

import qgis.core

uri = qgis.core.QgsDataSourceURI()
uri = QgsDataSourceURI()
uri.setDatabase(database)
return self.connectToUri(uri)

Expand All @@ -93,17 +92,17 @@ def addConnection(self, conn_name, uri):
def addConnectionActionSlot(self, item, action, parent, index):
QApplication.restoreOverrideCursor()
try:
filename = QFileDialog.getOpenFileName(self, "Choose Sqlite/Spatialite/Geopackage file")
filename = QFileDialog.getOpenFileName(parent, "Choose Sqlite/Spatialite/Geopackage file")
if not filename:
return
finally:
QApplication.setOverrideCursor(Qt.WaitCursor)

conn_name = QFileInfo(filepath).fileName()
uri = qgis.core.QgsDataSourceURI()
uri.setDatabase(filepath)
conn_name = QFileInfo(filename).fileName()
uri = QgsDataSourceURI()
uri.setDatabase(filename)
self.addConnection(conn_name, uri)
index.internalPointer().emit(SIGNAL('itemChanged'))
index.internalPointer().emit(SIGNAL('itemChanged'), index.internalPointer())



Expand Down
2 changes: 1 addition & 1 deletion python/plugins/db_manager/db_tree.py
Expand Up @@ -21,7 +21,7 @@
"""

from PyQt4.QtCore import SIGNAL, SLOT, QSettings, Qt
from PyQt4.QtGui import QWidget, QTreeView, QMenu, QLabel, QFileDialog
from PyQt4.QtGui import QWidget, QTreeView, QMenu, QLabel

from qgis.core import QgsMapLayerRegistry, QgsMessageLog
from qgis.gui import QgsMessageBar, QgsMessageBarItem
Expand Down

0 comments on commit 80a13e3

Please sign in to comment.