23 void QgsSaveSelectedFeatures::initAlgorithm(
const QVariantMap & )
30 QString QgsSaveSelectedFeatures::name()
const
32 return QStringLiteral(
"saveselectedfeatures" );
35 QString QgsSaveSelectedFeatures::displayName()
const
37 return QObject::tr(
"Extract selected features" );
40 QStringList QgsSaveSelectedFeatures::tags()
const
42 return QObject::tr(
"selection,save,by" ).split(
',' );
45 QString QgsSaveSelectedFeatures::group()
const
47 return QObject::tr(
"Vector general" );
50 QString QgsSaveSelectedFeatures::groupId()
const
52 return QStringLiteral(
"vectorgeneral" );
55 QString QgsSaveSelectedFeatures::shortHelpString()
const
57 return QObject::tr(
"This algorithm creates a new layer with all the selected features in a given vector layer.\n\n"
58 "If the selected layer has no selected features, the newly created layer will be empty." );
61 QgsSaveSelectedFeatures *QgsSaveSelectedFeatures::createInstance()
const
63 return new QgsSaveSelectedFeatures();
68 QgsVectorLayer *selectLayer = parameterAsVectorLayer( parameters, QStringLiteral(
"INPUT" ), context );
78 QgsVectorLayer *selectLayer = parameterAsVectorLayer( parameters, QStringLiteral(
"INPUT" ), context );
83 std::unique_ptr< QgsFeatureSink > sink( parameterAsSink( parameters, QStringLiteral(
"OUTPUT" ), context, dest, selectLayer->
fields(), selectLayer->
wkbType(), selectLayer->
sourceCrs() ) );
88 int count = mSelection.count();
90 double step = count > 0 ? 100.0 / count : 1;
107 outputs.insert( QStringLiteral(
"OUTPUT" ), dest );