[QGIS Commit] r12517 - trunk/qgis/python/plugins/osm
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Sat Dec 19 09:31:23 EST 2009
Author: wonder
Date: 2009-12-19 09:31:23 -0500 (Sat, 19 Dec 2009)
New Revision: 12517
Modified:
trunk/qgis/python/plugins/osm/OsmDownloadDlg.py
Log:
OSM: small usability improvements in download dialog
Modified: trunk/qgis/python/plugins/osm/OsmDownloadDlg.py
===================================================================
--- trunk/qgis/python/plugins/osm/OsmDownloadDlg.py 2009-12-19 13:27:01 UTC (rev 12516)
+++ trunk/qgis/python/plugins/osm/OsmDownloadDlg.py 2009-12-19 14:31:23 UTC (rev 12517)
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
"""@package OsmDownloadDlg
Module provides simple way how to download OSM data.
First user is asked to choose download region, output file etc.
@@ -54,7 +55,6 @@
self.urlPathPrefix="/api/0.6/map?bbox="
self.downloadButton.setDefault(True)
- self.downloadButton.setEnabled(False)
# determining default area for download
if QgsMapLayerRegistry.instance().count()>0:
@@ -99,7 +99,6 @@
defaultFileName=self.generateDefFileName()
self.destdirLineEdit.setText(defaultFileName)
self.destdirLineEdit.setEnabled(True)
- self.downloadButton.setEnabled(True)
# check default extent
self.checkExtent()
@@ -119,12 +118,6 @@
It's called after click() signal is emitted on Download button.
"""
- if self.finished:
- return
-
- self.downloadButton.setEnabled(False)
- self.disconnectDlgSignals()
-
# finding out which area should be downloaded, and to where
urlPath = self.urlPathPrefix + self.lonFromLineEdit.text() + "," + self.latFromLineEdit.text() + "," + self.lonToLineEdit.text() + "," + self.latToLineEdit.text()
fileName = self.destdirLineEdit.text()
@@ -141,6 +134,9 @@
self.outFile = None
return
+ self.setEnabled(False)
+ self.finished = False
+
# creating progress dialog for download
self.progressDialog=QProgressDialog(self)
# !!! don't set progress dialog modal !!! it would cause serious problems!
@@ -148,8 +144,6 @@
self.progressDialog.setWindowTitle(self.tr("OSM Download"))
self.connect(self.progressDialog,SIGNAL("canceled()"), self.progressDlgCanceled)
- self.setEnabled(False)
- self.progressDialog.setEnabled(True)
self.progressDialog.show()
self.progressDialog.setLabelText(self.tr("Waiting for OpenStreetMap server ..."))
self.progressDialog.setMaximum(1)
@@ -254,6 +248,9 @@
del self.http
self.http=None
+ self.progressDialog.close()
+ self.setEnabled(True)
+
# request was not aborted
if error:
self.httpSuccess=False
@@ -263,17 +260,18 @@
del self.outFile
self.outFile=None
- # and tell user
- if self.errMessage==None:
- self.errMessage="Check your internet connection"
- QMessageBox.information(self, self.tr("OSM Download Error")
- ,self.tr("Download failed: %1.").arg(self.errMessage))
- else:
- self.httpSuccess=True
+ # and tell user (if the download wasn't cancelled by user)
+ if self.errMessage != "__cancel__":
+ if self.errMessage==None:
+ self.errMessage="Check your internet connection"
+ QMessageBox.information(self, self.tr("OSM Download Error")
+ ,self.tr("Download failed: %1.").arg(self.errMessage))
+ return
+ self.httpSuccess=True
+
# well, download process has finished successfully;
- # close progress dialog and the whole download dialog
- self.progressDialog.close()
+ # close the whole download dialog
self.close()
@@ -304,15 +302,11 @@
Only OSM files can be selected.
"""
- if self.finished:
- return
-
# display file open dialog and get absolute path to selected directory
fileSelected = QFileDialog.getSaveFileName(self, "Choose file to save","download.osm", "OSM Files (*.osm)");
# insert selected directory path into line edit control
if not fileSelected.isNull():
self.destdirLineEdit.setText(fileSelected)
- self.downloadButton.setEnabled(True)
def generateDefFileName(self):
@@ -322,9 +316,6 @@
Default name is always unique. It consist of current timestamp and a postfix.
"""
- if self.finished:
- return
-
prefix=QDir.tempPath() + "/"
if self.dbm.currentKey:
key=QString(self.dbm.currentKey)
@@ -339,9 +330,6 @@
"""Function is called after clicking on AutoLoad checkbox.
"""
- if self.finished:
- return
-
if not self.autoLoadCheckBox.isChecked():
self.chkCustomRenderer.setEnabled(False)
self.chkReplaceData.setEnabled(False)
@@ -355,9 +343,6 @@
It shows basic information on downloading.
"""
- if self.finished:
- return
-
mb=QMessageBox()
mb.setMinimumWidth(390)
mb.information(self, self.tr("Getting data"),self.tr("The OpenStreetMap server you are downloading OSM data from (~ api.openstreetmap.org) has fixed limitations of how much data you can get. As written at <http://wiki.openstreetmap.org/wiki/Getting_Data> neither latitude nor longitude extent of downloaded region can be larger than 0.25 degrees. Note that Quantum GIS allows you to specify any extent you want, but OpenStreetMap server will reject all request that won't satisfy downloading limitations."))
@@ -370,9 +355,6 @@
Result of checking is displayed on dialog.
"""
- if self.finished:
- return
-
lim = 0.25 # download limitations of openstreetmap server in degrees
# get coordinates that are currently set
@@ -406,13 +388,10 @@
It aborts HTTP connection.
"""
- if self.finished:
- return
+ # cancel download with a special message
+ self.cancelDownload("__cancel__")
- # cancel download with no message for user
- self.cancelDownload()
-
def setProxy(self):
"""Function sets proxy to HTTP connection of downloader.
@@ -420,9 +399,6 @@
because it's global - accessible for the whole downloader.
"""
- if self.finished:
- return
-
# getting and setting proxy information
settings=QSettings()
proxyHost=QString()
More information about the QGIS-commit
mailing list