mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-27 00:33:48 -05:00
available values of value map
This commit is contained in:
parent
a02cdbc39a
commit
54f4efbd86
@ -46,6 +46,9 @@ Default constructor of field formatter for a value map field.
|
||||
|
||||
virtual QVariant sortValue( QgsVectorLayer *layer, int fieldIndex, const QVariantMap &config, const QVariant &cache, const QVariant &value ) const;
|
||||
|
||||
|
||||
virtual QList<QVariant> availableValues( const QVariantMap &config, int countLimit ) const;
|
||||
|
||||
};
|
||||
|
||||
/************************************************************************
|
||||
|
@ -19,6 +19,11 @@
|
||||
|
||||
const QString QgsValueMapFieldFormatter::NULL_VALUE = QStringLiteral( "{2839923C-8B7D-419E-B84B-CA2FE9B80EC7}" );
|
||||
|
||||
QgsValueMapFieldFormatter::QgsValueMapFieldFormatter()
|
||||
{
|
||||
setFlags( flags() | QgsFieldFormatter::CanProvideAvailableValues );
|
||||
}
|
||||
|
||||
QString QgsValueMapFieldFormatter::id() const
|
||||
{
|
||||
return QStringLiteral( "ValueMap" );
|
||||
@ -62,3 +67,17 @@ QVariant QgsValueMapFieldFormatter::sortValue( QgsVectorLayer *layer, int fieldI
|
||||
{
|
||||
return representValue( layer, fieldIndex, config, cache, value );
|
||||
}
|
||||
|
||||
QList<QVariant> QgsValueMapFieldFormatter::availableValues( const QVariantMap &config, int countLimit ) const
|
||||
{
|
||||
QList<QVariant> values;
|
||||
QList<QVariant> valueList = config.value( QStringLiteral( "map" ) ).toList();
|
||||
for ( const QVariant &item : valueList )
|
||||
{
|
||||
values.append( item.toMap().constBegin().value() );
|
||||
if ( values.count() == countLimit )
|
||||
break;
|
||||
}
|
||||
|
||||
return values;
|
||||
}
|
||||
|
@ -49,13 +49,15 @@ class CORE_EXPORT QgsValueMapFieldFormatter : public QgsFieldFormatter
|
||||
/**
|
||||
* Default constructor of field formatter for a value map field.
|
||||
*/
|
||||
QgsValueMapFieldFormatter() = default;
|
||||
QgsValueMapFieldFormatter();
|
||||
|
||||
QString id() const override;
|
||||
|
||||
QString representValue( QgsVectorLayer *layer, int fieldIndex, const QVariantMap &config, const QVariant &cache, const QVariant &value ) const override;
|
||||
|
||||
QVariant sortValue( QgsVectorLayer *layer, int fieldIndex, const QVariantMap &config, const QVariant &cache, const QVariant &value ) const override;
|
||||
|
||||
QList<QVariant> availableValues( const QVariantMap &config, int countLimit ) const override;
|
||||
};
|
||||
|
||||
#endif // QGSVALUEMAPFIELDKIT_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user