[QGIS Commit] r15233 - in trunk/qgis: python/plugins/osm
src/providers/osm
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Mon Feb 21 09:36:46 EST 2011
Author: jef
Date: 2011-02-21 06:36:46 -0800 (Mon, 21 Feb 2011)
New Revision: 15233
Modified:
trunk/qgis/python/plugins/osm/OsmLoadDlg.py
trunk/qgis/src/providers/osm/osmprovider.cpp
trunk/qgis/src/providers/osm/osmprovider.h
Log:
fix #2996
Modified: trunk/qgis/python/plugins/osm/OsmLoadDlg.py
===================================================================
--- trunk/qgis/python/plugins/osm/OsmLoadDlg.py 2011-02-21 13:17:07 UTC (rev 15232)
+++ trunk/qgis/python/plugins/osm/OsmLoadDlg.py 2011-02-21 14:36:46 UTC (rev 15233)
@@ -224,17 +224,15 @@
def setCustomRenderer(self, layer):
"""Function provides a way how to set custom renderer.
-
- For more check changeAttributeValues() implementation of OSM provider.
-
- @param layer point to QGIS vector layer
+ @param layer pointer to QGIS vector layer
"""
- import sip
- layerAddr = sip.unwrapinstance(layer)
- layer.dataProvider().changeAttributeValues( { 0x12345678 : { 0 : QVariant(layerAddr) } } )
+ if QObject.connect( self, SIGNAL( "setRenderer(QgsVectorLayer *)" ), layer.dataProvider(), SLOT( "setRenderer( QgsVectorLayer * )" ) ):
+ self.emit( SIGNAL( "setRenderer(QgsVectorLayer *)" ), layer )
+ QObject.disconnect( self, SIGNAL( "setRenderer(QgsVectorLayer *)" ), layer.dataProvider(), SLOT( "setRenderer( QgsVectorLayer * )" ) )
+ else:
+ QMessageBox.information(self, "OSM Load", QString("Could not connect to setRenderer signal."))
-
def filesLoaded(self):
"""Function returns list of keys of all currently loaded vector layers.
Note that names are not absolute and not unique.
Modified: trunk/qgis/src/providers/osm/osmprovider.cpp
===================================================================
--- trunk/qgis/src/providers/osm/osmprovider.cpp 2011-02-21 13:17:07 UTC (rev 15232)
+++ trunk/qgis/src/providers/osm/osmprovider.cpp 2011-02-21 14:36:46 UTC (rev 15233)
@@ -981,23 +981,6 @@
}
-bool QgsOSMDataProvider::changeAttributeValues( const QgsChangedAttributesMap & attr_map )
-{
- QgsDebugMsg( QString( "In changeAttributeValues(...)." ) );
-
- // VERY VERY ugly hack to assign custom renderer for OSM layer
- // but probably there's no simple way how to set our custom renderer from python plugin
- if ( attr_map.contains( 0x12345678 ) )
- {
- const QgsAttributeMap& x = attr_map.value( 0x12345678 );
- QgsVectorLayer* layer = ( QgsVectorLayer* ) x.value( 0 ).toUInt();
- QgsDebugMsg( "SETTING CUSTOM RENDERER!" );
- layer->setRenderer( new OsmRenderer( layer->geometryType(), mStyleFileName ) );
- }
- return true;
-}
-
-
int QgsOSMDataProvider::capabilities() const
{
return QgsVectorDataProvider::SelectAtId | QgsVectorDataProvider::SelectGeometryAtId;
@@ -1682,4 +1665,7 @@
return true;
};
-
+void QgsOSMDataProvider::setRenderer( QgsVectorLayer *layer )
+{
+ layer->setRenderer( new OsmRenderer( layer->geometryType(), mStyleFileName ) );
+}
Modified: trunk/qgis/src/providers/osm/osmprovider.h
===================================================================
--- trunk/qgis/src/providers/osm/osmprovider.h 2011-02-21 13:17:07 UTC (rev 15232)
+++ trunk/qgis/src/providers/osm/osmprovider.h 2011-02-21 14:36:46 UTC (rev 15233)
@@ -193,13 +193,6 @@
virtual void rewind();
/**
- * Changes attribute values of existing features.
- * @param attr_map a map containing changed attributes
- * @return true in case of success and false in case of failure
- */
- virtual bool changeAttributeValues( const QgsChangedAttributesMap & attr_map );
-
- /**
* Returns a bitmask containing the supported capabilities
* Note, some capabilities may change depending on whether
* a spatial filter is active on this provider, so it may
@@ -235,6 +228,8 @@
*/
virtual QgsCoordinateReferenceSystem crs();
+ public slots:
+ virtual void setRenderer( QgsVectorLayer *layer );
private:
/**
More information about the QGIS-commit
mailing list