Exemplo n.º 1
0
bool QgsMapToolLabel::dataDefinedShowHide( QgsVectorLayer* vlayer, const QgsFeatureId &featureId, int& show, bool& showSuccess, int& showCol ) const
{
  showSuccess = false;
  if ( !vlayer )
  {
    return false;
  }

  if ( !layerCanShowHide( vlayer, showCol ) )
  {
    return false;
  }

  QgsFeature f;
  if ( !vlayer->getFeatures( QgsFeatureRequest().setFilterFid( featureId ).setFlags( QgsFeatureRequest::NoGeometry ) ).nextFeature( f ) )
  {
    return false;
  }

  show = f.attribute( showCol ).toInt( &showSuccess );
  return true;
}
Exemplo n.º 2
0
bool QgsMapToolLabel::dataDefinedShowHide( QgsVectorLayer* vlayer, int featureId, int& show, bool& showSuccess, int& showCol )
{
    showSuccess = false;
    if ( !vlayer )
    {
        return false;
    }

    if ( !layerCanShowHide( vlayer, showCol ) )
    {
        return false;
    }

    QgsFeature f;
    if ( !vlayer->featureAtId( featureId, f, false, true ) )
    {
        return false;
    }

    QgsAttributeMap attributes = f.attributeMap();

    show = attributes[showCol].toInt( &showSuccess );
    return true;
}