mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
[DBManager] fix add new SL/GPKG connection from "New connection" context menu entry
This commit is contained in:
parent
bef84dc676
commit
80a13e3852
@ -270,7 +270,7 @@ class DBManager(QMainWindow):
|
||||
|
||||
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 @@ class DBManager(QMainWindow):
|
||||
"""
|
||||
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 @@ email : brush.tyler@gmail.com
|
||||
# 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 @@ class SpatiaLiteDBPlugin(DBPlugin):
|
||||
|
||||
database = settings.value("sqlitepath")
|
||||
|
||||
import qgis.core
|
||||
|
||||
uri = qgis.core.QgsDataSourceURI()
|
||||
uri = QgsDataSourceURI()
|
||||
uri.setDatabase(database)
|
||||
return self.connectToUri(uri)
|
||||
|
||||
@ -93,17 +92,17 @@ class SpatiaLiteDBPlugin(DBPlugin):
|
||||
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 @@ email : brush.tyler@gmail.com
|
||||
"""
|
||||
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user