Skip to content

Commit 12df5c5

Browse files
author
jef
committed
fix #2996
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@15233 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent f6a6da9 commit 12df5c5

File tree

3 files changed

+12
-33
lines changed

3 files changed

+12
-33
lines changed

python/plugins/osm/OsmLoadDlg.py

+6-8
Original file line numberDiff line numberDiff line change
@@ -224,16 +224,14 @@ def onOK(self):
224224

225225
def setCustomRenderer(self, layer):
226226
"""Function provides a way how to set custom renderer.
227-
228-
For more check changeAttributeValues() implementation of OSM provider.
229-
230-
@param layer point to QGIS vector layer
227+
@param layer pointer to QGIS vector layer
231228
"""
232229

233-
import sip
234-
layerAddr = sip.unwrapinstance(layer)
235-
layer.dataProvider().changeAttributeValues( { 0x12345678 : { 0 : QVariant(layerAddr) } } )
236-
230+
if QObject.connect( self, SIGNAL( "setRenderer(QgsVectorLayer *)" ), layer.dataProvider(), SLOT( "setRenderer( QgsVectorLayer * )" ) ):
231+
self.emit( SIGNAL( "setRenderer(QgsVectorLayer *)" ), layer )
232+
QObject.disconnect( self, SIGNAL( "setRenderer(QgsVectorLayer *)" ), layer.dataProvider(), SLOT( "setRenderer( QgsVectorLayer * )" ) )
233+
else:
234+
QMessageBox.information(self, "OSM Load", QString("Could not connect to setRenderer signal."))
237235

238236
def filesLoaded(self):
239237
"""Function returns list of keys of all currently loaded vector layers.

src/providers/osm/osmprovider.cpp

+4-18
Original file line numberDiff line numberDiff line change
@@ -981,23 +981,6 @@ int QgsOSMDataProvider::freeFeatureId()
981981
}
982982

983983

984-
bool QgsOSMDataProvider::changeAttributeValues( const QgsChangedAttributesMap & attr_map )
985-
{
986-
QgsDebugMsg( QString( "In changeAttributeValues(...)." ) );
987-
988-
// VERY VERY ugly hack to assign custom renderer for OSM layer
989-
// but probably there's no simple way how to set our custom renderer from python plugin
990-
if ( attr_map.contains( 0x12345678 ) )
991-
{
992-
const QgsAttributeMap& x = attr_map.value( 0x12345678 );
993-
QgsVectorLayer* layer = ( QgsVectorLayer* ) x.value( 0 ).toUInt();
994-
QgsDebugMsg( "SETTING CUSTOM RENDERER!" );
995-
layer->setRenderer( new OsmRenderer( layer->geometryType(), mStyleFileName ) );
996-
}
997-
return true;
998-
}
999-
1000-
1001984
int QgsOSMDataProvider::capabilities() const
1002985
{
1003986
return QgsVectorDataProvider::SelectAtId | QgsVectorDataProvider::SelectGeometryAtId;
@@ -1682,4 +1665,7 @@ bool QgsOSMDataProvider::closeDatabase()
16821665
return true;
16831666
};
16841667

1685-
1668+
void QgsOSMDataProvider::setRenderer( QgsVectorLayer *layer )
1669+
{
1670+
layer->setRenderer( new OsmRenderer( layer->geometryType(), mStyleFileName ) );
1671+
}

src/providers/osm/osmprovider.h

+2-7
Original file line numberDiff line numberDiff line change
@@ -192,13 +192,6 @@ class QgsOSMDataProvider: public QgsVectorDataProvider
192192
*/
193193
virtual void rewind();
194194

195-
/**
196-
* Changes attribute values of existing features.
197-
* @param attr_map a map containing changed attributes
198-
* @return true in case of success and false in case of failure
199-
*/
200-
virtual bool changeAttributeValues( const QgsChangedAttributesMap & attr_map );
201-
202195
/**
203196
* Returns a bitmask containing the supported capabilities
204197
* Note, some capabilities may change depending on whether
@@ -235,6 +228,8 @@ class QgsOSMDataProvider: public QgsVectorDataProvider
235228
*/
236229
virtual QgsCoordinateReferenceSystem crs();
237230

231+
public slots:
232+
virtual void setRenderer( QgsVectorLayer *layer );
238233

239234
private:
240235
/**

0 commit comments

Comments
 (0)