Skip to content

Commit

Permalink
Fix broken handle bad layers dialog
Browse files Browse the repository at this point in the history
Partially revert af0bae6 and ea2cc36

Fixes #20265

(cherry picked from commit 0d7f598)
  • Loading branch information
nyalldawson committed Oct 30, 2018
1 parent 15cff4f commit 370e87e
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/providers/gdal/qgsgdalprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1991,6 +1991,10 @@ QStringList QgsGdalProvider::subLayers() const
return mSubLayers;
}

QGISEXTERN int dataCapabilities()
{
return QgsDataProvider::File | QgsDataProvider::Dir | QgsDataProvider::Net;
}

QGISEXTERN QVariantMap decodeUri( const QString &uri )
{
Expand Down
5 changes: 5 additions & 0 deletions src/providers/ogr/qgsogrprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3397,6 +3397,11 @@ QGISEXTERN bool createEmptyDataSource( const QString &uri,
return true;
}

QGISEXTERN int dataCapabilities()
{
return QgsDataProvider::File | QgsDataProvider::Dir;
}

QGISEXTERN QList< QgsDataItemProvider * > *dataItemProviders()
{
QList< QgsDataItemProvider * > *providers = new QList< QgsDataItemProvider * >();
Expand Down
1 change: 1 addition & 0 deletions tests/src/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ ADD_PYTHON_TEST(PyQgsFilterLineEdit test_qgsfilterlineedit.py)
ADD_PYTHON_TEST(PyQgsFloatingWidget test_qgsfloatingwidget.py)
ADD_PYTHON_TEST(PyQgsFontButton test_qgsfontbutton.py)
ADD_PYTHON_TEST(PyQgsFontUtils test_qgsfontutils.py)
ADD_PYTHON_TEST(PyQgsGdalProvider test_provider_gdal.py)
ADD_PYTHON_TEST(PyQgsGeoNodeConnection test_qgsgeonodeconnection.py)
ADD_PYTHON_TEST(PyQgsGeometryAvoidIntersections test_qgsgeometry_avoid_intersections.py)
ADD_PYTHON_TEST(PyQgsGeometryGeneratorSymbolLayer test_qgsgeometrygeneratorsymbollayer.py)
Expand Down
34 changes: 34 additions & 0 deletions tests/src/python/test_provider_gdal.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# -*- coding: utf-8 -*-
"""Generic Unit tests for the GDAL provider.
.. note:: 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.
"""
__author__ = 'Nyall Dawson'
__date__ = '2018-30-10'
__copyright__ = 'Copyright 2018, Nyall Dawson'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'

from qgis.core import (QgsProviderRegistry,
QgsDataProvider)
from qgis.testing import start_app, unittest

from utilities import unitTestDataPath

start_app()
TEST_DATA_DIR = unitTestDataPath()


class PyQgsGdalProvider(unittest.TestCase):

def testCapabilities(self):
self.assertTrue(QgsProviderRegistry.instance().providerCapabilities("gdal") & QgsDataProvider.File)
self.assertTrue(QgsProviderRegistry.instance().providerCapabilities("gdal") & QgsDataProvider.Dir)
self.assertTrue(QgsProviderRegistry.instance().providerCapabilities("gdal") & QgsDataProvider.Net)


if __name__ == '__main__':
unittest.main()
5 changes: 5 additions & 0 deletions tests/src/python/test_provider_ogr.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from qgis.PyQt.QtCore import QVariant
from qgis.core import (QgsApplication,
QgsRectangle,
QgsProviderRegistry,
QgsFeature, QgsFeatureRequest, QgsField, QgsSettings, QgsDataProvider,
QgsVectorDataProvider, QgsVectorLayer, QgsWkbTypes, QgsNetworkAccessManager)
from qgis.testing import start_app, unittest
Expand Down Expand Up @@ -72,6 +73,10 @@ def tearDownClass(cls):
for dirname in cls.dirs_to_cleanup:
shutil.rmtree(dirname, True)

def testCapabilities(self):
self.assertTrue(QgsProviderRegistry.instance().providerCapabilities("ogr") & QgsDataProvider.File)
self.assertTrue(QgsProviderRegistry.instance().providerCapabilities("ogr") & QgsDataProvider.Dir)

def testUpdateMode(self):

vl = QgsVectorLayer('{}|layerid=0'.format(self.datasource), 'test', 'ogr')
Expand Down

0 comments on commit 370e87e

Please sign in to comment.