Skip to content
Permalink
Browse files

fix #2996

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@15233 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef
jef committed Feb 21, 2011
1 parent f6a6da9 commit 12df5c569725b2f4e910ebaa44e1a98992430f14
Showing with 12 additions and 33 deletions.
  1. +6 −8 python/plugins/osm/OsmLoadDlg.py
  2. +4 −18 src/providers/osm/osmprovider.cpp
  3. +2 −7 src/providers/osm/osmprovider.h
@@ -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.
@@ -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;
@@ -1682,4 +1665,7 @@ bool QgsOSMDataProvider::closeDatabase()
return true;
};


void QgsOSMDataProvider::setRenderer( QgsVectorLayer *layer )
{
layer->setRenderer( new OsmRenderer( layer->geometryType(), mStyleFileName ) );
}
@@ -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
@@ -235,6 +228,8 @@ class QgsOSMDataProvider: public QgsVectorDataProvider
*/
virtual QgsCoordinateReferenceSystem crs();

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

private:
/**

0 comments on commit 12df5c5

Please sign in to comment.
You can’t perform that action at this time.