Skip to content
Permalink
Browse files

[DBManager] fix add new SL/GPKG connection from "New connection" cont…

…ext menu entry
  • Loading branch information
brushtyler committed Sep 3, 2015
1 parent bef84dc commit 80a13e38526d7c7e6cc4869170818b66955e6517
@@ -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.
@@ -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
@@ -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, \
@@ -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)

@@ -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())



@@ -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

0 comments on commit 80a13e3

Please sign in to comment.
You can’t perform that action at this time.