Example #1
0
QVariant QgsListWidgetWrapper::value() const
{
  QVariant::Type type = field().type();
  if ( !mWidget ) return QVariant( type );
  if ( type == QVariant::StringList )
  {
    QStringList result;
    const QVariantList list = mWidget->list();
    for ( QVariantList::const_iterator it = list.constBegin(); it != list.constEnd(); ++it )
      result.append( it->toString() );
    return result;
  }
  else
    return QVariant( mWidget->list() );
}
Example #2
0
QString QgsListFieldFormatter::representValue( QgsVectorLayer* layer, int fieldIndex, const QVariantMap& config, const QVariant& cache, const QVariant& value ) const
{
  Q_UNUSED( layer );
  Q_UNUSED( fieldIndex );
  Q_UNUSED( config );
  Q_UNUSED( cache );

  if ( value.isNull() )
  {
    QSettings settings;
    return QgsApplication::nullRepresentation();
  }

  QString result;
  const QVariantList list = value.toList();
  for ( QVariantList::const_iterator i = list.constBegin(); i != list.constEnd(); ++i )
  {
    if ( !result.isEmpty() ) result.append( ", " );
    result.append( i->toString() );
  }
  return result;
}
Example #3
0
QString QgsListWidgetFactory::representValue( QgsVectorLayer* vl, int fieldIdx, const QgsEditorWidgetConfig& config, const QVariant& cache, const QVariant& value ) const
{
  Q_UNUSED( vl );
  Q_UNUSED( fieldIdx );
  Q_UNUSED( config );
  Q_UNUSED( cache );

  if ( value.isNull() )
  {
    QSettings settings;
    return settings.value( "qgis/nullValue", "NULL" ).toString();
  }

  QString result;
  const QVariantList list = value.toList();
  for ( QVariantList::const_iterator i = list.constBegin(); i != list.constEnd(); ++i )
  {
    if ( !result.isEmpty() ) result.append( ", " );
    result.append( i->toString() );
  }
  return result;
}