MetaSearch: minor fixes for QGIS 3 compat

This commit is contained in:
Tom Kralidis 2017-03-05 21:21:51 -05:00
parent c2b365c70e
commit 6ce208c776
2 changed files with 24 additions and 16 deletions

View File

@ -145,7 +145,7 @@ class MetaSearchDialog(QDialog, BASE_CLASS):
self.populate_connection_list()
self.btnCapabilities.setEnabled(False)
self.spnRecords.setValue(
self.settings.value('/MetaSearch/returnRecords', 10, int))
int(self.settings.value('/MetaSearch/returnRecords', 10)))
key = '/MetaSearch/%s' % self.cmbConnectionsSearch.currentText()
self.catalog_url = self.settings.value('%s/url' % key)
@ -380,7 +380,7 @@ class MetaSearchDialog(QDialog, BASE_CLASS):
def set_bbox_from_map(self):
"""set bounding box from map extent"""
crs = self.map.mapRenderer().destinationCrs()
crs = self.map.mapSettings().destinationCrs()
crsid = int(crs.authid().split(':')[1])
extent = self.map.extent()

View File

@ -44,7 +44,7 @@ from jinja2 import Environment, FileSystemLoader
from pygments import highlight
from pygments.lexers import XmlLexer
from pygments.formatters import HtmlFormatter
from qgis.PyQt.QtCore import QUrl
from qgis.PyQt.QtCore import QUrl, QUrlQuery
from qgis.PyQt.QtWidgets import QMessageBox
from qgis.PyQt.uic import loadUiType
@ -110,14 +110,17 @@ def get_connections_from_file(parent, filename):
def prettify_xml(xml):
"""convenience function to prettify XML"""
if xml.count('\n') > 5: # likely already pretty printed
if isinstance(xml, bytes):
xml = xml.decode('utf-8')
if xml.count('\n') > 20: # likely already pretty printed
return xml
# check if it's a GET request
if xml.startswith('http'):
return xml
else:
# check if it's a GET request
if xml.startswith('http'):
return xml
else:
return parseString(xml).toprettyxml()
return parseString(xml).toprettyxml()
def highlight_xml(context, xml):
@ -138,7 +141,7 @@ def get_help_url():
"""return QGIS MetaSearch help documentation link"""
locale_name = QgsSettings().value('locale/userLocale')[0:2]
major, minor = QGis.QGIS_VERSION.split('.')[:2]
major, minor = Qgis.QGIS_VERSION.split('.')[:2]
if minor == '99': # master
version = 'testing'
@ -182,10 +185,15 @@ def serialize_string(input_string):
def clean_ows_url(url):
"""clean an OWS URL of added basic service parameters"""
url2 = QUrl(url)
url2.removeEncodedQueryItem('service')
url2.removeEncodedQueryItem('SERVICE')
url2.removeEncodedQueryItem('request')
url2.removeEncodedQueryItem('REQUEST')
url = QUrl(url)
query_string = url.query()
return url2.toString()
if query_string:
query_string = QUrlQuery(query_string)
query_string.removeQueryItem('service')
query_string.removeQueryItem('SERVICE')
query_string.removeQueryItem('request')
query_string.removeQueryItem('REQUEST')
url.setQuery(query_string)
return url.toString()