From a51fd5f0cef1ff58be082230b4e3291e67bb4566 Mon Sep 17 00:00:00 2001 From: "Juergen E. Fischer" Date: Mon, 15 Apr 2013 07:16:20 +0200 Subject: [PATCH] indentation update --- .../sextante/algs/ftools/ConvexHull.py | 2 +- .../sextante/algs/ftools/ReprojectLayer.py | 2 +- python/plugins/sextante/gdal/OgrAlgorithm.py | 2 +- python/plugins/sextante/gdal/ogr2ogr.py | 34 +- .../plugins/sextante/grass/GrassAlgorithm.py | 16 +- .../sextante/grass/GrassAlgorithmProvider.py | 4 +- python/plugins/sextante/grass/GrassUtils.py | 4 +- .../sextante/gui/MissingDependencyDialog.py | 2 +- .../modeler/ModelerParametersDialog.py | 12 +- .../modeler/SaveAsPythonScriptAction.py | 8 +- .../parameters/ParameterTableField.py | 10 +- python/plugins/sextante/saga/SagaAlgorithm.py | 6 +- python/plugins/sextante/saga/SagaUtils.py | 2 +- python/plugins/sextante/tests/GdalTest.py | 18 +- .../sextante/tests/GeoAlgorithmTest.py | 10 +- .../sextante/tests/ModelerAlgorithmTest.py | 14 +- python/plugins/sextante/tests/QgisAlgsTest.py | 6 +- python/plugins/sextante/tests/SagaTest.py | 2 +- python/plugins/sextante/tests/ScriptTest.py | 4 +- .../plugins/sextante/tests/SextanteTests.py | 4 +- .../sextante/tests/SextanteToolsTest.py | 32 +- python/plugins/sextante/tools/vector.py | 8 +- src/app/qgisappinterface.cpp | 4 +- src/app/qgsaddtaborgroup.cpp | 6 +- src/app/qgsaddtaborgroup.h | 2 +- src/app/qgsattributetabledialog.cpp | 4 +- src/app/qgsfieldsproperties.cpp | 6 +- src/core/composer/qgscomposerlabel.cpp | 2 +- src/core/composer/qgscomposerlegend.cpp | 4 +- src/core/qgsproject.cpp | 2 +- src/core/qgsproject.h | 2 +- src/core/qgsvectorlayer.cpp | 6 +- src/core/qgsvectorlayerfeatureiterator.cpp | 2 +- src/core/raster/qgsrasteridentifyresult.cpp | 18 +- src/core/raster/qgsrasterrange.cpp | 10 +- src/core/raster/qgsrasterrange.h | 4 +- .../symbology-ng/qgssymbologyv2conversion.cpp | 2 +- .../qgsattributetabledelegate.h | 2 +- .../qgsattributetablefiltermodel.cpp | 4 +- .../qgsattributetablefiltermodel.h | 2 +- .../attributetable/qgsattributetablemodel.cpp | 4 +- .../attributetable/qgsattributetableview.cpp | 78 +-- .../attributetable/qgsfeaturelistmodel.cpp | 4 +- src/gui/attributetable/qgsfeaturelistview.cpp | 30 +- src/gui/attributetable/qgsfeaturelistview.h | 2 +- .../qgsfeaturelistviewdelegate.cpp | 4 +- src/gui/attributetable/qgsfeaturemodel.h | 4 +- .../qgsfeatureselectionmodel.cpp | 28 +- .../attributetable/qgsfeatureselectionmodel.h | 168 ++--- .../delimitedtext/qgsdelimitedtextfile.h | 606 +++++++++--------- src/providers/ogr/qgsogrprovider.cpp | 2 +- tests/bench/qgsbench.cpp | 2 +- tests/src/gui/testqgsdualview.cpp | 2 +- .../python/test_qgsdelimitedtextprovider.py | 26 +- 54 files changed, 622 insertions(+), 622 deletions(-) diff --git a/python/plugins/sextante/algs/ftools/ConvexHull.py b/python/plugins/sextante/algs/ftools/ConvexHull.py index fdb984fd184a..635146dba620 100644 --- a/python/plugins/sextante/algs/ftools/ConvexHull.py +++ b/python/plugins/sextante/algs/ftools/ConvexHull.py @@ -71,7 +71,7 @@ def processAlgorithm(self, progress): GEOS_EXCEPT = True FEATURE_EXCEPT = True - + f = QgsField("value") f.setType(QVariant.String) f.setLength(255) diff --git a/python/plugins/sextante/algs/ftools/ReprojectLayer.py b/python/plugins/sextante/algs/ftools/ReprojectLayer.py index 106f161bd1f6..e315ac4ebaa5 100644 --- a/python/plugins/sextante/algs/ftools/ReprojectLayer.py +++ b/python/plugins/sextante/algs/ftools/ReprojectLayer.py @@ -79,5 +79,5 @@ def processAlgorithm(self, progress): progress.setPercentage(int(current * total)) del writer - + self.crs = targetCrs diff --git a/python/plugins/sextante/gdal/OgrAlgorithm.py b/python/plugins/sextante/gdal/OgrAlgorithm.py index ea80b50d9627..b962eb09609e 100644 --- a/python/plugins/sextante/gdal/OgrAlgorithm.py +++ b/python/plugins/sextante/gdal/OgrAlgorithm.py @@ -47,7 +47,7 @@ def ogrConnectionString(self, uri): layer = QGisLayers.getObjectFromUri(uri, False) if layer == None: return uri; - provider = layer.dataProvider().name() + provider = layer.dataProvider().name() if provider == 'spatialite': #dbname='/geodata/osm_ch.sqlite' table="places" (Geometry) sql= regex = re.compile("dbname='(.+)'") diff --git a/python/plugins/sextante/gdal/ogr2ogr.py b/python/plugins/sextante/gdal/ogr2ogr.py index 117d27afd06f..4211455ede51 100644 --- a/python/plugins/sextante/gdal/ogr2ogr.py +++ b/python/plugins/sextante/gdal/ogr2ogr.py @@ -62,9 +62,9 @@ def defineCharacteristics(self): #we add the input vector layer. It can have any kind of geometry #It is a mandatory (not optional) one, hence the False argument - self.addParameter(ParameterVector(self.INPUT_LAYER, "Input layer", ParameterVector.VECTOR_TYPE_ANY, False)) - self.addParameter(ParameterSelection(self.DEST_FORMAT, "Destination Format", FORMATS)) - self.addParameter(ParameterString(self.DEST_DSCO, "Creation Options", "")) + self.addParameter(ParameterVector(self.INPUT_LAYER, "Input layer", ParameterVector.VECTOR_TYPE_ANY, False)) + self.addParameter(ParameterSelection(self.DEST_FORMAT, "Destination Format", FORMATS)) + self.addParameter(ParameterString(self.DEST_DSCO, "Creation Options", "")) self.addOutput(OutputVector(self.OUTPUT_LAYER, "Output layer")) @@ -72,37 +72,37 @@ def processAlgorithm(self, progress): '''Here is where the processing itself takes place''' if not gdalAvailable: - raise GeoAlgorithmExecutionException("GDAL bindings not installed.") + raise GeoAlgorithmExecutionException("GDAL bindings not installed.") input = self.getParameterValue(self.INPUT_LAYER) ogrLayer = self.ogrConnectionString(input) - + output = self.getOutputFromName(self.OUTPUT_LAYER) outfile = output.value - + formatIdx = self.getParameterValue(self.DEST_FORMAT) - + ext = EXTS[formatIdx] if not outfile.endswith(ext): outfile = outfile + ext; output.value = outfile - + dst_ds = self.ogrConnectionString(outfile) dst_format = FORMATS[formatIdx] - ogr_dsco = [self.getParameterValue(self.DEST_DSCO)] - + ogr_dsco = [self.getParameterValue(self.DEST_DSCO)] + poDS = ogr.Open( ogrLayer, False ) if poDS is None: - raise GeoAlgorithmExecutionException(self.failure(ogrLayer)) - + raise GeoAlgorithmExecutionException(self.failure(ogrLayer)) + if dst_format == "SQLite" and os.path.isfile(dst_ds): - os.remove(dst_ds) + os.remove(dst_ds) driver = ogr.GetDriverByName(str(dst_format)) poDstDS = driver.CreateDataSource(dst_ds, options = ogr_dsco) if poDstDS is None: raise GeoAlgorithmExecutionException("Error creating %s" % dst_ds) return - self.ogrtransform(poDS, poDstDS, bOverwrite = True) + self.ogrtransform(poDS, poDstDS, bOverwrite = True) def ogrtransform(self, @@ -141,7 +141,7 @@ def ogrtransform(self, poLayer = poSrcDS.GetLayer(iLayer) if poLayer is None: - raise GeoAlgorithmExecutionException( "FAILURE: Couldn't fetch advertised layer %d!" % iLayer) + raise GeoAlgorithmExecutionException( "FAILURE: Couldn't fetch advertised layer %d!" % iLayer) papoLayers[iLayer] = poLayer iLayer = iLayer + 1 @@ -156,12 +156,12 @@ def ogrtransform(self, poLayer = poSrcDS.GetLayerByName(layername) if poLayer is None: - raise GeoAlgorithmExecutionException("FAILURE: Couldn't fetch advertised layer %s!" % layername) + raise GeoAlgorithmExecutionException("FAILURE: Couldn't fetch advertised layer %s!" % layername) papoLayers[iLayer] = poLayer iLayer = iLayer + 1 - for poSrcLayer in papoLayers: + for poSrcLayer in papoLayers: ok = TranslateLayer( poSrcDS, poSrcLayer, poDstDS, papszLCO, pszNewLayerName, \ bTransform, poOutputSRS, poSourceSRS, papszSelFields, \ bAppend, eGType, bOverwrite, eGeomOp, dfGeomOpParam, \ diff --git a/python/plugins/sextante/grass/GrassAlgorithm.py b/python/plugins/sextante/grass/GrassAlgorithm.py index 79203c75da07..81d4391fa2eb 100644 --- a/python/plugins/sextante/grass/GrassAlgorithm.py +++ b/python/plugins/sextante/grass/GrassAlgorithm.py @@ -78,7 +78,7 @@ def getIcon(self): return QIcon(os.path.dirname(__file__) + "/../images/grass.png") def helpFile(self): - return 'http://grass.osgeo.org/grass64/manuals/' + self.grassName + ".html" + return 'http://grass.osgeo.org/grass64/manuals/' + self.grassName + ".html" def getParameterDescriptions(self): descs = {} @@ -293,8 +293,8 @@ def processAlgorithm(self, progress): command+= (" > " + out.value) else: command+=(" " + out.name + "=\"" + out.value + "\""); - elif not isinstance(out, OutputHTML): - #html files are not generated by GRASS, only by SEXTANTE to decorate grass output, so we skip them + elif not isinstance(out, OutputHTML): + #html files are not generated by GRASS, only by SEXTANTE to decorate grass output, so we skip them #An output name to make sure it is unique if the session uses this algorithm several times uniqueOutputName = out.name + uniqueSufix command += (" " + out.name + "=" + uniqueOutputName) @@ -358,7 +358,7 @@ def postProcessResults(self): def exportVectorLayer(self, orgFilename): #TODO: improve this. We are now exporting if it is not a shapefile, - #but the functionality of v.in.ogr could be used for this. + #but the functionality of v.in.ogr could be used for this. #We also export if there is a selection if not os.path.exists(orgFilename) or not orgFilename.endswith("shp"): layer = QGisLayers.getObjectFromUri(orgFilename, False) @@ -427,12 +427,12 @@ def getTempFilename(self): def commandLineName(self): return "grass:" + self.name[:self.name.find(" ")] - + def checkBeforeOpeningParametersDialog(self): msg = GrassUtils.checkGrassIsInstalled() - if msg is not None: - html = ("

This algorithm requires GRASS to be run." - "Unfortunately, it seems that GRASS is not installed in your system, or it is not correctly configured to be used from QGIS

") + if msg is not None: + html = ("

This algorithm requires GRASS to be run." + "Unfortunately, it seems that GRASS is not installed in your system, or it is not correctly configured to be used from QGIS

") html += '

Click here to know more about how to install and configure GRASS to be used with SEXTANTE

' return html diff --git a/python/plugins/sextante/grass/GrassAlgorithmProvider.py b/python/plugins/sextante/grass/GrassAlgorithmProvider.py index a5bdfdf79726..626c2b08adc6 100644 --- a/python/plugins/sextante/grass/GrassAlgorithmProvider.py +++ b/python/plugins/sextante/grass/GrassAlgorithmProvider.py @@ -46,13 +46,13 @@ def initializeSettings(self): SextanteConfig.addSetting(Setting(self.getDescription(), GrassUtils.GRASS_FOLDER, "GRASS folder", GrassUtils.grassPath())) SextanteConfig.addSetting(Setting(self.getDescription(), GrassUtils.GRASS_WIN_SHELL, "Msys folder", GrassUtils.grassWinShell())) SextanteConfig.addSetting(Setting(self.getDescription(), GrassUtils.GRASS_LOG_COMMANDS, "Log execution commands", False)) - SextanteConfig.addSetting(Setting(self.getDescription(), GrassUtils.GRASS_LOG_CONSOLE, "Log console output", False)) + SextanteConfig.addSetting(Setting(self.getDescription(), GrassUtils.GRASS_LOG_CONSOLE, "Log console output", False)) def unload(self): AlgorithmProvider.unload(self) if SextanteUtils.isWindows() or SextanteUtils.isMac(): SextanteConfig.removeSetting(GrassUtils.GRASS_FOLDER) - SextanteConfig.removeSetting(GrassUtils.GRASS_WIN_SHELL) + SextanteConfig.removeSetting(GrassUtils.GRASS_WIN_SHELL) SextanteConfig.removeSetting(GrassUtils.GRASS_LOG_COMMANDS) SextanteConfig.removeSetting(GrassUtils.GRASS_LOG_CONSOLE) diff --git a/python/plugins/sextante/grass/GrassUtils.py b/python/plugins/sextante/grass/GrassUtils.py index 17c23f390a0b..0a3b3a9e7864 100644 --- a/python/plugins/sextante/grass/GrassUtils.py +++ b/python/plugins/sextante/grass/GrassUtils.py @@ -43,7 +43,7 @@ class GrassUtils: GRASS_REGION_XMAX = "GRASS_REGION_XMAX" GRASS_REGION_YMAX = "GRASS_REGION_YMAX" GRASS_REGION_CELLSIZE = "GRASS_REGION_CELLSIZE" - GRASS_FOLDER = "GRASS_FOLDER" + GRASS_FOLDER = "GRASS_FOLDER" GRASS_WIN_SHELL = "GRASS_WIN_SHELL" GRASS_LOG_COMMANDS = "GRASS_LOG_COMMANDS" GRASS_LOG_CONSOLE = "GRASS_LOG_CONSOLE" @@ -327,7 +327,7 @@ def checkGrassIsInstalled(ignoreRegistrySettings=False): settings = QSettings() GRASS_INSTALLED = "/SextanteQGIS/GrassInstalled" - if not ignoreRegistrySettings: + if not ignoreRegistrySettings: if settings.contains(GRASS_INSTALLED): return diff --git a/python/plugins/sextante/gui/MissingDependencyDialog.py b/python/plugins/sextante/gui/MissingDependencyDialog.py index e1e92ae73b3e..12e0d8964790 100644 --- a/python/plugins/sextante/gui/MissingDependencyDialog.py +++ b/python/plugins/sextante/gui/MissingDependencyDialog.py @@ -40,7 +40,7 @@ def setupUi(self): layout = QVBoxLayout() webView = QtWebKit.QWebView() webView.page().setLinkDelegationPolicy(QtWebKit.QWebPage.DelegateAllLinks) - webView.connect(webView, SIGNAL("linkClicked(const QUrl&)"), self.linkClicked) + webView.connect(webView, SIGNAL("linkClicked(const QUrl&)"), self.linkClicked) webView.setHtml(self.msg) closeButton = QtGui.QPushButton() closeButton.setText("Close") diff --git a/python/plugins/sextante/modeler/ModelerParametersDialog.py b/python/plugins/sextante/modeler/ModelerParametersDialog.py index ed2d541a02aa..1f479e86a955 100644 --- a/python/plugins/sextante/modeler/ModelerParametersDialog.py +++ b/python/plugins/sextante/modeler/ModelerParametersDialog.py @@ -651,7 +651,7 @@ def setParamTableFieldValue(self, param, widget): idx = widget.findText(widget.currentText()) if idx < 0: name = self.getSafeNameForHarcodedParameter(param) - value = AlgorithmAndParameter(AlgorithmAndParameter.PARENT_MODEL_ALGORITHM, name) + value = AlgorithmAndParameter(AlgorithmAndParameter.PARENT_MODEL_ALGORITHM, name) s = str(widget.currentText()).strip() if s == "": if param.optional: @@ -669,21 +669,21 @@ def setParamTableFieldValue(self, param, widget): return True def setParamStringValue(self, param, widget): - if param.multiline: + if param.multiline: name = self.getSafeNameForHarcodedParameter(param) paramValue = AlgorithmAndParameter(AlgorithmAndParameter.PARENT_MODEL_ALGORITHM, name) value = widget.getValue() option = widget.getOption() - if option == MultilineTextPanel.USE_TEXT: + if option == MultilineTextPanel.USE_TEXT: if value == "": if param.optional: self.params[param.name] = None - return True + return True else: return False - else: + else: self.values[name] = value - + self.params[param.name] = paramValue else: self.params[param.name] = value diff --git a/python/plugins/sextante/modeler/SaveAsPythonScriptAction.py b/python/plugins/sextante/modeler/SaveAsPythonScriptAction.py index 9de5bdcd0e1e..2afab9681807 100644 --- a/python/plugins/sextante/modeler/SaveAsPythonScriptAction.py +++ b/python/plugins/sextante/modeler/SaveAsPythonScriptAction.py @@ -46,7 +46,7 @@ def execute(self): if filename: if not filename.endswith(".py"): filename += ".py" - text = self.translateToPythonCode(self.alg) + text = self.translateToPythonCode(self.alg) try: fout = open(filename, "w") fout.write(text) @@ -57,8 +57,8 @@ def execute(self): QMessageBox.warning(self, self.tr("I/O error"), self.tr("Unable to save edits. Reason:\n %1").arg(unicode(sys.exc_info()[1])) - ) - + ) + def translateToPythonCode(self, model): s = ["##" + model.name + "=name"] for param in model.parameters: @@ -113,4 +113,4 @@ def translateToPythonCode(self, model): i += 1 s += multiple s.append(str(runline + ")")) - return "\n".join(s) \ No newline at end of file + return "\n".join(s) \ No newline at end of file diff --git a/python/plugins/sextante/parameters/ParameterTableField.py b/python/plugins/sextante/parameters/ParameterTableField.py index 62b6454cd301..9362e4dd99cd 100644 --- a/python/plugins/sextante/parameters/ParameterTableField.py +++ b/python/plugins/sextante/parameters/ParameterTableField.py @@ -43,14 +43,14 @@ def getValueAsCommandLineParameter(self): def getAsScriptCode(self): return "##" + self.name + "=field " + str(self.parent) - + def setValue(self, field): if field is None: return self.optional - elif len(field) > 0: + elif len(field) > 0: self.value = str(field) else: - return self.optional + return self.optional return True def serialize(self): @@ -58,8 +58,8 @@ def serialize(self): "|" + str(self.parent) + "|" + str(self.datatype) def deserialize(self, s): - tokens = s.split("|") - return ParameterTableField(tokens[1], tokens[2], tokens[3], int(tokens[4]), tokens[5] == str(True)) + tokens = s.split("|") + return ParameterTableField(tokens[1], tokens[2], tokens[3], int(tokens[4]), tokens[5] == str(True)) def __str__(self): return self.name + " <" + self.__module__.split(".")[-1] +" from " + self.parent + ">" diff --git a/python/plugins/sextante/saga/SagaAlgorithm.py b/python/plugins/sextante/saga/SagaAlgorithm.py index 903051fd0c40..2725bfa52643 100644 --- a/python/plugins/sextante/saga/SagaAlgorithm.py +++ b/python/plugins/sextante/saga/SagaAlgorithm.py @@ -358,9 +358,9 @@ def exportRasterLayer(self, layer): def checkBeforeOpeningParametersDialog(self): msg = SagaUtils.checkSagaIsInstalled() - if msg is not None: - html = ("

This algorithm requires SAGA to be run." - "Unfortunately, it seems that SAGA is not installed in your system, or it is not correctly configured to be used from QGIS

") + if msg is not None: + html = ("

This algorithm requires SAGA to be run." + "Unfortunately, it seems that SAGA is not installed in your system, or it is not correctly configured to be used from QGIS

") html += '

Click here to know more about how to install and configure SAGA to be used with SEXTANTE

' return html diff --git a/python/plugins/sextante/saga/SagaUtils.py b/python/plugins/sextante/saga/SagaUtils.py index 7bca5bcac76c..df3d1b21b659 100644 --- a/python/plugins/sextante/saga/SagaUtils.py +++ b/python/plugins/sextante/saga/SagaUtils.py @@ -137,7 +137,7 @@ def checkSagaIsInstalled(ignoreRegistrySettings=False): settings = QSettings() SAGA_INSTALLED = "/SextanteQGIS/SagaInstalled" - if not ignoreRegistrySettings: + if not ignoreRegistrySettings: if settings.contains(SAGA_INSTALLED): return diff --git a/python/plugins/sextante/tests/GdalTest.py b/python/plugins/sextante/tests/GdalTest.py index 6ff85f052e73..ea8f82cff16a 100644 --- a/python/plugins/sextante/tests/GdalTest.py +++ b/python/plugins/sextante/tests/GdalTest.py @@ -34,7 +34,7 @@ from sextante.core.SextanteUtils import SextanteUtils class GdalTest(unittest.TestCase): - + def test_gdalogrsieve(self): outputs=sextante.runalg("gdalogr:sieve",raster(),2,0,None) output=outputs['dst_filename'] @@ -42,7 +42,7 @@ def test_gdalogrsieve(self): dataset=gdal.Open(output, GA_ReadOnly) strhash=hash(str(dataset.ReadAsArray(0).tolist())) self.assertEqual(strhash,-1353696889) - + def test_gdalogrsieveWithUnsupportedOutputFormat(self): outputs=sextante.runalg("gdalogr:sieve",raster(),2,0, SextanteUtils.getTempFilename("img")) output=outputs['dst_filename'] @@ -50,15 +50,15 @@ def test_gdalogrsieveWithUnsupportedOutputFormat(self): dataset=gdal.Open(output, GA_ReadOnly) strhash=hash(str(dataset.ReadAsArray(0).tolist())) self.assertEqual(strhash,-1353696889) - + def test_gdalogrwarpreproject(self): outputs=sextante.runalg("gdalogr:warpreproject",raster(),"EPSG:23030","EPSG:4326",0,0,"",None) output=outputs['OUTPUT'] self.assertTrue(os.path.isfile(output)) dataset=gdal.Open(output, GA_ReadOnly) strhash=hash(str(dataset.ReadAsArray(0).tolist())) - self.assertEqual(strhash,-2021328784) - + self.assertEqual(strhash,-2021328784) + def test_gdalogrmerge(self): outputs=sextante.runalg("gdalogr:merge",raster(),False,False,None) output=outputs['OUTPUT'] @@ -66,7 +66,7 @@ def test_gdalogrmerge(self): dataset=gdal.Open(output, GA_ReadOnly) strhash=hash(str(dataset.ReadAsArray(0).tolist())) self.assertEqual(strhash,-1353696889) - + def test_gdalogrogr2ogr(self): outputs=sextante.runalg("gdalogr:ogr2ogr",union(),3,"",None) output=outputs['OUTPUT_LAYER'] @@ -86,8 +86,8 @@ def test_gdalogrogr2ogr(self): values=[str(attr.toString()) for attr in attrs] self.assertEqual(expectedvalues, values) wkt='POLYGON((270807.08580285 4458940.1594565,270798.42294527 4458914.62661676,270780.81854858 4458914.21983449,270763.52289518 4458920.715993,270760.3449542 4458926.6570575,270763.78234766 4458958.22561242,270794.30290024 4458942.16424502,270807.08580285 4458940.1594565))' - self.assertEqual(wkt, str(feature.geometry().exportToWkt())) - + self.assertEqual(wkt, str(feature.geometry().exportToWkt())) + def test_gdalogrogr2ogrWrongExtension(self): outputs=sextante.runalg("gdalogr:ogr2ogr",union(),3,"",SextanteUtils.getTempFilename("wrongext")) output=outputs['OUTPUT_LAYER'] @@ -107,7 +107,7 @@ def test_gdalogrogr2ogrWrongExtension(self): values=[str(attr.toString()) for attr in attrs] self.assertEqual(expectedvalues, values) wkt='POLYGON((270807.08580285 4458940.1594565,270798.42294527 4458914.62661676,270780.81854858 4458914.21983449,270763.52289518 4458920.715993,270760.3449542 4458926.6570575,270763.78234766 4458958.22561242,270794.30290024 4458942.16424502,270807.08580285 4458940.1594565))' - self.assertEqual(wkt, str(feature.geometry().exportToWkt())) + self.assertEqual(wkt, str(feature.geometry().exportToWkt())) def suite(): suite = unittest.makeSuite(GdalTest, 'test') diff --git a/python/plugins/sextante/tests/GeoAlgorithmTest.py b/python/plugins/sextante/tests/GeoAlgorithmTest.py index dcc2b54c3d19..c1dcf768371b 100644 --- a/python/plugins/sextante/tests/GeoAlgorithmTest.py +++ b/python/plugins/sextante/tests/GeoAlgorithmTest.py @@ -30,12 +30,12 @@ from sextante.core.QGisLayers import QGisLayers from sextante.core.SextanteUtils import SextanteUtils -class GeoAlgorithmTest(unittest.TestCase): - - def testWrongformat(self): +class GeoAlgorithmTest(unittest.TestCase): + + def testWrongformat(self): outputs=sextante.runalg("qgis:countpointsinpolygon",polygons(),points(),"NUMPOINTS",SextanteUtils.getTempFilename("wrongext")) output=outputs['OUTPUT'] - self.assertTrue(output.endswith('shp')) + self.assertTrue(output.endswith('shp')) layer=QGisLayers.getObjectFromUri(output, True) fields=layer.pendingFields() expectednames=['ID','POLY_NUM_A','POLY_ST_A','NUMPOINTS'] @@ -51,7 +51,7 @@ def testWrongformat(self): expectedvalues=["1","1.1","string a","6"] values=[str(attr.toString()) for attr in attrs] self.assertEqual(expectedvalues, values) - + def suite(): suite = unittest.makeSuite(GeoAlgorithmTest, 'test') diff --git a/python/plugins/sextante/tests/ModelerAlgorithmTest.py b/python/plugins/sextante/tests/ModelerAlgorithmTest.py index ce1b7ce1c4bf..36e9a514961f 100644 --- a/python/plugins/sextante/tests/ModelerAlgorithmTest.py +++ b/python/plugins/sextante/tests/ModelerAlgorithmTest.py @@ -39,10 +39,10 @@ class ModelerAlgorithmTest(unittest.TestCase): def testCreateModel(self): pass - + def testEditModelParameter(self): pass - + def testEditModelAlgorithm(self): pass @@ -54,12 +54,12 @@ def testRemoveAlgorithm(self): model.provider = Providers.providers['model'] self.assertTrue(2, len(model.algs)) self.assertFalse(model.removeAlgorithm(0)) - self.assertTrue(model.removeAlgorithm(len(model.algs) - 1)); + self.assertTrue(model.removeAlgorithm(len(model.algs) - 1)); model.execute(None) outputs = model.outputs self.assertEquals(1, len(outputs)) output=outputs[0].value - self.assertTrue(os.path.exists(output)) + self.assertTrue(os.path.exists(output)) def testRemoveParameter(self): folder = os.path.join(os.path.dirname(ModelerAlgorithmProvider.__file__), "models") @@ -146,7 +146,7 @@ def test_modelernotinorder(self): dataset=gdal.Open(output, GA_ReadOnly) strhash=hash(str(dataset.ReadAsArray(0).tolist())) self.assertEqual(strhash,-1557050506) - + def test_modeleroptionalfield(self): outputs=sextante.runalg("modeler:optionalfield",points(),None) output=outputs['OUTPUT_ALG0'] @@ -166,7 +166,7 @@ def test_modeleroptionalfield(self): values=[str(attr.toString()) for attr in attrs] self.assertEqual(expectedvalues, values) wkt='POLYGON((270839.46818665 4458921.97813894,270778.60197966 4458935.96883677,270786.54279065 4458980.04784113,270803.15756434 4458983.84880322,270839.65586926 4458983.16267036,270855.74530134 4458940.79948673,270839.46818665 4458921.97813894))' - self.assertEqual(wkt, str(feature.geometry().exportToWkt())) + self.assertEqual(wkt, str(feature.geometry().exportToWkt())) def test_modeleremptystring(self): outputs=sextante.runalg("modeler:emptystring",union(),None) @@ -187,7 +187,7 @@ def test_modeleremptystring(self): values=[str(attr.toString()) for attr in attrs] self.assertEqual(expectedvalues, values) wkt='POLYGON((270807.08580285 4458940.1594565,270798.42294527 4458914.62661676,270780.81854858 4458914.21983449,270763.52289518 4458920.715993,270760.3449542 4458926.6570575,270763.78234766 4458958.22561242,270794.30290024 4458942.16424502,270807.08580285 4458940.1594565))' - self.assertEqual(wkt, str(feature.geometry().exportToWkt())) + self.assertEqual(wkt, str(feature.geometry().exportToWkt())) def suite(): diff --git a/python/plugins/sextante/tests/QgisAlgsTest.py b/python/plugins/sextante/tests/QgisAlgsTest.py index 71389fd4fafd..674a86ffa27c 100644 --- a/python/plugins/sextante/tests/QgisAlgsTest.py +++ b/python/plugins/sextante/tests/QgisAlgsTest.py @@ -186,7 +186,7 @@ def test_qgiscreategridnointeger(self): self.assertEqual(expectedvalues, values) wkt='LINESTRING(-0.5 -0.5, -0.5 -0.4, -0.5 -0.3, -0.5 -0.2, -0.5 -0.1, -0.5 -0.0, -0.5 0.1, -0.5 0.2, -0.5 0.3, -0.5 0.4, -0.5 0.5)' self.assertEqual(wkt, str(feature.geometry().exportToWkt())) - + def test_qgiscreategridhex(self): outputs=sextante.runalg("qgis:creategrid",10,10,360,180,0,0,3,None) output=outputs['SAVENAME'] @@ -944,9 +944,9 @@ def test_qgisstatisticsbycategories(self): output=outputs['OUTPUT'] layer=QGisLayers.getObjectFromUri(output, True) fields=layer.pendingFields() - expectednames=['category','min','max','mean','stddev'] + expectednames=['category','min','max','mean','stddev'] names=[str(f.name()) for f in fields] - self.assertEqual(expectednames, names) + self.assertEqual(expectednames, names) features=sextante.getfeatures(layer) self.assertEqual(3, len(features)) feature=features.next() diff --git a/python/plugins/sextante/tests/SagaTest.py b/python/plugins/sextante/tests/SagaTest.py index ffd2d4216b9a..7dc4e7e6f018 100644 --- a/python/plugins/sextante/tests/SagaTest.py +++ b/python/plugins/sextante/tests/SagaTest.py @@ -108,7 +108,7 @@ def test_SagaVectorAlgorithWithUnsupportedInputAndOutputFormat(self): self.assertEqual(expectedvalues, values) wkt='POINT(270787.49991451 4458955.46775295)' self.assertEqual(wkt, str(feature.geometry().exportToWkt())) - + def test_SagaRasterAlgorithmWithUnsupportedOutputFormat(self): outputs=sextante.runalg("saga:convergenceindex",raster(),0,0,SextanteUtils.getTempFilename("img")) output=outputs['RESULT'] diff --git a/python/plugins/sextante/tests/ScriptTest.py b/python/plugins/sextante/tests/ScriptTest.py index 7b8d0e23775d..0a3973bfa396 100644 --- a/python/plugins/sextante/tests/ScriptTest.py +++ b/python/plugins/sextante/tests/ScriptTest.py @@ -78,8 +78,8 @@ def test_scriptascriptthatreturnsanumber(self): outputs=sextante.runalg("script:ascriptthatreturnsanumber") output=outputs['number'] self.assertTrue(10, output) - - + + def suite(): suite = unittest.makeSuite(ScriptTest, 'test') diff --git a/python/plugins/sextante/tests/SextanteTests.py b/python/plugins/sextante/tests/SextanteTests.py index 112cca1e361f..f5c77c26478f 100644 --- a/python/plugins/sextante/tests/SextanteTests.py +++ b/python/plugins/sextante/tests/SextanteTests.py @@ -23,7 +23,7 @@ # This will get replaced with a git SHA1 when you do a git archive __revision__ = '$Format:%H$' -'''Convenience module to create a test suite will all SEXTANTE tests''' +'''Convenience module to create a test suite will all SEXTANTE tests''' import unittest from sextante.tests import QgisAlgsTest from sextante.tests import ParametersTest @@ -41,7 +41,7 @@ def suite(): suite.addTests(SagaTest.suite()) suite.addTests(GdalTest.suite()) suite.addTests(ScriptTest.suite()) - suite.addTests(SextanteToolsTest.suite()) + suite.addTests(SextanteToolsTest.suite()) #suite.addTests(ParametersTest.suite()) suite.addTests(GeoAlgorithmTest.suite()) return suite diff --git a/python/plugins/sextante/tests/SextanteToolsTest.py b/python/plugins/sextante/tests/SextanteToolsTest.py index 11a807e786c1..dfb31cdf2959 100644 --- a/python/plugins/sextante/tests/SextanteToolsTest.py +++ b/python/plugins/sextante/tests/SextanteToolsTest.py @@ -32,46 +32,46 @@ from sextante.tools.general import getfromname class SextanteToolsTest(unittest.TestCase): - '''tests the method imported when doing an "import sextante", and also in sextante.tools. + '''tests the method imported when doing an "import sextante", and also in sextante.tools. They are mostly convenience tools''' - + def test_getobject(self): layer = sextante.getobject(points()); - self.assertIsNotNone(layer) + self.assertIsNotNone(layer) layer = sextante.getobject("points"); self.assertIsNotNone(layer) - + def test_runandload(self): - sextante.runandload("qgis:countpointsinpolygon",polygons(),points(),"NUMPOINTS", None) + sextante.runandload("qgis:countpointsinpolygon",polygons(),points(),"NUMPOINTS", None) layer = getfromname("Result") - self.assertIsNotNone(layer) - + self.assertIsNotNone(layer) + def test_featuresWithoutSelection(self): - layer = sextante.getobject(points()) + layer = sextante.getobject(points()) features = sextante.getfeatures(layer) - self.assertEqual(12, len(features)) - + self.assertEqual(12, len(features)) + def test_featuresWithSelection(self): layer = sextante.getobject(points()) feature = layer.getFeatures().next() selected = [feature.id()] layer.setSelectedFeatures(selected) - features = sextante.getfeatures(layer) + features = sextante.getfeatures(layer) self.assertEqual(1, len(features)) layer.setSelectedFeatures([]) - + def test_attributeValues(self): - layer = sextante.getobject(points()) + layer = sextante.getobject(points()) attributeValues = values(layer, "ID") i = 1 for value in attributeValues['ID']: self.assertEqual(int(i), int(value)) - i+=1 + i+=1 self.assertEquals(13,i) - + def test_extent(self): pass - + def suite(): diff --git a/python/plugins/sextante/tools/vector.py b/python/plugins/sextante/tools/vector.py index 8b8d036a3352..891f5955c0dd 100644 --- a/python/plugins/sextante/tools/vector.py +++ b/python/plugins/sextante/tools/vector.py @@ -32,7 +32,7 @@ def uniquevalues(layer, attribute): It considers the existing selection''' values = [] fieldIndex = resolveFieldIndex(layer, attribute) - features = QGisLayers.features(layer) + features = QGisLayers.features(layer) for feat in features: if feat.attributes()[fieldIndex] not in values: values.append(feat.attributes()[fieldIndex]) @@ -41,7 +41,7 @@ def uniquevalues(layer, attribute): def resolveFieldIndex(layer, attr): '''This method takes an object and returns the index field it refers to in a layer. If the passed object is an integer, it returns the same integer value. - If the passed value is not an integer, it returns the field whose name is the string + If the passed value is not an integer, it returns the field whose name is the string representation of the passed object. Ir raises an exception if the int value is larger than the number of fields, or if the passed object does not correspond to any field''' @@ -51,7 +51,7 @@ def resolveFieldIndex(layer, attr): index = layer.fieldNameIndex(unicode(attr)) if index == -1: raise ValueError('Wrong field name') - return index + return index def values(layer, *attributes): @@ -63,7 +63,7 @@ def values(layer, *attributes): for attr in attributes: index = resolveFieldIndex(layer, attr) values = [] - features = QGisLayers.features(layer) + features = QGisLayers.features(layer) for feature in features: try: v = float(feature.attributes()[index].toString()) diff --git a/src/app/qgisappinterface.cpp b/src/app/qgisappinterface.cpp index 1b17956d9629..4c4cd2b9dc76 100644 --- a/src/app/qgisappinterface.cpp +++ b/src/app/qgisappinterface.cpp @@ -531,13 +531,13 @@ bool QgisAppInterface::openFeatureForm( QgsVectorLayer *vlayer, QgsFeature &f, b return false; QgsFeatureAction action( tr( "Attributes changed" ), f, vlayer, -1, -1, QgisApp::instance() ); - if (vlayer->isEditable()) + if ( vlayer->isEditable() ) { return action.editFeature(); } else { - return action.viewFeatureForm(); + return action.viewFeatureForm(); } } diff --git a/src/app/qgsaddtaborgroup.cpp b/src/app/qgsaddtaborgroup.cpp index 7554b73bee4a..91b2cd63bbcd 100644 --- a/src/app/qgsaddtaborgroup.cpp +++ b/src/app/qgsaddtaborgroup.cpp @@ -25,9 +25,9 @@ #include QgsAddTabOrGroup::QgsAddTabOrGroup( QgsVectorLayer *lyr, QList < TabPair > tabList, QWidget * parent ) - : QDialog( parent ) - , mLayer( lyr ) - , mTabs( tabList ) + : QDialog( parent ) + , mLayer( lyr ) + , mTabs( tabList ) { setupUi( this ); diff --git a/src/app/qgsaddtaborgroup.h b/src/app/qgsaddtaborgroup.h index 340157bcddea..68efb7901c38 100644 --- a/src/app/qgsaddtaborgroup.h +++ b/src/app/qgsaddtaborgroup.h @@ -30,7 +30,7 @@ class QgsAddTabOrGroup : public QDialog, private Ui::QgsAddTabOrGroupBase Q_OBJECT public: - typedef QPair TabPair; + typedef QPair TabPair; public: QgsAddTabOrGroup( QgsVectorLayer *lyr, QList< TabPair > tabList, QWidget *parent = 0 ); diff --git a/src/app/qgsattributetabledialog.cpp b/src/app/qgsattributetabledialog.cpp index 85c77ba2fcdc..eabc6dd35719 100644 --- a/src/app/qgsattributetabledialog.cpp +++ b/src/app/qgsattributetabledialog.cpp @@ -110,8 +110,8 @@ QgsAttributeTableDialog::QgsAttributeTableDialog( QgsVectorLayer *theLayer, QWid connect( mLayer, SIGNAL( editingStopped() ), this, SLOT( editingToggled() ) ); connect( mLayer, SIGNAL( layerDeleted() ), this, SLOT( close() ) ); connect( mLayer, SIGNAL( selectionChanged() ), this, SLOT( updateTitle() ) ); - connect( mLayer, SIGNAL( attributeAdded(int) ), this, SLOT( columnBoxInit() ) ); - connect( mLayer, SIGNAL( attributeDeleted(int) ), this, SLOT( columnBoxInit() ) ); + connect( mLayer, SIGNAL( attributeAdded( int ) ), this, SLOT( columnBoxInit() ) ); + connect( mLayer, SIGNAL( attributeDeleted( int ) ), this, SLOT( columnBoxInit() ) ); // connect table info to window connect( mMainView, SIGNAL( filterChanged() ), this, SLOT( updateTitle() ) ); diff --git a/src/app/qgsfieldsproperties.cpp b/src/app/qgsfieldsproperties.cpp index b6af19a292db..183ddb1d2ba8 100644 --- a/src/app/qgsfieldsproperties.cpp +++ b/src/app/qgsfieldsproperties.cpp @@ -359,11 +359,11 @@ void QgsFieldsProperties::on_mAddTabOrGroupButton_clicked() QList tabList; - for( QTreeWidgetItemIterator it( mAttributesTree ); *it; ++it ) + for ( QTreeWidgetItemIterator it( mAttributesTree ); *it; ++it ) { - if ( ( *it )->data( 0 , Qt::UserRole ) == "container" ) + if (( *it )->data( 0 , Qt::UserRole ) == "container" ) { - tabList.append( QgsAddTabOrGroup::TabPair( (*it)->text( 0 ), *it ) ); + tabList.append( QgsAddTabOrGroup::TabPair(( *it )->text( 0 ), *it ) ); } } QgsAddTabOrGroup addTabOrGroup( mLayer, tabList, this ); diff --git a/src/core/composer/qgscomposerlabel.cpp b/src/core/composer/qgscomposerlabel.cpp index a4da75fa9a3a..277d8a33b3eb 100644 --- a/src/core/composer/qgscomposerlabel.cpp +++ b/src/core/composer/qgscomposerlabel.cpp @@ -131,7 +131,7 @@ void QgsComposerLabel::paint( QPainter* painter, const QStyleOptionGraphicsItem* /*Track when QWebPage has finished loading its html contents*/ void QgsComposerLabel::loadingHtmlFinished( bool result ) { - Q_UNUSED (result); + Q_UNUSED( result ); mHtmlLoaded = true; } diff --git a/src/core/composer/qgscomposerlegend.cpp b/src/core/composer/qgscomposerlegend.cpp index 773532421391..2501ecef1a76 100644 --- a/src/core/composer/qgscomposerlegend.cpp +++ b/src/core/composer/qgscomposerlegend.cpp @@ -377,7 +377,7 @@ QgsComposerLegend::Nucleon QgsComposerLegend::drawSymbolItem( QgsComposerLegendI if ( painter ) painter->setPen( mFontColor ); //double labelX = point.x() + labelXOffset; // + mIconLabelSpace; - double labelX = point.x() + qMax( (double) symbolSize.width(), labelXOffset ); + double labelX = point.x() + qMax(( double ) symbolSize.width(), labelXOffset ); // Vertical alignment of label with symbol: // a) label height < symbol heigh: label centerd with symbol @@ -410,7 +410,7 @@ QgsComposerLegend::Nucleon QgsComposerLegend::drawSymbolItem( QgsComposerLegendI nucleon.symbolSize = symbolSize; nucleon.labelSize = labelSize; //QgsDebugMsg( QString( "symbol height = %1 label height = %2").arg( symbolSize.height()).arg( labelSize.height() )); - double width = qMax( (double) symbolSize.width(), labelXOffset ) + labelSize.width(); + double width = qMax(( double ) symbolSize.width(), labelXOffset ) + labelSize.width(); double height = qMax( symbolSize.height(), labelSize.height() ); nucleon.size = QSizeF( width, height ); return nucleon; diff --git a/src/core/qgsproject.cpp b/src/core/qgsproject.cpp index 4e61a348c552..6f5f3b289481 100644 --- a/src/core/qgsproject.cpp +++ b/src/core/qgsproject.cpp @@ -1132,7 +1132,7 @@ QStringList QgsProject::readListEntry( QString const & scope, const QString & key, QStringList def, - bool * ok) const + bool * ok ) const { QgsProperty * property = findKey_( scope, key, imp_->properties_ ); diff --git a/src/core/qgsproject.h b/src/core/qgsproject.h index a8288296b8c0..daa605cc3c14 100644 --- a/src/core/qgsproject.h +++ b/src/core/qgsproject.h @@ -231,7 +231,7 @@ class CORE_EXPORT QgsProject : public QObject @note The key string must include '/'s. E.g., "/foo" not "foo". */ //@{ - QStringList readListEntry( const QString & scope, const QString & key, QStringList def = QStringList(), bool *ok = 0 ) const; + QStringList readListEntry( const QString & scope, const QString & key, QStringList def = QStringList(), bool *ok = 0 ) const; QString readEntry( const QString & scope, const QString & key, const QString & def = QString::null, bool * ok = 0 ) const; int readNumEntry( const QString & scope, const QString & key, int def = 0, bool * ok = 0 ) const; diff --git a/src/core/qgsvectorlayer.cpp b/src/core/qgsvectorlayer.cpp index ad499d60f2e4..611b6028377d 100644 --- a/src/core/qgsvectorlayer.cpp +++ b/src/core/qgsvectorlayer.cpp @@ -145,7 +145,7 @@ QgsVectorLayer::QgsVectorLayer( QString vectorLayerPath, //mUpdateThreshold = settings.readNumEntry("Map/updateThreshold", 1000); } - connect ( this, SIGNAL( selectionChanged(QgsFeatureIds,QgsFeatureIds,bool) ), this, SIGNAL( selectionChanged() ) ); + connect( this, SIGNAL( selectionChanged( QgsFeatureIds, QgsFeatureIds, bool ) ), this, SIGNAL( selectionChanged() ) ); } // QgsVectorLayer ctor @@ -714,7 +714,7 @@ void QgsVectorLayer::deselect( const QgsFeatureIds& featureIds ) emit selectionChanged( QgsFeatureIds(), featureIds, false ); } -void QgsVectorLayer::select(QgsRectangle & rect, bool addToSelection ) +void QgsVectorLayer::select( QgsRectangle & rect, bool addToSelection ) { // normalize the rectangle rect.normalize(); @@ -2605,7 +2605,7 @@ bool QgsVectorLayer::addFeatures( QgsFeatureList features, bool makeSelected ) for ( QgsFeatureList::iterator iter = features.begin(); iter != features.end(); ++iter ) ids << iter->id(); - setSelectedFeatures ( ids ); + setSelectedFeatures( ids ); } return res; diff --git a/src/core/qgsvectorlayerfeatureiterator.cpp b/src/core/qgsvectorlayerfeatureiterator.cpp index acbc7213f7ae..0fd434300a4f 100644 --- a/src/core/qgsvectorlayerfeatureiterator.cpp +++ b/src/core/qgsvectorlayerfeatureiterator.cpp @@ -44,7 +44,7 @@ QgsVectorLayerFeatureIterator::QgsVectorLayerFeatureIterator( QgsVectorLayer* la if ( L->pendingFields().fieldOrigin( attrIndex ) == QgsFields::OriginProvider ) providerSubset << L->pendingFields().fieldOriginIndex( attrIndex ); } - mProviderRequest.setSubsetOfAttributes(providerSubset); + mProviderRequest.setSubsetOfAttributes( providerSubset ); } if ( request.filterType() == QgsFeatureRequest::FilterFid ) diff --git a/src/core/raster/qgsrasteridentifyresult.cpp b/src/core/raster/qgsrasteridentifyresult.cpp index bf58460cc18e..8a0c158e9cc8 100644 --- a/src/core/raster/qgsrasteridentifyresult.cpp +++ b/src/core/raster/qgsrasteridentifyresult.cpp @@ -23,22 +23,22 @@ #include "qgsrasterdataprovider.h" QgsRasterIdentifyResult::QgsRasterIdentifyResult() - : mValid(false) - , mFormat(QgsRasterDataProvider::IdentifyFormatUndefined) + : mValid( false ) + , mFormat( QgsRasterDataProvider::IdentifyFormatUndefined ) { } QgsRasterIdentifyResult::QgsRasterIdentifyResult( QgsRasterDataProvider::IdentifyFormat theFormat, QMap theResults ) - : mValid(true) - , mFormat(theFormat) - , mResults(theResults) + : mValid( true ) + , mFormat( theFormat ) + , mResults( theResults ) { } -QgsRasterIdentifyResult::QgsRasterIdentifyResult( QgsError theError ) - : mValid(false) - , mFormat(QgsRasterDataProvider::IdentifyFormatUndefined) - , mError(theError) +QgsRasterIdentifyResult::QgsRasterIdentifyResult( QgsError theError ) + : mValid( false ) + , mFormat( QgsRasterDataProvider::IdentifyFormatUndefined ) + , mError( theError ) { } diff --git a/src/core/raster/qgsrasterrange.cpp b/src/core/raster/qgsrasterrange.cpp index aefdd4d93321..7d5486cf741b 100644 --- a/src/core/raster/qgsrasterrange.cpp +++ b/src/core/raster/qgsrasterrange.cpp @@ -20,14 +20,14 @@ #include "qgsrasterrange.h" QgsRasterRange::QgsRasterRange() - : mMin ( std::numeric_limits::quiet_NaN() ) - , mMax ( std::numeric_limits::quiet_NaN() ) + : mMin( std::numeric_limits::quiet_NaN() ) + , mMax( std::numeric_limits::quiet_NaN() ) { } -QgsRasterRange::QgsRasterRange( double theMin, double theMax ) - : mMin ( theMin ) - , mMax ( theMax ) +QgsRasterRange::QgsRasterRange( double theMin, double theMax ) + : mMin( theMin ) + , mMax( theMax ) { } diff --git a/src/core/raster/qgsrasterrange.h b/src/core/raster/qgsrasterrange.h index 32c4b8dc0f23..2b58e4157598 100644 --- a/src/core/raster/qgsrasterrange.h +++ b/src/core/raster/qgsrasterrange.h @@ -1,5 +1,5 @@ /*************************************************************************** - qgsrasterrange.h + qgsrasterrange.h -------------------------------------- Date : Oct 9, 2012 Copyright : (C) 2012 by Radim Blazek @@ -39,7 +39,7 @@ class CORE_EXPORT QgsRasterRange * @param theMin minimum value * @param theMax max value */ - QgsRasterRange( double theMin, double theMax ); + QgsRasterRange( double theMin, double theMax ); ~QgsRasterRange(); diff --git a/src/core/symbology-ng/qgssymbologyv2conversion.cpp b/src/core/symbology-ng/qgssymbologyv2conversion.cpp index c0a6f49bc3c4..18d1b1ecd256 100644 --- a/src/core/symbology-ng/qgssymbologyv2conversion.cpp +++ b/src/core/symbology-ng/qgssymbologyv2conversion.cpp @@ -109,7 +109,7 @@ static QString readMarkerSymbolName( const QDomNode& synode ) QDomElement psymbelement = psymbnode.toElement(); return psymbelement.text(); } - return QString("hard:circle"); + return QString( "hard:circle" ); } static float readMarkerSymbolSize( const QDomNode& synode ) diff --git a/src/gui/attributetable/qgsattributetabledelegate.h b/src/gui/attributetable/qgsattributetabledelegate.h index a0f205077f6d..2792c3a0e551 100644 --- a/src/gui/attributetable/qgsattributetabledelegate.h +++ b/src/gui/attributetable/qgsattributetabledelegate.h @@ -71,7 +71,7 @@ class QgsAttributeTableDelegate : public QItemDelegate void setFeatureSelectionModel( QgsFeatureSelectionModel* featureSelectionModel ); -private: + private: QgsFeatureSelectionModel* mFeatureSelectionModel; }; diff --git a/src/gui/attributetable/qgsattributetablefiltermodel.cpp b/src/gui/attributetable/qgsattributetablefiltermodel.cpp index 76bc1ea21a2c..6a60fb85230b 100644 --- a/src/gui/attributetable/qgsattributetablefiltermodel.cpp +++ b/src/gui/attributetable/qgsattributetablefiltermodel.cpp @@ -177,7 +177,7 @@ void QgsAttributeTableFilterModel::selectionChanged() } else if ( mSelectedOnTop ) { - sort ( sortColumn(), sortOrder() ); + sort( sortColumn(), sortOrder() ); invalidate(); } } @@ -267,7 +267,7 @@ QModelIndex QgsAttributeTableFilterModel::fidToIndex( QgsFeatureId fid ) QModelIndexList QgsAttributeTableFilterModel::fidToIndexList( QgsFeatureId fid ) { QModelIndexList indexes; - foreach( QModelIndex idx, masterModel()->idToIndexList( fid ) ) + foreach ( QModelIndex idx, masterModel()->idToIndexList( fid ) ) { indexes.append( mapFromMaster( idx ) ); } diff --git a/src/gui/attributetable/qgsattributetablefiltermodel.h b/src/gui/attributetable/qgsattributetablefiltermodel.h index bf565948fef5..5fdf104d353e 100644 --- a/src/gui/attributetable/qgsattributetablefiltermodel.h +++ b/src/gui/attributetable/qgsattributetablefiltermodel.h @@ -150,7 +150,7 @@ class GUI_EXPORT QgsAttributeTableFilterModel: public QSortFilterProxyModel, pub */ void extentsChanged(); -private slots: + private slots: void selectionChanged(); private: diff --git a/src/gui/attributetable/qgsattributetablemodel.cpp b/src/gui/attributetable/qgsattributetablemodel.cpp index 5953e4119661..450eca9ee275 100644 --- a/src/gui/attributetable/qgsattributetablemodel.cpp +++ b/src/gui/attributetable/qgsattributetablemodel.cpp @@ -294,7 +294,7 @@ void QgsAttributeTableModel::loadAttributes() mFieldCount = attributes.size(); mAttributes = attributes; - + if ( ins ) { endInsertColumns(); @@ -381,7 +381,7 @@ QModelIndex QgsAttributeTableModel::idToIndex( QgsFeatureId id ) const return index( idToRow( id ), 0 ); } -QModelIndexList QgsAttributeTableModel::idToIndexList(QgsFeatureId id) const +QModelIndexList QgsAttributeTableModel::idToIndexList( QgsFeatureId id ) const { QModelIndexList indexes; diff --git a/src/gui/attributetable/qgsattributetableview.cpp b/src/gui/attributetable/qgsattributetableview.cpp index 179b62e8418d..a848a03f160b 100644 --- a/src/gui/attributetable/qgsattributetableview.cpp +++ b/src/gui/attributetable/qgsattributetableview.cpp @@ -51,8 +51,8 @@ QgsAttributeTableView::QgsAttributeTableView( QWidget *parent ) verticalHeader()->viewport()->installEventFilter( this ); - connect( verticalHeader(), SIGNAL( sectionPressed(int) ), this, SLOT(selectRow(int) ) ); - connect( verticalHeader(), SIGNAL( sectionEntered(int) ), this, SLOT(_q_selectRow(int) ) ); + connect( verticalHeader(), SIGNAL( sectionPressed( int ) ), this, SLOT( selectRow( int ) ) ); + connect( verticalHeader(), SIGNAL( sectionEntered( int ) ), this, SLOT( _q_selectRow( int ) ) ); } QgsAttributeTableView::~QgsAttributeTableView() @@ -77,16 +77,16 @@ void QgsAttributeTableView::setCanvasAndLayerCache( QgsMapCanvas *canvas, QgsVec mFilterModel = new QgsAttributeTableFilterModel( canvas, mMasterModel, mMasterModel ); setModel( mFilterModel ); delete mFeatureSelectionModel; - mFeatureSelectionModel = new QgsFeatureSelectionModel( mFilterModel, mFilterModel, layerCache->layer (), mFilterModel ); - connect( mFeatureSelectionModel, SIGNAL(requestRepaint(QModelIndexList)), this, SLOT( repaintRequested(QModelIndexList) ) ); + mFeatureSelectionModel = new QgsFeatureSelectionModel( mFilterModel, mFilterModel, layerCache->layer(), mFilterModel ); + connect( mFeatureSelectionModel, SIGNAL( requestRepaint( QModelIndexList ) ), this, SLOT( repaintRequested( QModelIndexList ) ) ); connect( mFeatureSelectionModel, SIGNAL( requestRepaint() ), this, SLOT( repaintRequested() ) ); - setSelectionModel ( mFeatureSelectionModel ); + setSelectionModel( mFeatureSelectionModel ); delete oldModel; delete filterModel; } -bool QgsAttributeTableView::eventFilter(QObject *object, QEvent *event) +bool QgsAttributeTableView::eventFilter( QObject *object, QEvent *event ) { if ( object == verticalHeader()->viewport() ) { @@ -121,10 +121,10 @@ void QgsAttributeTableView::setModel( QgsAttributeTableFilterModel* filterModel delete mFeatureSelectionModel; mFeatureSelectionModel = new QgsFeatureSelectionModel( mFilterModel, mFilterModel, mFilterModel->layer(), mFilterModel ); - setSelectionModel ( mFeatureSelectionModel ); + setSelectionModel( mFeatureSelectionModel ); mTableDelegate->setFeatureSelectionModel( mFeatureSelectionModel ); - connect( mFeatureSelectionModel, SIGNAL(requestRepaint(QModelIndexList)), this, SLOT( repaintRequested(QModelIndexList) ) ); - connect( mFeatureSelectionModel, SIGNAL(requestRepaint()), this, SLOT( repaintRequested() ) ); + connect( mFeatureSelectionModel, SIGNAL( requestRepaint( QModelIndexList ) ), this, SLOT( repaintRequested( QModelIndexList ) ) ); + connect( mFeatureSelectionModel, SIGNAL( requestRepaint() ), this, SLOT( repaintRequested() ) ); if ( filterModel ) { @@ -186,7 +186,7 @@ void QgsAttributeTableView::keyPressEvent( QKeyEvent *event ) void QgsAttributeTableView::repaintRequested( QModelIndexList indexes ) { - foreach( const QModelIndex index, indexes ) + foreach ( const QModelIndex index, indexes ) { update( index ); } @@ -248,37 +248,37 @@ void QgsAttributeTableView::_q_selectRow( int row ) void QgsAttributeTableView::selectRow( int row, bool anchor ) { if ( selectionBehavior() == QTableView::SelectColumns - || ( selectionMode() == QTableView::SingleSelection - && selectionBehavior() == QTableView::SelectItems)) - return; + || ( selectionMode() == QTableView::SingleSelection + && selectionBehavior() == QTableView::SelectItems ) ) + return; if ( row >= 0 && row < model()->rowCount() ) { - int column = horizontalHeader()->logicalIndexAt( isRightToLeft() ? viewport()->width() : 0 ); - QModelIndex index = model()->index( row, column ); - QItemSelectionModel::SelectionFlags command = selectionCommand( index ); - selectionModel()->setCurrentIndex( index, QItemSelectionModel::NoUpdate ); - if ( ( anchor && !( command & QItemSelectionModel::Current ) ) - || ( selectionMode() == QTableView::SingleSelection ) ) - mRowSectionAnchor = row; - - if ( selectionMode() != QTableView::SingleSelection - && command.testFlag( QItemSelectionModel::Toggle ) ) - { - if ( anchor ) - mCtrlDragSelectionFlag = mFeatureSelectionModel->isSelected( index ) - ? QItemSelectionModel::Deselect : QItemSelectionModel::Select; - command &= ~QItemSelectionModel::Toggle; - command |= mCtrlDragSelectionFlag; - if ( !anchor ) - command |= QItemSelectionModel::Current; - } - - QModelIndex tl = model()->index( qMin( mRowSectionAnchor, row ), 0 ); - QModelIndex br = model()->index( qMax( mRowSectionAnchor, row ), model()->columnCount() - 1 ); - if ( verticalHeader()->sectionsMoved() && tl.row() != br.row() ) - setSelection( visualRect( tl ) | visualRect( br ), command ); - else - mFeatureSelectionModel->selectFeatures( QItemSelection( tl, br ), command ); + int column = horizontalHeader()->logicalIndexAt( isRightToLeft() ? viewport()->width() : 0 ); + QModelIndex index = model()->index( row, column ); + QItemSelectionModel::SelectionFlags command = selectionCommand( index ); + selectionModel()->setCurrentIndex( index, QItemSelectionModel::NoUpdate ); + if (( anchor && !( command & QItemSelectionModel::Current ) ) + || ( selectionMode() == QTableView::SingleSelection ) ) + mRowSectionAnchor = row; + + if ( selectionMode() != QTableView::SingleSelection + && command.testFlag( QItemSelectionModel::Toggle ) ) + { + if ( anchor ) + mCtrlDragSelectionFlag = mFeatureSelectionModel->isSelected( index ) + ? QItemSelectionModel::Deselect : QItemSelectionModel::Select; + command &= ~QItemSelectionModel::Toggle; + command |= mCtrlDragSelectionFlag; + if ( !anchor ) + command |= QItemSelectionModel::Current; + } + + QModelIndex tl = model()->index( qMin( mRowSectionAnchor, row ), 0 ); + QModelIndex br = model()->index( qMax( mRowSectionAnchor, row ), model()->columnCount() - 1 ); + if ( verticalHeader()->sectionsMoved() && tl.row() != br.row() ) + setSelection( visualRect( tl ) | visualRect( br ), command ); + else + mFeatureSelectionModel->selectFeatures( QItemSelection( tl, br ), command ); } } diff --git a/src/gui/attributetable/qgsfeaturelistmodel.cpp b/src/gui/attributetable/qgsfeaturelistmodel.cpp index d2fb98474f5b..0a60be915545 100644 --- a/src/gui/attributetable/qgsfeaturelistmodel.cpp +++ b/src/gui/attributetable/qgsfeaturelistmodel.cpp @@ -234,12 +234,12 @@ int QgsFeatureListModel::rowCount( const QModelIndex& parent ) const return sourceModel()->rowCount(); } -QModelIndex QgsFeatureListModel::fidToIndex(QgsFeatureId fid) +QModelIndex QgsFeatureListModel::fidToIndex( QgsFeatureId fid ) { return mapFromMaster( masterModel()->idToIndex( fid ) ); } -QModelIndexList QgsFeatureListModel::fidToIndexList(QgsFeatureId fid) +QModelIndexList QgsFeatureListModel::fidToIndexList( QgsFeatureId fid ) { return QModelIndexList() << fidToIndex( fid ); } diff --git a/src/gui/attributetable/qgsfeaturelistview.cpp b/src/gui/attributetable/qgsfeaturelistview.cpp index cbb5bd3cd081..8e5b9f494a4b 100644 --- a/src/gui/attributetable/qgsfeaturelistview.cpp +++ b/src/gui/attributetable/qgsfeaturelistview.cpp @@ -52,8 +52,8 @@ void QgsFeatureListView::setModel( QgsFeatureListModel* featureListModel ) mModel = featureListModel; delete mFeatureSelectionModel; - mFeatureSelectionModel = new QgsFeatureSelectionModel( featureListModel, featureListModel, featureListModel->layerCache ()->layer(), this ); - setSelectionModel ( mFeatureSelectionModel ); + mFeatureSelectionModel = new QgsFeatureSelectionModel( featureListModel, featureListModel, featureListModel->layerCache()->layer(), this ); + setSelectionModel( mFeatureSelectionModel ); mCurrentEditSelectionModel = new QItemSelectionModel( mModel->masterModel(), this ); @@ -67,8 +67,8 @@ void QgsFeatureListView::setModel( QgsFeatureListModel* featureListModel ) setItemDelegate( mItemDelegate ); mItemDelegate->setFeatureSelectionModel( mFeatureSelectionModel ); - connect( mFeatureSelectionModel, SIGNAL(requestRepaint(QModelIndexList)), this, SLOT( repaintRequested(QModelIndexList) ) ); - connect( mFeatureSelectionModel, SIGNAL(requestRepaint()), this, SLOT( repaintRequested() ) ); + connect( mFeatureSelectionModel, SIGNAL( requestRepaint( QModelIndexList ) ), this, SLOT( repaintRequested( QModelIndexList ) ) ); + connect( mFeatureSelectionModel, SIGNAL( requestRepaint() ), this, SLOT( repaintRequested() ) ); connect( mCurrentEditSelectionModel, SIGNAL( selectionChanged( QItemSelection, QItemSelection ) ), SLOT( editSelectionChanged( QItemSelection, QItemSelection ) ) ); } @@ -155,7 +155,7 @@ void QgsFeatureListView::setEditSelection( const QgsFeatureIds &fids ) void QgsFeatureListView::repaintRequested( QModelIndexList indexes ) { - foreach( const QModelIndex index, indexes ) + foreach ( const QModelIndex index, indexes ) { update( index ); } @@ -172,7 +172,7 @@ void QgsFeatureListView::repaintRequested() over the selection is extended; if a drag is in progress it is continued. */ -void QgsFeatureListView::mouseMoveEvent(QMouseEvent *event) +void QgsFeatureListView::mouseMoveEvent( QMouseEvent *event ) { QPoint pos = event->pos(); @@ -211,7 +211,7 @@ void QgsFeatureListView::mouseReleaseEvent( QMouseEvent *event ) void QgsFeatureListView::keyPressEvent( QKeyEvent *event ) { - if ( Qt::Key_Up == event->key () || Qt::Key_Down == event->key() ) + if ( Qt::Key_Up == event->key() || Qt::Key_Down == event->key() ) { int currentRow = 0; if ( 0 != mCurrentEditSelectionModel->selectedIndexes().count() ) @@ -264,15 +264,15 @@ void QgsFeatureListView::selectRow( const QModelIndex& index, bool anchor ) mRowAnchor = row; if ( selectionMode() != QListView::SingleSelection - && command.testFlag( QItemSelectionModel::Toggle ) ) + && command.testFlag( QItemSelectionModel::Toggle ) ) { - if ( anchor ) - mCtrlDragSelectionFlag = mFeatureSelectionModel->isSelected( index ) - ? QItemSelectionModel::Deselect : QItemSelectionModel::Select; - command &= ~QItemSelectionModel::Toggle; - command |= mCtrlDragSelectionFlag; - if ( !anchor ) - command |= QItemSelectionModel::Current; + if ( anchor ) + mCtrlDragSelectionFlag = mFeatureSelectionModel->isSelected( index ) + ? QItemSelectionModel::Deselect : QItemSelectionModel::Select; + command &= ~QItemSelectionModel::Toggle; + command |= mCtrlDragSelectionFlag; + if ( !anchor ) + command |= QItemSelectionModel::Current; } QModelIndex tl = model()->index( qMin( mRowAnchor, row ), 0 ); diff --git a/src/gui/attributetable/qgsfeaturelistview.h b/src/gui/attributetable/qgsfeaturelistview.h index f77485606daa..b0fa64f45a44 100644 --- a/src/gui/attributetable/qgsfeaturelistview.h +++ b/src/gui/attributetable/qgsfeaturelistview.h @@ -140,7 +140,7 @@ class GUI_EXPORT QgsFeatureListView : public QListView void editSelectionChanged( QItemSelection deselected, QItemSelection selected ); private: - void selectRow(const QModelIndex &index, bool anchor ); + void selectRow( const QModelIndex &index, bool anchor ); QgsFeatureListModel *mModel; QItemSelectionModel* mCurrentEditSelectionModel; diff --git a/src/gui/attributetable/qgsfeaturelistviewdelegate.cpp b/src/gui/attributetable/qgsfeaturelistviewdelegate.cpp index 19a8041cceaf..cc3daf9116ec 100644 --- a/src/gui/attributetable/qgsfeaturelistviewdelegate.cpp +++ b/src/gui/attributetable/qgsfeaturelistviewdelegate.cpp @@ -32,7 +32,7 @@ QgsFeatureListViewDelegate::Element QgsFeatureListViewDelegate::positionToElemen } } -void QgsFeatureListViewDelegate::setFeatureSelectionModel(QgsFeatureSelectionModel *featureSelectionModel) +void QgsFeatureListViewDelegate::setFeatureSelectionModel( QgsFeatureSelectionModel *featureSelectionModel ) { mFeatureSelectionModel = featureSelectionModel; } @@ -61,7 +61,7 @@ void QgsFeatureListViewDelegate::paint( QPainter *painter, const QStyleOptionVie QPixmap icon; - if ( mFeatureSelectionModel->isSelected ( index ) ) + if ( mFeatureSelectionModel->isSelected( index ) ) { // Item is selected icon = QgsApplication::getThemePixmap( "/mIconSelected.svg" ); diff --git a/src/gui/attributetable/qgsfeaturemodel.h b/src/gui/attributetable/qgsfeaturemodel.h index d03a206a04f8..eae9e111f318 100644 --- a/src/gui/attributetable/qgsfeaturemodel.h +++ b/src/gui/attributetable/qgsfeaturemodel.h @@ -6,8 +6,8 @@ class QgsFeatureModel { -public: - virtual QModelIndex fidToIndex( QgsFeatureId fid ) = 0; + public: + virtual QModelIndex fidToIndex( QgsFeatureId fid ) = 0; }; #endif // QGSFEATUREMODEL_H diff --git a/src/gui/attributetable/qgsfeatureselectionmodel.cpp b/src/gui/attributetable/qgsfeatureselectionmodel.cpp index f519962cbcc9..de4b8891ed35 100644 --- a/src/gui/attributetable/qgsfeatureselectionmodel.cpp +++ b/src/gui/attributetable/qgsfeatureselectionmodel.cpp @@ -5,13 +5,13 @@ #include QgsFeatureSelectionModel::QgsFeatureSelectionModel( QAbstractItemModel* model, QgsFeatureModel* featureModel, QgsVectorLayer* layer, QObject* parent ) - : QItemSelectionModel( model, parent ) - , mFeatureModel( featureModel ) - , mLayer( layer ) - , mSyncEnabled( true ) - , mClearAndSelectBuffer( false ) + : QItemSelectionModel( model, parent ) + , mFeatureModel( featureModel ) + , mLayer( layer ) + , mSyncEnabled( true ) + , mClearAndSelectBuffer( false ) { - connect( mLayer, SIGNAL( selectionChanged(QgsFeatureIds,QgsFeatureIds,bool) ), this, SLOT( layerSelectionChanged(QgsFeatureIds,QgsFeatureIds,bool)) ); + connect( mLayer, SIGNAL( selectionChanged( QgsFeatureIds, QgsFeatureIds, bool ) ), this, SLOT( layerSelectionChanged( QgsFeatureIds, QgsFeatureIds, bool ) ) ); } void QgsFeatureSelectionModel::enableSync( bool enable ) @@ -59,16 +59,16 @@ void QgsFeatureSelectionModel::selectFeatures( const QItemSelection &selection, { QgsFeatureIds ids; - foreach( const QModelIndex index, selection.indexes() ) + foreach ( const QModelIndex index, selection.indexes() ) { QgsFeatureId id = index.model()->data( index, QgsAttributeTableModel::FeatureIdRole ).toInt(); ids << id; } - disconnect( mLayer, SIGNAL( selectionChanged(QgsFeatureIds,QgsFeatureIds,bool) ), this, SLOT( layerSelectionChanged(QgsFeatureIds,QgsFeatureIds,bool)) ); + disconnect( mLayer, SIGNAL( selectionChanged( QgsFeatureIds, QgsFeatureIds, bool ) ), this, SLOT( layerSelectionChanged( QgsFeatureIds, QgsFeatureIds, bool ) ) ); - if ( command.testFlag ( QItemSelectionModel::ClearAndSelect ) ) + if ( command.testFlag( QItemSelectionModel::ClearAndSelect ) ) { if ( !mSyncEnabled ) { @@ -86,7 +86,7 @@ void QgsFeatureSelectionModel::selectFeatures( const QItemSelection &selection, mLayer->setSelectedFeatures( ids ); } } - else if ( command.testFlag ( QItemSelectionModel::Select ) ) + else if ( command.testFlag( QItemSelectionModel::Select ) ) { if ( !mSyncEnabled ) { @@ -103,7 +103,7 @@ void QgsFeatureSelectionModel::selectFeatures( const QItemSelection &selection, mLayer->select( ids ); } } - else if ( command.testFlag ( QItemSelectionModel::Deselect ) ) + else if ( command.testFlag( QItemSelectionModel::Deselect ) ) { if ( !mSyncEnabled ) { @@ -121,12 +121,12 @@ void QgsFeatureSelectionModel::selectFeatures( const QItemSelection &selection, } } - connect( mLayer, SIGNAL( selectionChanged(QgsFeatureIds,QgsFeatureIds,bool) ), this, SLOT( layerSelectionChanged(QgsFeatureIds,QgsFeatureIds,bool)) ); + connect( mLayer, SIGNAL( selectionChanged( QgsFeatureIds, QgsFeatureIds, bool ) ), this, SLOT( layerSelectionChanged( QgsFeatureIds, QgsFeatureIds, bool ) ) ); QModelIndexList updatedIndexes; foreach ( QModelIndex idx, selection.indexes() ) { - updatedIndexes.append( expandIndexToRow ( idx ) ); + updatedIndexes.append( expandIndexToRow( idx ) ); } emit requestRepaint( updatedIndexes ); @@ -164,7 +164,7 @@ QModelIndexList QgsFeatureSelectionModel::expandIndexToRow( const QModelIndex& i if ( !model ) return indexes; - for( int column = 0; column < model->columnCount(); ++column ) + for ( int column = 0; column < model->columnCount(); ++column ) { indexes.append( model->index( row, column ) ); } diff --git a/src/gui/attributetable/qgsfeatureselectionmodel.h b/src/gui/attributetable/qgsfeatureselectionmodel.h index 33f06f6da6a0..7ee439efe555 100644 --- a/src/gui/attributetable/qgsfeatureselectionmodel.h +++ b/src/gui/attributetable/qgsfeatureselectionmodel.h @@ -10,90 +10,90 @@ class QgsFeatureModel; class QgsFeatureSelectionModel : public QItemSelectionModel { - Q_OBJECT -public: - explicit QgsFeatureSelectionModel( QAbstractItemModel* model, QgsFeatureModel* featureModel, QgsVectorLayer* layer, QObject* parent ); - - /** - * Enables or disables synchronisation to the {@link QgsVectorLayer} - * When synchronisation is disabled, any selection change will be buffered inside this selection model. - * When enabled, any buffered changes are communicated to the layer and the buffer is emptied. - * Mainly to be used for performance reasons, because selection change on the layer can cost time as it - * repaints the layer. - * - * @param enable The synchronisation status to set. - */ - void enableSync( bool enable ); - - /** - * Returns the selection status of a given feature id. - * - * @param fid The featureid to determine the selection status of - * - * @return The selection status - */ - - virtual bool isSelected( QgsFeatureId fid ); - /** - * Returns the selection status of a given QModelIndex. - * - * @param index The index to determine the selection status of - * - * @return The selection status - */ - virtual bool isSelected( const QModelIndex& index ); - -signals: - /** - * Request a repaint of a list of model indexes. - * Views using this model should connect to and properly process this signal. - * - * @param indexes The model indexes which need to be repainted - */ - void requestRepaint( QModelIndexList indexes ); - - /** - * Request a repaint of the visible items of connected views. - * Views using this model should connect to and properly process this signal. - */ - void requestRepaint(); - -public slots: - /** - * Overwritten to do NOTHING (we handle selection ourselves) - * - * @see selectFeatures( const QItemSelection&, SelectionFlags ) - */ - virtual void select ( const QModelIndex &index, SelectionFlags command ) { Q_UNUSED( index); Q_UNUSED( command ); } - - /** - * Overwritten to do NOTHING (we handle selection ourselves) - * - * @see selectFeatures( const QItemSelection&, SelectionFlags ) - */ - virtual void select ( const QItemSelection &selection, SelectionFlags command ) { Q_UNUSED( selection); Q_UNUSED( command ); } - - /** - * Select features on this table. Is to be used in favor of the stock select methods. - * - * @param selection The QItemSelection which will be selected - * @param command The command to apply. Select, Deselect and ClearAndSelect are processed. - */ - virtual void selectFeatures( const QItemSelection &selection, SelectionFlags command ); - -private slots: - virtual void layerSelectionChanged( QgsFeatureIds selected, QgsFeatureIds deselected, bool clearAndSelect ); - -private: - QModelIndexList expandIndexToRow( const QModelIndex& index ) const; - -private: - QgsFeatureModel* mFeatureModel; - QgsVectorLayer* mLayer; - bool mSyncEnabled; - QgsFeatureIds mSelectedBuffer; - QgsFeatureIds mDeselectedBuffer; - bool mClearAndSelectBuffer; + Q_OBJECT + public: + explicit QgsFeatureSelectionModel( QAbstractItemModel* model, QgsFeatureModel* featureModel, QgsVectorLayer* layer, QObject* parent ); + + /** + * Enables or disables synchronisation to the {@link QgsVectorLayer} + * When synchronisation is disabled, any selection change will be buffered inside this selection model. + * When enabled, any buffered changes are communicated to the layer and the buffer is emptied. + * Mainly to be used for performance reasons, because selection change on the layer can cost time as it + * repaints the layer. + * + * @param enable The synchronisation status to set. + */ + void enableSync( bool enable ); + + /** + * Returns the selection status of a given feature id. + * + * @param fid The featureid to determine the selection status of + * + * @return The selection status + */ + + virtual bool isSelected( QgsFeatureId fid ); + /** + * Returns the selection status of a given QModelIndex. + * + * @param index The index to determine the selection status of + * + * @return The selection status + */ + virtual bool isSelected( const QModelIndex& index ); + + signals: + /** + * Request a repaint of a list of model indexes. + * Views using this model should connect to and properly process this signal. + * + * @param indexes The model indexes which need to be repainted + */ + void requestRepaint( QModelIndexList indexes ); + + /** + * Request a repaint of the visible items of connected views. + * Views using this model should connect to and properly process this signal. + */ + void requestRepaint(); + + public slots: + /** + * Overwritten to do NOTHING (we handle selection ourselves) + * + * @see selectFeatures( const QItemSelection&, SelectionFlags ) + */ + virtual void select( const QModelIndex &index, SelectionFlags command ) { Q_UNUSED( index ); Q_UNUSED( command ); } + + /** + * Overwritten to do NOTHING (we handle selection ourselves) + * + * @see selectFeatures( const QItemSelection&, SelectionFlags ) + */ + virtual void select( const QItemSelection &selection, SelectionFlags command ) { Q_UNUSED( selection ); Q_UNUSED( command ); } + + /** + * Select features on this table. Is to be used in favor of the stock select methods. + * + * @param selection The QItemSelection which will be selected + * @param command The command to apply. Select, Deselect and ClearAndSelect are processed. + */ + virtual void selectFeatures( const QItemSelection &selection, SelectionFlags command ); + + private slots: + virtual void layerSelectionChanged( QgsFeatureIds selected, QgsFeatureIds deselected, bool clearAndSelect ); + + private: + QModelIndexList expandIndexToRow( const QModelIndex& index ) const; + + private: + QgsFeatureModel* mFeatureModel; + QgsVectorLayer* mLayer; + bool mSyncEnabled; + QgsFeatureIds mSelectedBuffer; + QgsFeatureIds mDeselectedBuffer; + bool mClearAndSelectBuffer; }; #endif // QGSFEATURESELECTIONMODEL_H diff --git a/src/providers/delimitedtext/qgsdelimitedtextfile.h b/src/providers/delimitedtext/qgsdelimitedtextfile.h index a7e1406d67e6..e107d6eb8f0d 100644 --- a/src/providers/delimitedtext/qgsdelimitedtextfile.h +++ b/src/providers/delimitedtext/qgsdelimitedtextfile.h @@ -1,303 +1,303 @@ -/*************************************************************************** - qgsdelimitedtextparser.h - File for delimited text file - ------------------- - begin : 2004-02-27 - copyright : (C) 2013 by Chris Crook - email : ccrook at linz.govt.nz - ***************************************************************************/ - -/*************************************************************************** - * * - * 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. * - * * - ***************************************************************************/ - -#include -#include -#include - -class QgsFeature; -class QgsField; -class QFile; -class QTextStream; - - -/** -\class QgsDelimitedTextFile -\brief Delimited text file parser extracts records from a QTextStream as a QStringList. -* -* -* The delimited text parser is used by the QgsDelimitedTextProvider to parse -* a QTextStream into records of QStringList. It provides a number of variants -* for parsing each record. The following options are supported: -* - Basic whitespace parsing. Each line in the file is treated as a record. -* Extracts all contiguous sequences of non-whitespace -* characters. Leading and trailing whitespace are ignored. -* - Regular expression parsing. Each line in the file is treated as a record. -* The string is split into fields based on a regular expression. -* - Character delimited, based on a delimiter character set, a quote character, and -* an escape character. The escape treats the next character as a part of a field. -* Fields may start and end with quote characters, in which case any non-escaped -* character within the field is treated literally, including end of line characters. -* The escape character within a string causes the next character to be read literally -* (this includes new line characters). If the escape and quote characters are the -* same, then only quote characters will be escaped (ie to include a quote in a -* quoted field it is entered as two quotes. All other characters in quoted fields -* are treated literally, including newlines. -* - CSV format files - these are a special case of character delimited, in which the -* delimiter is a comma, and the quote and escape characters are double quotes (") -* -* The delimiters can be encode in and decoded from a QUrl as query items. The -* items used are: -* - delimiterType, one of plain (delimiter is any of a set of characters), -* regexp, csv, whitespace -* - delimiter, interpreted according to the type. For plain characters this is -* a sequence of characters. The string \t in the sequence is replaced by a tab. -* For regexp type delimiters this specifies the reqular expression. -* The field is ignored for csv and whitespace -* - quoteChar, optional, a single character used for quoting plain fields -* - escapeChar, optional, a single characer used for escaping (may be the same as quoteChar) -*/ - -// Note: this has been implemented as a single class rather than a set of classes based -// on an abstract base class in order to facilitate changing the type of the parser easily -// eg in the provider dialog - -class QgsDelimitedTextFile -{ - - public: - - enum Status - { - RecordOk, - InvalidDefinition, - RecordEmpty, - RecordInvalid, - RecordEOF - }; - - enum DelimiterType - { - DelimTypeWhitespace, - DelimTypeCSV, - DelimTypeRegexp, - }; - - QgsDelimitedTextFile( QString url = QString() ); - - virtual ~QgsDelimitedTextFile(); - - /** Set the filename - * @param filename the name of the file - */ - void setFileName( QString filename ); - /** Return the filename - * @return filename the name of the file - */ - QString fileName() - { - return mFileName; - } - - /** Set the file encoding (defuault is UTF-8) - * @param encoding the encoding to use for the fileName() - */ - void setEncoding( QString encoding ); - /** Return the file encoding - * @return encoding The file encoding - */ - QString encoding() { return mEncoding; } - - /** Decode the parser settings from a url as a string - * @param url The url from which the delimiter and delimiterType items are read - */ - bool setFromUrl( QString url ); - /** Decode the parser settings from a url - * @param url The url from which the delimiter and delimiterType items are read - */ - bool setFromUrl( QUrl &url ); - - /** Encode the parser settings into a QUrl - * @return url The url into which the delimiter and delimiterType items are set - */ - QUrl url(); - - /** Set the parser for parsing CSV files - */ - void setTypeWhitespace(); - - /** Set the parser for parsing based on a reqular expression delimiter - @param regexp A string defining the regular expression - */ - void setTypeRegexp( QString regexp ); - /** Set the parser to use a character type delimiter. - * @param delim The field delimiter character set - * @param quote The quote character, used to define quoted fields - * @param escape The escape character used to escape quote or delim - * characters. - */ - void setTypeCSV( QString delim = QString( "," ), QString quote = QString( "\"" ), QString escape = QString( "\"" ) ); - - /* Set the number of header lines to skip - * @param skiplines The maximum lines to skip - */ - void setSkipLines( int skiplines ); - /* Return the number of header lines to skip - * @return skiplines The maximum lines to skip - */ - int skipLines() - { - return mSkipLines; - } - - /* Set reading column names from the first record - * @param useheaders Column names will be read if true - */ - void setUseHeader( bool useheader = true ); - /* Return the option for reading column names from the first record - * @return useheaders Column names will be read if true - */ - bool useHeader() - { - return mUseHeader; - } - - /* Set the option for dicarding empty fields - * @param useheaders Empty fields will be discarded if true - */ - void setDiscardEmptyFields( bool discardEmptyFields = true ); - /* Return the option for discarding empty fields - * @return useheaders Empty fields will be discarded if true - */ - bool discardEmptyFields() - { - return mDiscardEmptyFields; - } - - /* Set the option for trimming whitespace from fields - * @param trimFields Fields will be trimmed if true - */ - void setTrimFields( bool trimFields = true ); - /* Return the option for trimming empty fields - * @return useheaders Empty fields will be trimmed if true - */ - bool trimFields() - { - return mTrimFields; - } - - /** Return the column names read from the header, or default names - * Col## if none defined. Will open and read the head of the file - * if required, then reset.. - */ - QStringList &columnNames(); - - /** Reads the next record from the stream splits into string fields. - * @param fields The string list to populate with the fields - * @return status The result of trying to parse a record. RecordOk - * if read successfully, RecordEOF if reached the end of the - * file, RecordEmpty if no data on the next line, and - * RecordInvalid if the record is ill-formatted. - */ - Status nextRecord( QStringList &fields ); - - /** Return the line number of the start of the last record read - * @return linenumber The line number of the start of the record - */ - int recordLineNumber() - { - return mRecordLineNumber; - } - - /** Reset the file to reread from the beginning - */ - Status reset(); - - /** Return a string defining the type of the delimiter as a string - * @return type The delimiter type as a string - */ - QString type(); - - /** Check that provider is valid (filename and definition valid) - * - * @return valid True if the provider is valid - */ - bool isValid(); - - /** Encode characters - used to convert delimiter/quote/escape characters to - * encoded form (eg replace tab with \t) - * @param string The unencoded string - * @return encstring The encoded string - */ - static QString encodeChars( QString string ); - - /** Encode characters - used to encoded character strings to - * decoded form (eg replace \t with tab) - * @param string The unencoded string - * @return decstring The decoded string - */ - static QString decodeChars( QString string ); - - - - - private: - - /** Open the file - * - * @return valid True if the file is successfully opened - */ - bool open(); - - /** Close the text file - */ - void close(); - - /** Reset the status if the definition is changing (eg clear - * existing column names, etc... - */ - void resetDefinition(); - - /** Parse reqular expression delimited fields */ - Status parseRegexp( QStringList &fields ); - /** Parse quote delimited fields, where quote and escape are different */ - Status parseQuoted( QStringList &fields ); - - /** Return the next line from the data file. If skipBlank is true then - * blank lines will be skipped - this is for compatibility with previous - * delimited text parser implementation. - */ - Status nextLine( QString &buffer, bool skipBlank = false ); - - // Pointer to the currently selected parser - Status( QgsDelimitedTextFile::*mParser )( QStringList &fields ); - - QString mFileName; - QString mEncoding; - QFile *mFile; - QTextStream *mStream; - - // Parameters common to parsers - bool mDefinitionValid; - DelimiterType mType; - bool mUseHeader; - bool mDiscardEmptyFields; - bool mTrimFields; - int mSkipLines; - int mMaxFields; - - // Parameters used by parsers - QRegExp mDelimRegexp; - QString mDelimChars; - QString mQuoteChar; - QString mEscapeChar; - - // Information extracted from file - QStringList mColumnNames; - int mLineNumber; - int mRecordLineNumber; -}; +/*************************************************************************** + qgsdelimitedtextparser.h - File for delimited text file + ------------------- + begin : 2004-02-27 + copyright : (C) 2013 by Chris Crook + email : ccrook at linz.govt.nz + ***************************************************************************/ + +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +#include +#include +#include + +class QgsFeature; +class QgsField; +class QFile; +class QTextStream; + + +/** +\class QgsDelimitedTextFile +\brief Delimited text file parser extracts records from a QTextStream as a QStringList. +* +* +* The delimited text parser is used by the QgsDelimitedTextProvider to parse +* a QTextStream into records of QStringList. It provides a number of variants +* for parsing each record. The following options are supported: +* - Basic whitespace parsing. Each line in the file is treated as a record. +* Extracts all contiguous sequences of non-whitespace +* characters. Leading and trailing whitespace are ignored. +* - Regular expression parsing. Each line in the file is treated as a record. +* The string is split into fields based on a regular expression. +* - Character delimited, based on a delimiter character set, a quote character, and +* an escape character. The escape treats the next character as a part of a field. +* Fields may start and end with quote characters, in which case any non-escaped +* character within the field is treated literally, including end of line characters. +* The escape character within a string causes the next character to be read literally +* (this includes new line characters). If the escape and quote characters are the +* same, then only quote characters will be escaped (ie to include a quote in a +* quoted field it is entered as two quotes. All other characters in quoted fields +* are treated literally, including newlines. +* - CSV format files - these are a special case of character delimited, in which the +* delimiter is a comma, and the quote and escape characters are double quotes (") +* +* The delimiters can be encode in and decoded from a QUrl as query items. The +* items used are: +* - delimiterType, one of plain (delimiter is any of a set of characters), +* regexp, csv, whitespace +* - delimiter, interpreted according to the type. For plain characters this is +* a sequence of characters. The string \t in the sequence is replaced by a tab. +* For regexp type delimiters this specifies the reqular expression. +* The field is ignored for csv and whitespace +* - quoteChar, optional, a single character used for quoting plain fields +* - escapeChar, optional, a single characer used for escaping (may be the same as quoteChar) +*/ + +// Note: this has been implemented as a single class rather than a set of classes based +// on an abstract base class in order to facilitate changing the type of the parser easily +// eg in the provider dialog + +class QgsDelimitedTextFile +{ + + public: + + enum Status + { + RecordOk, + InvalidDefinition, + RecordEmpty, + RecordInvalid, + RecordEOF + }; + + enum DelimiterType + { + DelimTypeWhitespace, + DelimTypeCSV, + DelimTypeRegexp, + }; + + QgsDelimitedTextFile( QString url = QString() ); + + virtual ~QgsDelimitedTextFile(); + + /** Set the filename + * @param filename the name of the file + */ + void setFileName( QString filename ); + /** Return the filename + * @return filename the name of the file + */ + QString fileName() + { + return mFileName; + } + + /** Set the file encoding (defuault is UTF-8) + * @param encoding the encoding to use for the fileName() + */ + void setEncoding( QString encoding ); + /** Return the file encoding + * @return encoding The file encoding + */ + QString encoding() { return mEncoding; } + + /** Decode the parser settings from a url as a string + * @param url The url from which the delimiter and delimiterType items are read + */ + bool setFromUrl( QString url ); + /** Decode the parser settings from a url + * @param url The url from which the delimiter and delimiterType items are read + */ + bool setFromUrl( QUrl &url ); + + /** Encode the parser settings into a QUrl + * @return url The url into which the delimiter and delimiterType items are set + */ + QUrl url(); + + /** Set the parser for parsing CSV files + */ + void setTypeWhitespace(); + + /** Set the parser for parsing based on a reqular expression delimiter + @param regexp A string defining the regular expression + */ + void setTypeRegexp( QString regexp ); + /** Set the parser to use a character type delimiter. + * @param delim The field delimiter character set + * @param quote The quote character, used to define quoted fields + * @param escape The escape character used to escape quote or delim + * characters. + */ + void setTypeCSV( QString delim = QString( "," ), QString quote = QString( "\"" ), QString escape = QString( "\"" ) ); + + /* Set the number of header lines to skip + * @param skiplines The maximum lines to skip + */ + void setSkipLines( int skiplines ); + /* Return the number of header lines to skip + * @return skiplines The maximum lines to skip + */ + int skipLines() + { + return mSkipLines; + } + + /* Set reading column names from the first record + * @param useheaders Column names will be read if true + */ + void setUseHeader( bool useheader = true ); + /* Return the option for reading column names from the first record + * @return useheaders Column names will be read if true + */ + bool useHeader() + { + return mUseHeader; + } + + /* Set the option for dicarding empty fields + * @param useheaders Empty fields will be discarded if true + */ + void setDiscardEmptyFields( bool discardEmptyFields = true ); + /* Return the option for discarding empty fields + * @return useheaders Empty fields will be discarded if true + */ + bool discardEmptyFields() + { + return mDiscardEmptyFields; + } + + /* Set the option for trimming whitespace from fields + * @param trimFields Fields will be trimmed if true + */ + void setTrimFields( bool trimFields = true ); + /* Return the option for trimming empty fields + * @return useheaders Empty fields will be trimmed if true + */ + bool trimFields() + { + return mTrimFields; + } + + /** Return the column names read from the header, or default names + * Col## if none defined. Will open and read the head of the file + * if required, then reset.. + */ + QStringList &columnNames(); + + /** Reads the next record from the stream splits into string fields. + * @param fields The string list to populate with the fields + * @return status The result of trying to parse a record. RecordOk + * if read successfully, RecordEOF if reached the end of the + * file, RecordEmpty if no data on the next line, and + * RecordInvalid if the record is ill-formatted. + */ + Status nextRecord( QStringList &fields ); + + /** Return the line number of the start of the last record read + * @return linenumber The line number of the start of the record + */ + int recordLineNumber() + { + return mRecordLineNumber; + } + + /** Reset the file to reread from the beginning + */ + Status reset(); + + /** Return a string defining the type of the delimiter as a string + * @return type The delimiter type as a string + */ + QString type(); + + /** Check that provider is valid (filename and definition valid) + * + * @return valid True if the provider is valid + */ + bool isValid(); + + /** Encode characters - used to convert delimiter/quote/escape characters to + * encoded form (eg replace tab with \t) + * @param string The unencoded string + * @return encstring The encoded string + */ + static QString encodeChars( QString string ); + + /** Encode characters - used to encoded character strings to + * decoded form (eg replace \t with tab) + * @param string The unencoded string + * @return decstring The decoded string + */ + static QString decodeChars( QString string ); + + + + + private: + + /** Open the file + * + * @return valid True if the file is successfully opened + */ + bool open(); + + /** Close the text file + */ + void close(); + + /** Reset the status if the definition is changing (eg clear + * existing column names, etc... + */ + void resetDefinition(); + + /** Parse reqular expression delimited fields */ + Status parseRegexp( QStringList &fields ); + /** Parse quote delimited fields, where quote and escape are different */ + Status parseQuoted( QStringList &fields ); + + /** Return the next line from the data file. If skipBlank is true then + * blank lines will be skipped - this is for compatibility with previous + * delimited text parser implementation. + */ + Status nextLine( QString &buffer, bool skipBlank = false ); + + // Pointer to the currently selected parser + Status( QgsDelimitedTextFile::*mParser )( QStringList &fields ); + + QString mFileName; + QString mEncoding; + QFile *mFile; + QTextStream *mStream; + + // Parameters common to parsers + bool mDefinitionValid; + DelimiterType mType; + bool mUseHeader; + bool mDiscardEmptyFields; + bool mTrimFields; + int mSkipLines; + int mMaxFields; + + // Parameters used by parsers + QRegExp mDelimRegexp; + QString mDelimChars; + QString mQuoteChar; + QString mEscapeChar; + + // Information extracted from file + QStringList mColumnNames; + int mLineNumber; + int mRecordLineNumber; +}; diff --git a/src/providers/ogr/qgsogrprovider.cpp b/src/providers/ogr/qgsogrprovider.cpp index 533baf9a2530..8b8424fe0182 100644 --- a/src/providers/ogr/qgsogrprovider.cpp +++ b/src/providers/ogr/qgsogrprovider.cpp @@ -504,7 +504,7 @@ void QgsOgrProvider::setEncoding( const QString& e ) { #if defined(OLCStringsAsUTF8) QSettings settings; - if ( ( ogrDriverName == "ESRI Shapefile" && settings.value( "/qgis/ignoreShapeEncoding", true ).toBool() ) || !OGR_L_TestCapability( ogrLayer, OLCStringsAsUTF8 ) ) + if (( ogrDriverName == "ESRI Shapefile" && settings.value( "/qgis/ignoreShapeEncoding", true ).toBool() ) || !OGR_L_TestCapability( ogrLayer, OLCStringsAsUTF8 ) ) { QgsVectorDataProvider::setEncoding( e ); } diff --git a/tests/bench/qgsbench.cpp b/tests/bench/qgsbench.cpp index 1b6580b6531b..c1ded220612e 100644 --- a/tests/bench/qgsbench.cpp +++ b/tests/bench/qgsbench.cpp @@ -299,7 +299,7 @@ QString QgsBench::serialize( QMap theMap, int level ) list.append( space2 + "\"" + i.key() + "\": " + QString( "%1" ).arg( i.value().toDouble(), 0, 'f', 3 ) ); break; case QMetaType::QString: - list.append( space2 + "\"" + i.key() + "\": \"" + i.value().toString().replace("\\","\\\\").replace("\"","\\\"") + "\"" ); + list.append( space2 + "\"" + i.key() + "\": \"" + i.value().toString().replace( "\\", "\\\\" ).replace( "\"", "\\\"" ) + "\"" ); break; //case QMetaType::QMap: QMap is not in QMetaType default: diff --git a/tests/src/gui/testqgsdualview.cpp b/tests/src/gui/testqgsdualview.cpp index c22414363734..ebb1ff3221cb 100644 --- a/tests/src/gui/testqgsdualview.cpp +++ b/tests/src/gui/testqgsdualview.cpp @@ -86,7 +86,7 @@ void TestQgsDualView::testSelectAll() mCanvas->setExtent( QgsRectangle( -139, 23, -100, 48 ) ); mDualView->mTableView->selectAll(); QVERIFY( mPointsLayer->selectedFeatureCount() == 10 ); - + mPointsLayer->setSelectedFeatures( QgsFeatureIds() ); mCanvas->setExtent( QgsRectangle( -110, 40, -100, 48 ) ); mDualView->mTableView->selectAll(); diff --git a/tests/src/python/test_qgsdelimitedtextprovider.py b/tests/src/python/test_qgsdelimitedtextprovider.py index c76b061b3e0c..f9abc654feb1 100644 --- a/tests/src/python/test_qgsdelimitedtextprovider.py +++ b/tests/src/python/test_qgsdelimitedtextprovider.py @@ -13,11 +13,11 @@ __revision__ = '$Format:%H$' # This module provides unit test for the delimtied text provider. It uses data files in -# the testdata/delimitedtext directory. +# the testdata/delimitedtext directory. # # New tests can be created (or existing ones updated), but incorporating a createTest -# call into the test. This will load the file and generate a test that the features -# loaded from it are correct. It assumes that the data is correct at the time the +# call into the test. This will load the file and generate a test that the features +# loaded from it are correct. It assumes that the data is correct at the time the # test is created. The new test is written to the test output file, and can be edited into # this module to implement the test. # @@ -28,7 +28,7 @@ import os.path; import re -from PyQt4.QtCore import (QVariant, +from PyQt4.QtCore import (QVariant, QUrl, QObject, QString, @@ -73,7 +73,7 @@ def __enter__( self ): def __exit__( self, type, value, traceback ): QgsMessageLog.instance().messageReceived.disconnect( self.logMessage ) - + def logMessage( self, msg, tag, level ): if tag == self.tag or not self.tag: self.log.append(unicode(msg)) @@ -146,7 +146,7 @@ def createTest( name, description, filename, **params ): print " if printTests:" print " createTest({0},description,filename,**params)".format(repr(name)) print " assert False,\"Set printTests to False to run delimited text tests\"" - + data=result['data'] log=result['log'] fields=result['fields'] @@ -167,7 +167,7 @@ def createTest( name, description, filename, **params ): print prefix+' '+repr(msg)+',' print prefix+' ]' print ' runTest(description,wanted,log_wanted,filename,**params)' - print + print def checkWktEqual( wkt1, wkt2 ): @@ -186,7 +186,7 @@ def checkWktEqual( wkt1, wkt2 ): diff=abs(float(p1[i])-float(p2[i])) if diff > tolerance: return False else: - # Could be more fancy here in terms of text comparison if + # Could be more fancy here in terms of text comparison if # turn out to be necessary. if p1 != p2: return False return True @@ -194,7 +194,7 @@ def checkWktEqual( wkt1, wkt2 ): def recordDifference( record1, record2 ): # Compare a record defined as a dictionary for k in record1.keys(): - if k not in record2: + if k not in record2: return "Field {0} is missing".format(k) r1k = record1[k] r2k = record2[k] @@ -202,17 +202,17 @@ def recordDifference( record1, record2 ): if not checkWktEqual(r1k,r2k): return "Geometry differs: {0:.50} versus {1:.50}".format(r1k,r2k) else: - if record1[k] != record2[k]: + if record1[k] != record2[k]: return "Field {0} differs: {1:.50} versus {2:.50}".format(k,repr(r1k),repr(r2k)); for k in record2.keys(): - if k not in record1: + if k not in record1: return "Output contains extra field {0} is missing".format(k) return '' def runTest( name, wanted, log_wanted, file, **params ): print "Running test:",name - - result = delimitedTextData( file, **params ) + + result = delimitedTextData( file, **params ) data = result['data'] log = result['log']