Skip to content

Commit

Permalink
fix #2996
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@15233 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Feb 21, 2011
1 parent f6a6da9 commit 12df5c5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 33 deletions.
14 changes: 6 additions & 8 deletions python/plugins/osm/OsmLoadDlg.py
Expand Up @@ -224,16 +224,14 @@ def onOK(self):

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.
Expand Down
22 changes: 4 additions & 18 deletions src/providers/osm/osmprovider.cpp
Expand Up @@ -981,23 +981,6 @@ int QgsOSMDataProvider::freeFeatureId()
}


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;
Expand Down Expand Up @@ -1682,4 +1665,7 @@ bool QgsOSMDataProvider::closeDatabase()
return true;
};


void QgsOSMDataProvider::setRenderer( QgsVectorLayer *layer )
{
layer->setRenderer( new OsmRenderer( layer->geometryType(), mStyleFileName ) );
}
9 changes: 2 additions & 7 deletions src/providers/osm/osmprovider.h
Expand Up @@ -192,13 +192,6 @@ class QgsOSMDataProvider: public QgsVectorDataProvider
*/
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
Expand Down Expand Up @@ -235,6 +228,8 @@ class QgsOSMDataProvider: public QgsVectorDataProvider
*/
virtual QgsCoordinateReferenceSystem crs();

public slots:
virtual void setRenderer( QgsVectorLayer *layer );

private:
/**
Expand Down

0 comments on commit 12df5c5

Please sign in to comment.