28 #include <QPainterPath> 30 #include <QProgressDialog> 89 #ifdef TESTPROVIDERLIB 98 const QString& styleDescription,
126 bool loadDefaultStyleFlag )
127 :
QgsMapLayer( VectorLayer, baseName, vectorLayerPath )
128 , mDataProvider( nullptr )
129 , mProviderKey( providerKey )
132 , mWkbType(
QGis::WKBUnknown )
133 , mRendererV2( nullptr )
137 , mLabelFontNotFoundNotified( false )
138 , mFeatureBlendMode(
QPainter::CompositionMode_SourceOver )
139 , mLayerTransparency( 0 )
140 , mVertexMarkerOnlyForSelection( false )
142 , mEditBuffer( nullptr )
143 , mJoinBuffer( nullptr )
144 , mExpressionFieldBuffer( nullptr )
145 , mDiagramRenderer( nullptr )
146 , mDiagramLayerSettings( nullptr )
147 , mValidExtent( false )
148 , mLazyExtent( true )
149 , mSymbolFeatureCounted( false )
150 , mEditCommandActive( false )
157 if ( ! mProviderKey.
isEmpty() )
159 setDataSource( vectorLayerPath, baseName, providerKey, loadDefaultStyleFlag );
167 mSimplifyMethod.
setSimplifyHints( static_cast< QgsVectorSimplifyMethod::SimplifyHints >( settings.
value(
"/qgis/simplifyDrawingHints", static_cast< int>( mSimplifyMethod.
simplifyHints() ) ).
toInt() ) );
183 delete mDataProvider;
186 delete mExpressionFieldBuffer;
190 delete mDiagramLayerSettings;
191 delete mDiagramRenderer;
196 delete mConditionalStyles;
251 mDisplayField = fldName;
255 int fieldsSize = mUpdatedFields.
size();
257 for (
int idx = 0; idx < mUpdatedFields.
count(); ++idx )
266 if ( fldName.
indexOf(
"name", 0, Qt::CaseInsensitive ) > -1 )
273 if ( fldName.
indexOf(
"descrip", 0, Qt::CaseInsensitive ) > -1 )
280 if ( fldName.
indexOf(
"id", 0, Qt::CaseInsensitive ) > -1 )
290 if ( fieldsSize == 0 )
293 if ( idxName.
length() > 0 )
295 mDisplayField = idxName;
301 mDisplayField = idxId;
305 mDisplayField = mUpdatedFields.
at( 0 ).
name();
322 if ( mRendererV2 && mLabelOn && mLabel &&
331 attributes.
append( attrNum );
339 QgsDebugMsg(
"Selecting features based on view extent" );
348 .setFilterRect( rendererContext.
extent() )
349 .setSubsetOfAttributes( attributes ) );
356 bool sel = mSelectedFeatureIds.
contains( fet.id() );
357 mLabel->
renderLabel( rendererContext, fet, sel,
nullptr );
403 p.
drawEllipse( x - m, y - m, m * 2 + 1, m * 2 + 1 );
408 p.
drawLine( x - m, y + m, x + m, y - m );
409 p.
drawLine( x - m, y - m, x + m, y + m );
415 mSelectedFeatureIds.
insert( fid );
422 mSelectedFeatureIds.
unite( featureIds );
429 mSelectedFeatureIds.
remove( fid );
436 mSelectedFeatureIds.
subtract( featureIds );
448 .setFilterRect( rect )
460 if ( !addToSelection )
473 if ( !intersectingIds.
isEmpty() )
475 QgsDebugMsg(
"Trying to select and deselect the same item at the same time. Unsure what to do. Selecting dubious items." );
478 mSelectedFeatureIds -= deselectIds;
479 mSelectedFeatureIds += selectIds;
487 ids.
subtract( mSelectedFeatureIds );
519 .setFilterRect( rect )
529 if ( mSelectedFeatureIds.
contains( fet.
id() ) )
531 deselectIds << fet.
id();
535 selectIds << fet.
id();
544 if ( mSelectedFeatureIds.
isEmpty() )
552 return mDataProvider;
557 return mDataProvider;
562 if (
mValid && mDataProvider && mDataProvider->
encoding() != encoding )
571 delete mDiagramRenderer;
572 mDiagramRenderer = r;
578 if (
mValid && mDataProvider )
585 QgsDebugMsg(
"invalid layer or pointer to mDataProvider is null" );
593 QgsDebugMsg(
"WARNING: This code should never be reached. Problems may occur..." );
623 .setFilterFids( mSelectedFeatureIds )
641 if ( mSelectedFeatureIds.
contains( fet.
id() ) )
652 if ( retval.
width() == 0.0 || retval.
height() == 0.0 )
661 retval.
set( -1.0, -1.0, 1.0, 1.0 );
675 if ( mLabeling->
type() ==
"simple" )
684 if ( !mDiagramRenderer || !mDiagramLayerSettings )
690 return settingList.
at( 0 ).enabled;
697 if ( !mSymbolFeatureCounted )
700 return mSymbolFeatureCountMap.
value( symbol );
705 if ( mSymbolFeatureCounted )
708 mSymbolFeatureCountMap.
clear();
715 if ( !mDataProvider )
729 for ( ; symbolIt != symbolList.
constEnd(); ++symbolIt )
731 mSymbolFeatureCountMap.
insert( symbolIt->second, 0 );
735 QProgressDialog progressDialog(
tr(
"Updating feature count for layer %1" ).arg(
name() ),
tr(
"Abort" ), 0, nFeatures );
738 int featuresCounted = 0;
758 mSymbolFeatureCountMap[*symbolIt] += 1;
764 if ( featuresCounted % 50 == 0 )
766 if ( featuresCounted > nFeatures )
770 progressDialog.
setValue( featuresCounted );
773 mSymbolFeatureCountMap.
clear();
781 progressDialog.
setValue( nFeatures );
782 mSymbolFeatureCounted =
true;
788 mValidExtent =
false;
805 if ( !mValidExtent && mLazyExtent && mDataProvider )
823 if ( !
mValid || !mDataProvider )
825 QgsDebugMsg(
"invoked with invalid layer or null mDataProvider" );
847 if ( it->constGeometry() )
887 if ( !
mValid || !mDataProvider )
889 QgsDebugMsg(
"invoked with invalid layer or null mDataProvider" );
897 if ( !
mValid || !mDataProvider )
899 QgsDebugMsg(
"invoked with invalid layer or null mDataProvider" );
919 double maximumSimplificationScale = mSimplifyMethod.
maximumScale();
922 if ( maximumSimplificationScale > 1 && renderContext.
rendererScale() <= maximumSimplificationScale )
932 return mConditionalStyles;
937 if ( !
mValid || !mDataProvider )
946 Q_UNUSED( alsoUpdateExtent );
947 if ( !
mValid || !mEditBuffer || !mDataProvider )
986 for (
int attr = 0; attr < fa.
count(); ++attr )
988 if ( fa.
at( attr ) != ca.
at( attr ) )
992 QgsDebugMsg(
QString(
"attribute %1 of feature %2 could not be changed." ).arg( attr ).arg( f.
id() ) );
1004 if ( !
mValid || !mEditBuffer || !mDataProvider )
1008 bool result = utils.
insertVertex( x, y, atFeatureId, beforeVertex );
1017 if ( !
mValid || !mEditBuffer || !mDataProvider )
1021 bool result = utils.
moveVertex( x, y, atFeatureId, atVertex );
1030 if ( !
mValid || !mEditBuffer || !mDataProvider )
1034 bool result = utils.
moveVertex( p, atFeatureId, atVertex );
1053 if ( !
mValid || !mEditBuffer || !mDataProvider )
1078 int count = mSelectedFeatureIds.
size();
1091 *deletedCount = deleted;
1094 return deleted == count;
1099 if ( !
mValid || !mEditBuffer || !mDataProvider )
1106 if ( !mSelectedFeatureIds.
isEmpty() )
1108 result = utils.
addRing( ring, mSelectedFeatureIds, featureId );
1122 if ( !
mValid || !mEditBuffer || !mDataProvider )
1143 if ( !mSelectedFeatureIds.
isEmpty() )
1145 result = utils.
addRing( static_cast< QgsCurveV2* >( ring->
clone() ), mSelectedFeatureIds, featureId );
1160 if ( !
mValid || !mEditBuffer || !mDataProvider )
1165 if ( mSelectedFeatureIds.
size() < 1 )
1170 else if ( mSelectedFeatureIds.
size() > 1 )
1186 if ( !
mValid || !mEditBuffer || !mDataProvider )
1191 if ( mSelectedFeatureIds.
size() < 1 )
1196 else if ( mSelectedFeatureIds.
size() > 1 )
1212 if ( !
mValid || !mEditBuffer || !mDataProvider )
1217 if ( mSelectedFeatureIds.
size() < 1 )
1222 else if ( mSelectedFeatureIds.
size() > 1 )
1238 if ( !
mValid || !mEditBuffer || !mDataProvider )
1251 if ( !
mValid || !mEditBuffer || !mDataProvider )
1255 return utils.
splitParts( splitLine, topologicalEditing );
1260 if ( !
mValid || !mEditBuffer || !mDataProvider )
1264 return utils.
splitFeatures( splitLine, topologicalEditing );
1272 int returnValue = 0;
1285 .setFilterRect( geomBBox )
1313 if ( !
mValid || !mEditBuffer || !mDataProvider )
1322 if ( !
mValid || !mEditBuffer || !mDataProvider )
1351 if ( mLabeling == labeling )
1360 if ( !
mValid || !mDataProvider )
1434 if ( pkeyNode.isNull() )
1441 mProviderKey = pkeyElt.
text();
1445 if ( !mProviderKey.
isNull() )
1452 mProviderKey =
"postgres";
1456 mProviderKey =
"ogr";
1459 if ( !setDataProvider( mProviderKey ) )
1465 if ( !pkeyElem.
isNull() )
1468 if ( !encodingString.
isEmpty() )
1478 connect( mJoinBuffer, SIGNAL( joinedFieldsChanged() ),
this, SLOT( onJoinedFieldsChanged() ) );
1480 mJoinBuffer->
readXml( layer_node );
1482 if ( !mExpressionFieldBuffer )
1484 mExpressionFieldBuffer->
readXml( layer_node );
1491 if ( prevExpNode.
isNull() )
1493 mDisplayExpression =
"";
1498 mDisplayExpression = prevExpElem.
text();
1524 setDataProvider( provider );
1537 bool defaultLoadedFlag =
false;
1538 if ( loadDefaultStyleFlag )
1558 bool QgsVectorLayer::setDataProvider(
QString const & provider )
1560 mProviderKey = provider;
1565 delete mDataProvider;
1569 if ( !mDataProvider )
1575 QgsDebugMsg(
"Instantiated the data provider plugin" );
1591 connect( mJoinBuffer, SIGNAL( joinedFieldsChanged() ),
this, SLOT( onJoinedFieldsChanged() ) );
1599 if ( mProviderKey ==
"postgres" )
1604 QRegExp reg(
"\"[^\"]+\"\\.\"([^\"]+)\"( \\([^)]+\\))?" );
1613 for ( it = layers.
constBegin(); it != layers.
constEnd() && ( *it )->name() != lName; ++it )
1618 lName +=
'.' + stuff[2].
mid( 2, stuff[2].length() - 3 );
1630 else if ( mProviderKey ==
"osm" )
1635 else if ( provider ==
"ogr" )
1664 if ( mapLayerNode.
isNull() || (
"maplayer" != mapLayerNode.
nodeName() ) )
1676 if ( mDataProvider )
1692 mJoinBuffer->
writeXml( layer_node, document );
1705 mExpressionFieldBuffer->
writeXml( layer_node, document );
1723 if ( !rendererElement.
isNull() )
1741 if ( !labelingElement.
isNull() )
1749 if ( !displayFieldNode.
isNull() )
1757 if ( !blendModeNode.isNull() )
1765 if ( !featureBlendModeNode.isNull() )
1773 if ( !layerTransparencyNode.isNull() )
1784 mLabel->
setMinScale( e.attribute(
"minLabelScale",
"1" ).toFloat() );
1785 mLabel->
setMaxScale( e.attribute(
"maxLabelScale",
"100000000" ).toFloat() );
1789 mSimplifyMethod.
setSimplifyHints( static_cast< QgsVectorSimplifyMethod::SimplifyHints >( e.attribute(
"simplifyDrawingHints",
"1" ).toInt() ) );
1790 mSimplifyMethod.
setThreshold( e.attribute(
"simplifyDrawingTol",
"1" ).toFloat() );
1792 mSimplifyMethod.
setMaximumScale( e.attribute(
"simplifyMaxScale",
"1" ).toFloat() );
1802 if ( hasLabelsEnabled < 1 )
1814 if ( !labelattributesnode.isNull() && mLabel )
1817 mLabel->
readXML( labelattributesnode );
1821 delete mDiagramRenderer;
1822 mDiagramRenderer =
nullptr;
1824 if ( !singleCatDiagramElem.
isNull() )
1827 mDiagramRenderer->
readXML( singleCatDiagramElem,
this );
1830 if ( !linearDiagramElem.
isNull() )
1833 mDiagramRenderer->
readXML( linearDiagramElem,
this );
1836 if ( mDiagramRenderer )
1839 if ( !diagramSettingsElem.
isNull() )
1841 delete mDiagramLayerSettings;
1843 mDiagramLayerSettings->
readXML( diagramSettingsElem,
this );
1851 mEditFormConfig->
readXml( node );
1854 if ( !annotationFormNode.
isNull() )
1860 mAttributeAliasMap.
clear();
1862 if ( !aliasesNode.
isNull() )
1867 for (
int i = 0; i < aliasNodeList.
size(); ++i )
1880 if ( index >= 0 && index <
fields().count() )
1889 mExcludeAttributesWMS.
clear();
1891 if ( !excludeWMSNode.
isNull() )
1894 for (
int i = 0; i < attributeNodeList.
size(); ++i )
1900 mExcludeAttributesWFS.
clear();
1902 if ( !excludeWFSNode.
isNull() )
1905 for (
int i = 0; i < attributeNodeList.
size(); ++i )
1911 mEditFormConfig->
readXml( node );
1913 mConditionalStyles->
readXml( node );
1964 featureBlendModeElem.
appendChild( featureBlendModeText );
1970 layerTransparencyElem.
appendChild( layerTransparencyText );
2002 if ( fieldname !=
"" )
2013 if ( mDiagramRenderer )
2015 mDiagramRenderer->
writeXML( mapLayerNode, doc,
this );
2016 if ( mDiagramLayerSettings )
2017 mDiagramLayerSettings->
writeXML( mapLayerNode, doc,
this );
2034 if ( !mAttributeAliasMap.
isEmpty() )
2038 for ( ; a_it != mAttributeAliasMap.
constEnd(); ++a_it )
2056 for ( ; attWMSIt != mExcludeAttributesWMS.
constEnd(); ++attWMSIt )
2068 for ( ; attWFSIt != mExcludeAttributesWFS.
constEnd(); ++attWFSIt )
2082 mConditionalStyles->
writeXml( node, doc );
2093 errorMessage =
"Warning: Name element not found within NamedLayer while it's required.";
2105 readSldLabeling( node );
2117 Q_UNUSED( errorMessage );
2140 if ( !mEditBuffer || !mDataProvider )
2157 Q_UNUSED( emitSignal );
2163 if ( !mEditBuffer || !mDataProvider )
2171 if ( !mEditBuffer || !mDataProvider )
2179 if ( attIndex < 0 || attIndex >=
fields().count() )
2183 if ( mAttributeAliasMap.
contains( name ) )
2185 mAttributeAliasMap.
remove( name );
2192 if ( attIndex < 0 || attIndex >=
fields().count() )
2197 mAttributeAliasMap.
insert( name, aliasString );
2203 if ( attributeIndex < 0 || attributeIndex >=
fields().count() )
2208 return mAttributeAliasMap.
value( name,
"" );
2216 if ( attributeIndex >= 0 && attributeIndex < mUpdatedFields.
count() )
2218 displayName = mUpdatedFields[attributeIndex].name();
2226 if ( index < 0 || index >=
fields().count() )
2235 if ( !mEditBuffer || !mDataProvider )
2243 bool deleted =
false;
2246 attrs = attrs.
toSet().toList();
2248 qSort( attrs.
begin(), attrs.
end(), qGreater<int>() );
2250 Q_FOREACH (
int attr, attrs )
2269 mSelectedFeatureIds.
remove( fid );
2285 mSelectedFeatureIds.
subtract( fids );
2297 for (
int i = 0; i < mUpdatedFields.
count(); ++i )
2301 pkAttributesList << i;
2304 return pkAttributesList;
2315 mCommitErrors.
clear();
2317 if ( !mDataProvider )
2319 mCommitErrors <<
tr(
"ERROR: no provider" );
2325 mCommitErrors <<
tr(
"ERROR: layer not editable" );
2336 mEditBuffer =
nullptr;
2362 return mCommitErrors;
2392 mEditBuffer =
nullptr;
2402 if ( rollbackExtent )
2413 QgsFeatureIds deselectedFeatures = mSelectedFeatureIds - ids;
2415 mSelectedFeatureIds = ids;
2422 return mSelectedFeatureIds.
size();
2427 return mSelectedFeatureIds;
2435 if ( mSelectedFeatureIds.
count() <= 8 )
2460 if ( mSelectedFeatureIds.
isEmpty() )
2466 if ( mSelectedFeatureIds.
count() == 1 )
2476 if ( !mEditBuffer || !mDataProvider )
2510 if ( snapResults.
size() < 1 )
2516 point.
setX( snap_it.
value().snappedVertex.x() );
2517 point.
setY( snap_it.
value().snappedVertex.y() );
2529 if ( snappingTolerance <= 0 || !mDataProvider )
2534 QgsRectangle searchRect( startPoint.
x() - snappingTolerance, startPoint.
y() - snappingTolerance,
2535 startPoint.
x() + snappingTolerance, startPoint.
y() + snappingTolerance );
2536 double sqrSnappingTolerance = snappingTolerance * snappingTolerance;
2544 for ( QgsGeometryMap::iterator it = cachedGeometries.
begin(); it != cachedGeometries.
end() ; ++it )
2549 snapToGeometry( startPoint, it.key(), g, sqrSnappingTolerance, snappingResults, snap_to );
2559 .setFilterRect( searchRect )
2565 snapToGeometry( startPoint, f.
id(), f.
constGeometry(), sqrSnappingTolerance, snappingResults, snap_to );
2570 return n == 0 ? 2 : 0;
2573 void QgsVectorLayer::snapToGeometry(
const QgsPoint& startPoint,
2576 double sqrSnappingTolerance,
2585 int atVertex, beforeVertex, afterVertex;
2586 double sqrDistVertexSnap, sqrDistSegmentSnap;
2593 snappedPoint = geom->
closestVertex( startPoint, atVertex, beforeVertex, afterVertex, sqrDistVertexSnap );
2594 if ( sqrDistVertexSnap < sqrSnappingTolerance )
2599 if ( beforeVertex != -1 )
2604 if ( afterVertex != -1 )
2609 snappingResultVertex.
layer =
this;
2610 snappingResults.
insert( sqrt( sqrDistVertexSnap ), snappingResultVertex );
2618 sqrDistSegmentSnap = geom->
closestSegmentWithContext( startPoint, snappedPoint, afterVertex,
nullptr,
crs().geographicFlag() ? 1e-12 : 1e-8 );
2620 if ( sqrDistSegmentSnap < sqrSnappingTolerance )
2629 snappingResultSegment.
layer =
this;
2630 snappingResults.
insert( sqrt( sqrDistSegmentSnap ), snappingResultSegment );
2645 QgsDebugMsg(
"----- Computing Coordinate System" );
2666 return mDisplayField;
2676 return mDisplayExpression;
2681 return ( mEditBuffer && mDataProvider );
2692 if ( readonly && mEditBuffer )
2695 mReadOnly = readonly;
2702 return mEditBuffer && mEditBuffer->
isModified();
2707 if ( idx < 0 || idx >= mUpdatedFields.
count() )
2717 if ( idx < 0 || idx >= mUpdatedFields.
count() )
2732 mAnnotationForm = ui;
2765 return QSize( cfg.value(
"Width" ).toInt(), cfg.value(
"Height" ).toInt() );
2774 if ( r != mRendererV2 )
2778 mSymbolFeatureCounted =
false;
2779 mSymbolFeatureCountMap.
clear();
2787 if ( !mDataProvider )
2794 mEditCommandActive =
true;
2801 if ( !mDataProvider )
2808 mEditCommandActive =
false;
2809 if ( !mDeletedFids.
isEmpty() )
2812 mDeletedFids.
clear();
2820 if ( !mDataProvider )
2828 mEditCommandActive =
false;
2829 mDeletedFids.
clear();
2839 cfg[
"CheckedState"] = checked;
2840 cfg[
"UncheckedState"] = unchecked;
2852 return mJoinBuffer && mJoinBuffer->
addJoin( joinInfo );
2865 res = mJoinBuffer->
removeJoin( joinLayerId );
2900 return mExpressionFieldBuffer->
expressions().value( oi ).expression;
2911 if ( !mDataProvider )
2916 mUpdatedFields = mDataProvider->
fields();
2926 if ( mExpressionFieldBuffer )
2927 mExpressionFieldBuffer->
updateFields( mUpdatedFields );
2929 if ( oldFields != mUpdatedFields )
2932 mEditFormConfig->setFields( mUpdatedFields );
2947 uniqueValues.
clear();
2948 if ( !mDataProvider )
2961 mDataProvider->
uniqueValues( index, uniqueValues, limit );
2966 Q_FOREACH (
const QVariant& v, uniqueValues )
2973 while ( addedIt.
hasNext() && ( limit < 0 || uniqueValues.
count() < limit ) )
2989 while ( it.hasNext() && ( limit < 0 || uniqueValues.
count() < limit ) )
3015 mDataProvider->
uniqueValues( index, uniqueValues, limit );
3028 .setSubsetOfAttributes( attList ) );
3037 if ( limit >= 0 && val.
size() >= limit )
3043 uniqueValues = val.
values();
3048 Q_ASSERT_X(
false,
"QgsVectorLayer::uniqueValues()",
"Unknown source of the field!" );
3053 if ( !mDataProvider )
3083 while ( it.hasNext() )
3118 .setSubsetOfAttributes( attList ) );
3122 double currentValue = 0;
3126 if ( currentValue < minimumValue )
3128 minimumValue = currentValue;
3135 Q_ASSERT_X(
false,
"QgsVectorLayer::minimumValue()",
"Unknown source of the field!" );
3141 if ( !mDataProvider )
3170 while ( it.hasNext() )
3203 .setSubsetOfAttributes( attList ) );
3207 double currentValue = 0;
3211 if ( currentValue > maximumValue )
3213 maximumValue = currentValue;
3220 Q_ASSERT_X(
false,
"QgsVectorLayer::maximumValue()",
"Unknown source of the field!" );
3233 if ( attrNum == -1 )
3241 if ( expression->hasParserError() || !expression->prepare( &context ) )
3250 if ( expression.
isNull() )
3251 lst.
append( fieldOrExpression );
3253 lst = expression->referencedColumns();
3256 .
setFlags(( expression && expression->needsGeometry() ) ?
3262 if ( !selectedOnly )
3277 QVariant v = expression->evaluate( &context );
3301 Q_FOREACH (
const QVariant& value, variantValues )
3303 double val = value.
toDouble( &convertOk );
3306 else if ( value.
isNull() )
3327 return mFeatureBlendMode;
3340 return mLayerTransparency;
3345 void QgsVectorLayer::readSldLabeling(
const QDomNode& node )
3352 if ( userStyleElem.
isNull() )
3354 QgsDebugMsg(
"Info: UserStyle element not found." );
3359 if ( featureTypeStyleElem.
isNull() )
3361 QgsDebugMsg(
"Info: FeatureTypeStyle element not found." );
3375 if ( textSymbolizerElem.
isNull() )
3377 QgsDebugMsg(
"Info: TextSymbolizer element not found." );
3384 if ( !labelElem.
isNull() )
3387 if ( !propertyNameElem.
isNull() )
3423 if ( fieldIndex == -1 )
3439 QgsDebugMsg(
"Info: PropertyName element not found." );
3451 if ( !fontElem.
isNull() )
3456 while ( !cssElem.
isNull() )
3458 cssName = cssElem.
attribute(
"name",
"not_found" );
3459 if ( cssName !=
"not_found" )
3461 elemText = cssElem.
text();
3462 if ( cssName ==
"font-family" )
3466 else if ( cssName ==
"font-style" )
3468 setCustomProperty(
"labeling/fontItalic", ( elemText ==
"italic" ) || ( elemText ==
"Italic" ) );
3470 else if ( cssName ==
"font-size" )
3473 int fontSize = elemText.
toInt( &ok );
3479 else if ( cssName ==
"font-weight" )
3481 setCustomProperty(
"labeling/fontBold", ( elemText ==
"bold" ) || ( elemText ==
"Bold" ) );
3483 else if ( cssName ==
"font-underline" )
3485 setCustomProperty(
"labeling/fontUnderline", ( elemText ==
"underline" ) || ( elemText ==
"Underline" ) );
3505 if ( !haloElem.
isNull() )
3511 if ( !radiusElem.
isNull() )
3533 if ( !labelPlacementElem.
isNull() )
3537 if ( !pointPlacementElem.
isNull() )
3542 if ( !displacementElem.
isNull() )
3545 if ( !displacementXElem.
isNull() )
3548 double xOffset = displacementXElem.
text().
toDouble( &ok );
3555 if ( !displacementYElem.
isNull() )
3558 double yOffset = displacementYElem.
text().
toDouble( &ok );
3567 if ( !rotationElem.
isNull() )
3582 if ( !mDiagramLayerSettings )
3584 *mDiagramLayerSettings = s;
3589 QString myMetadata =
"<html><body>";
3593 myMetadata +=
"<p class=\"subheaderglossy\">";
3594 myMetadata +=
tr(
"General" );
3595 myMetadata +=
"</p>\n";
3600 myMetadata +=
"<p class=\"glossy\">" +
tr(
"Layer comment" ) +
"</p>\n";
3601 myMetadata +=
"<p>";
3603 myMetadata +=
"</p>\n";
3607 myMetadata +=
"<p class=\"glossy\">" +
tr(
"Storage type of this layer" ) +
"</p>\n";
3608 myMetadata +=
"<p>";
3610 myMetadata +=
"</p>\n";
3615 myMetadata +=
"<p class=\"glossy\">" +
tr(
"Description of this provider" ) +
"</p>\n";
3616 myMetadata +=
"<p>";
3618 myMetadata +=
"</p>\n";
3622 myMetadata +=
"<p class=\"glossy\">" +
tr(
"Source for this layer" ) +
"</p>\n";
3623 myMetadata +=
"<p>";
3625 myMetadata +=
"</p>\n";
3639 myMetadata +=
"<p class=\"glossy\">" +
tr(
"Geometry type of the features in this layer" ) +
"</p>\n";
3640 myMetadata +=
"<p>";
3641 myMetadata += typeString;
3642 myMetadata +=
"</p>\n";
3648 myMetadata +=
"<p class=\"glossy\">" +
tr(
"Primary key attributes" ) +
"</p>\n";
3649 myMetadata +=
"<p>";
3650 Q_FOREACH (
int idx, pkAttrList )
3654 myMetadata +=
"</p>\n";
3659 myMetadata +=
"<p class=\"glossy\">" +
tr(
"The number of features in this layer" ) +
"</p>\n";
3660 myMetadata +=
"<p>";
3662 myMetadata +=
"</p>\n";
3664 myMetadata +=
"<p class=\"glossy\">" +
tr(
"Capabilities of this layer" ) +
"</p>\n";
3665 myMetadata +=
"<p>";
3667 myMetadata +=
"</p>\n";
3672 myMetadata +=
"<p class=\"subheaderglossy\">";
3673 myMetadata +=
tr(
"Extents" );
3674 myMetadata +=
"</p>\n";
3677 myMetadata +=
"<p class=\"glossy\">" +
tr(
"In layer spatial reference system units" ) +
"</p>\n";
3678 myMetadata +=
"<p>";
3691 QString xMin, yMin, xMax, yMax;
3692 double changeoverValue = 99999;
3693 if ( qAbs( myExtent.
xMinimum() ) > changeoverValue )
3701 if ( qAbs( myExtent.
yMinimum() ) > changeoverValue )
3709 if ( qAbs( myExtent.
xMaximum() ) > changeoverValue )
3717 if ( qAbs( myExtent.
yMaximum() ) > changeoverValue )
3726 myMetadata +=
tr(
"xMin,yMin %1,%2 : xMax,yMax %3,%4" )
3727 .
arg( xMin, yMin, xMax, yMax );
3731 myMetadata +=
tr(
"unknown extent" );
3734 myMetadata +=
"</p>\n";
3742 QgsRectangle myProjectedExtent = coordinateTransform->transformBoundingBox(
extent() );
3743 myMetadata +=
"<p class=\"glossy\">" +
tr(
"In project spatial reference system units" ) +
"</p>\n";
3744 myMetadata +=
"<p>";
3745 myMetadata +=
tr(
"xMin,yMin %1,%2 : xMax,yMax %3,%4" )
3747 .arg( myProjectedExtent.
yMinimum() )
3748 .arg( myProjectedExtent.
xMaximum() )
3749 .arg( myProjectedExtent.
yMaximum() );
3750 myMetadata +=
"</p>\n";
3756 myMetadata +=
"<p class=\"glossy\">" +
tr(
"Layer Spatial Reference System" ) +
"</p>\n";
3757 myMetadata +=
"<p>";
3759 myMetadata +=
"</p>\n";
3767 myMetadata +=
"<p class=\"glossy\">" +
tr(
"Project (Output) Spatial Reference System" ) +
"</p>\n";
3768 myMetadata +=
"<p>";
3769 myMetadata += coordinateTransform->destCRS().toProj4().
replace(
'"',
" \"" );
3770 myMetadata +=
"</p>\n";
3778 myMetadata +=
"<p class=\"glossy\">" +
tr(
"In project spatial reference system units" ) +
"</p>\n";
3779 myMetadata +=
"<p>";
3780 myMetadata +=
tr(
"(Invalid transformation of layer extents)" );
3781 myMetadata +=
"</p>\n";
3789 myMetadata +=
"<p class=\"glossy\">" +
tr(
"Attribute field info" ) +
"</p>\n";
3790 myMetadata +=
"<p>";
3793 myMetadata +=
"<table width=\"100%\">";
3794 myMetadata +=
"<tr><th>";
3795 myMetadata +=
tr(
"Field" );
3796 myMetadata +=
"</th>";
3797 myMetadata +=
"<th>";
3798 myMetadata +=
tr(
"Type" );
3799 myMetadata +=
"</th>";
3800 myMetadata +=
"<th>";
3801 myMetadata +=
tr(
"Length" );
3802 myMetadata +=
"</th>";
3803 myMetadata +=
"<th>";
3804 myMetadata +=
tr(
"Precision" );
3805 myMetadata +=
"</th>";
3806 myMetadata +=
"<th>";
3807 myMetadata +=
tr(
"Comment" );
3808 myMetadata +=
"</th>";
3812 for (
int i = 0, n = myFields.
size(); i < n; ++i )
3816 myMetadata +=
"<tr><td>";
3817 myMetadata += myField.
name();
3818 myMetadata +=
"</td>";
3819 myMetadata +=
"<td>";
3821 myMetadata +=
"</td>";
3822 myMetadata +=
"<td>";
3824 myMetadata +=
"</td>";
3825 myMetadata +=
"<td>";
3827 myMetadata +=
"</td>";
3828 myMetadata +=
"<td>";
3830 myMetadata +=
"</td></tr>";
3834 myMetadata +=
"</table>";
3837 myMetadata +=
"</body></html>";
3843 mSymbolFeatureCounted =
false;
3846 void QgsVectorLayer::onJoinedFieldsChanged()
3852 void QgsVectorLayer::onFeatureDeleted(
QgsFeatureId fid )
3854 if ( mEditCommandActive )
3855 mDeletedFids << fid;
3864 if ( mEditFormConfig->
widgetType( idx ) ==
"ValueRelation" )
3869 cfg.
value(
"Key" ).toString(),
3870 cfg.
value(
"Value" ).toString(),
3871 cfg.
value(
"AllowNull" ).toBool(),
3872 cfg.
value(
"OrderByValue" ).toBool(),
3873 cfg.
value(
"AllowMulti" ).toBool(),
3874 cfg.
value(
"FilterExpression" ).toString()
3902 mChildren.append( widget );
3921 if ( elem->
type() == AeTypeContainer )
3946 msgError =
QObject::tr(
"Unable to load %1 provider" ).
arg( mProviderKey );
3951 if ( !listStylesExternalMethod )
3954 msgError =
QObject::tr(
"Provider %1 has no %2 method" ).
arg( mProviderKey,
"listStyles" );
3958 return listStylesExternalMethod(
mDataSource, ids, names, descriptions, msgError );
3967 msgError =
QObject::tr(
"Unable to load %1 provider" ).
arg( mProviderKey );
3972 if ( !getStyleByIdMethod )
3975 msgError =
QObject::tr(
"Provider %1 has no %2 method" ).
arg( mProviderKey,
"getStyleById" );
3979 return getStyleByIdMethod(
mDataSource, styleId, msgError );
3984 bool useAsDefault,
const QString& uiFileContent,
QString &msgError )
3992 msgError =
QObject::tr(
"Unable to load %1 provider" ).
arg( mProviderKey );
3997 if ( !saveStyleExternalMethod )
4000 msgError =
QObject::tr(
"Provider %1 has no %2 method" ).
arg( mProviderKey,
"saveStyle" );
4006 if ( !msgError.
isNull() )
4013 if ( !msgError.
isNull() )
4019 saveStyleExternalMethod(
mDataSource, qmlStyle, sldStyle, name,
4020 description, uiFileContent, useAsDefault, msgError );
4040 if ( loadStyleExternalMethod )
4043 qml = loadStyleExternalMethod(
mDataSource, errorMsg );
4077 mRelation = relationManager->
relation( mRelationId );
4083 if ( mDataProvider )
Q_DECL_DEPRECATED bool deleteVertex(QgsFeatureId atFeatureId, int atVertex)
Deletes a vertex from a feature.
QObject * child(const char *objName, const char *inheritsClass, bool recursiveSearch) const
void setExtent(const QgsRectangle &rect) override
Set the extent.
bool labelsEnabled() const
Returns whether the layer contains labels which are enabled and should be drawn.
bool draw(QgsRenderContext &rendererContext) override
Draws the layer.
virtual QString subsetString()
Get the string (typically sql) used to define a subset of the layer.
void writeXml(QDomNode &layer_node, QDomDocument &document) const
Saves mVectorJoins to xml under the layer node.
virtual Q_DECL_DEPRECATED bool applyNamedStyle(const QString &namedStyle, QString &errorMsg)
Will load a named style from a provided QML string.
Class for parsing and evaluation of expressions (formerly called "search strings").
void updateFields()
Assembles mUpdatedFields considering provider fields, joined fields and added fields.
Q_DECL_DEPRECATED int removePolygonIntersections(QgsGeometry *geom, const QgsFeatureIds &ignoreFeatures=QgsFeatureIds())
Changes the specified geometry such that it has no intersections with other polygon (or multipolygon)...
QString encoding() const
Get encoding which is used for accessing data.
Wrapper for iterator of features from vector data provider or vector layer.
void featuresDeleted(const QgsFeatureIds &fids)
Emitted when features have been deleted.
void selectAll()
Select all the features.
QDomNodeList elementsByTagName(const QString &tagname) const
bool contains(const QgsRectangle &rect) const
return true when rectangle contains other rectangle
bool isValid() const
Returns the validity of this relation.
int indexOf(QChar ch, int from, Qt::CaseSensitivity cs) const
#define RENDERER_TAG_NAME
virtual QString subsetString()
Returns the subset definition string (typically sql) currently in use by the layer and used by the pr...
bool addJoin(const QgsVectorJoinInfo &joinInfo)
Joins another vector layer to this layer.
static QgsProviderRegistry * instance(const QString &pluginPath=QString::null)
Means of accessing canonical single instance.
virtual bool setSubsetString(const QString &subset, bool updateFeatureCount=true)
Set the subset string used to create a subset of features in the layer.
A rectangle specified with double values.
Base class for all map layer types.
double rendererScale() const
bool writeXml(QDomNode &node, QDomDocument &doc) const
Write field ui properties specific state from Dom node.
QGis::WkbType wkbType() const
Returns the WKBType or WKBUnknown in case of error.
QString comment() const
Returns the field comment.
bool init(QgsRelationManager *relManager)
Initializes the relation from the id.
void setDiagramLayerSettings(const QgsDiagramLayerSettings &s)
iterator insert(const Key &key, const T &value)
int insertSegmentVerticesForSnap(const QList< QgsSnappingResult > &snapResults)
Inserts vertices to the snapped segments.
bool containsJoins() const
Quick way to test if there is any join at all.
bool readSymbology(const QDomNode &node, QString &errorMessage) override
Read the symbology for the current layer from the Dom node supplied.
field comes from a joined layer (originIndex / 1000 = index of the join, originIndex % 1000 = index w...
QgsAttributes attributes() const
Returns the feature's attributes.
QgsFeatureList selectedFeatures()
Get a copy of the user-selected features.
virtual bool addAttribute(const QgsField &field)
Add an attribute field (but does not commit it) returns true if the field was added.
void setName(const QString &name)
Change the name of this container.
virtual bool writeXml(QDomNode &layer_node, QDomDocument &doc) override
Write vector layer specific state to project file Dom node.
int size() const
Return number of items.
This is an abstract base class for any elements of a drag and drop form.
FieldOrigin fieldOrigin(int fieldIdx) const
Get field's origin (value from an enumeration)
void setMinimal()
Set a rectangle so that min corner is at max and max corner is at min.
bool contains(const Key &key) const
void createJoinCaches()
Calls cacheJoinLayer() for all vector joins.
virtual void updateExtents()
Update the extents of the layer.
void readCustomProperties(const QDomNode &layerNode, const QString &keyStartsWith="")
Read custom properties from project file.
void addExpression(const QString &exp, const QgsField &fld)
Add an expression to the buffer.
QDomNode appendChild(const QDomNode &newChild)
void beforeRollBack()
Is emitted, before changes are rolled back.
virtual bool addFeatures(QgsFeatureList &features)
Insert a copy of the given features into the layer (but does not commit it)
void beginEditCommand(const QString &text)
Create edit command for undo/redo operations.
Use exact geometry intersection (slower) instead of bounding boxes.
static QgsFeatureRendererV2 * loadSld(const QDomNode &node, QGis::GeometryType geomType, QString &errorMessage)
Create a new renderer according to the information contained in the UserStyle element of a SLD style ...
void setMaximum(int maximum)
void push_back(const T &value)
int translateFeature(QgsFeatureId featureId, double dx, double dy)
Translates feature by dx, dy.
QVariant maximumValue(int index)
Returns the maximum value for an attribute column or an invalid variant in case of error...
QgsMapLayerLegend * legend() const
Can be null.
QString storageType() const
Returns the permanent storage type for this layer as a friendly name.
Renders the diagrams for all features with the same settings.
QString attribute(const QString &name, const QString &defValue) const
virtual bool addFeature(QgsFeature &f)
Adds a feature.
field has been temporarily added in editing mode (originIndex = index in the list of added attributes...
QString labelField(int attr) const
label field
int addTopologicalPoints(const QgsGeometry *geom)
Adds topological points for every vertex of the geometry.
void beginMacro(const QString &text)
void layerTransparencyChanged(int layerTransparency)
Signal emitted when setLayerTransparency() is called.
bool deleteFeature(QgsFeatureId fid)
Delete a feature from the layer (but does not commit it)
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the context.
virtual QgsCoordinateReferenceSystem crs()=0
Get the QgsCoordinateReferenceSystem for this layer.
QSet< QgsFeatureId > QgsFeatureIds
void uniqueValues(int index, QList< QVariant > &uniqueValues, int limit=-1)
Calculates a list of unique values contained within an attribute in the layer.
QString toString(int indent) const
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest())
Query the provider for features specified in request.
virtual QDomElement save(QDomDocument &doc)
store renderer info to XML element
friend class QgsVectorLayerFeatureSource
void setForceLocalOptimization(bool localOptimization)
Sets where the simplification executes, after fetch the geometries from provider, or when supported...
void invertSelectionInRectangle(QgsRectangle &rect)
Invert selection of features found within the search rectangle (in layer's coordinates) ...
QLibrary * providerLibrary(const QString &providerKey) const
bool commitChanges()
Attempts to commit any changes to disk.
void setRendererV2(QgsFeatureRendererV2 *r)
Set renderer which will be invoked to represent this layer.
void deleteCachedGeometries()
Deletes the geometries in mCachedGeometries.
Storage and management of actions associated with Qgis layer attributes.
virtual void setEncoding(const QString &e)
Set encoding used for accessing data from layer.
bool startEditing()
Make layer editable.
const_iterator constBegin() const
void setRendererScale(double scale)
const T & at(int i) const
void setCustomProperty(const QString &key, const QVariant &value)
Set a custom property for layer.
const QgsCoordinateReferenceSystem & crs() const
Returns layer's spatial reference system.
VertexMarkerType
Editing vertex markers.
void removeExpressionField(int index)
Remove an expression field.
void setFeatureBlendMode(QPainter::CompositionMode blendMode)
Set the blending mode used for rendering each feature.
const QgsChangedAttributesMap & changedAttributeValues()
Changed attributes values which are not commited.
void select(QgsRectangle &rect, bool addToSelection)
Select features found within the search rectangle (in layer's coordinates)
#define Q_NOWARN_DEPRECATED_PUSH
int makeDifference(const QgsGeometry *other)
Changes this geometry such that it does not intersect the other geometry.
virtual QList< QgsDiagramSettings > diagramSettings() const =0
Returns list with all diagram settings in the renderer.
static QgsMapRenderer::BlendMode getBlendModeEnum(QPainter::CompositionMode blendMode)
Returns a BlendMode corresponding to a QPainter::CompositionMode.
QgsFeatureRequest & setSubsetOfAttributes(const QgsAttributeList &attrs)
Set a subset of attributes that will be fetched.
QString toProj4() const
Returns a Proj4 string representation of this CRS.
bool writeXML(QDomNode &layer_node, QDomDocument &doc) const
Writes the actions out in XML format.
Q_DECL_DEPRECATED QString dateFormat(int idx)
Access date format.
virtual QList< QgsAttributeEditorElement * > findElements(AttributeEditorType type) const
Traverses the element tree to find any element of the specified type.
SimplifyHint
Simplification flags for fast rendering of features.
bool deleteAttributes(QList< int > attrs)
Deletes a list of attribute fields (but does not commit it)
void setLabeling(QgsAbstractVectorLayerLabeling *labeling)
Set labeling configuration.
void readCustomSymbology(const QDomElement &element, QString &errorMessage)
Signal emitted whenever the symbology (QML-file) for this layer is being read.
QString evalErrorString() const
Returns evaluation error.
QDomElement nextSiblingElement(const QString &tagName) const
bool deleteFeatures(const QgsFeatureIds &fids)
Deletes a set of features from the layer (but does not commit it)
int insertSegmentVerticesForSnap(const QList< QgsSnappingResult > &snapResults)
Inserts vertices to the snapped segments.
Q_DECL_DEPRECATED QMap< QString, QVariant > valueMap(int idx)
Access value map.
void readXml(const QDomNode &layer_node)
Reads joins from project file.
virtual void uniqueValues(int index, QList< QVariant > &uniqueValues, int limit=-1)
Return unique values of an attribute.
Container of fields for a vector layer.
virtual void rollBack()
Stop editing and discard the edits.
const QgsRectangle & cachedGeometriesRect()
A geometry is the spatial representation of a feature.
void setDiagramRenderer(QgsDiagramRendererV2 *r)
Sets diagram rendering object (takes ownership)
void setLayerTransparency(int layerTransparency)
Set the transparency for the vector layer.
QSet< T > & subtract(const QSet< T > &other)
ValueRelationData valueRelation(int idx)
Access value relation widget data.
void beforeRemovingExpressionField(int idx)
Will be emitted, when an expression field is going to be deleted from this vector layer...
static const char * vectorGeometryType(GeometryType type)
description strings for geometry types
QgsChangedAttributesMap mChangedAttributeValues
Changed attributes values which are not commited.
WkbType
Used for symbology operations.
static void mergeScaleDependencies(int mScaleMinDenom, int mScaleMaxDenom, QgsStringMap &props)
Merges the local scale limits, if any, with the ones already in the map, if any.
const QgsGeometry * constGeometry() const
Gets a const pointer to the geometry object associated with this feature.
int precision() const
Gets the precision of the field.
void remAttributeAlias(int attIndex)
Removes an alias (a display name) for attributes to display in dialogs.
QList< double > getDoubleValues(const QString &fieldOrExpression, bool &ok, bool selectedOnly=false, int *nullCount=nullptr)
Fetches all double values from a specified field name or expression.
The QGis class provides global constants for use throughout the application.
void setDisplayExpression(const QString &displayExpression)
Set the preview expression, used to create a human readable preview string.
bool addFeature(QgsFeature &f, bool alsoUpdateExtent=true)
Adds a feature.
virtual QList< QString > usedAttributes()=0
Returns a set of attributes required for this renderer.
field comes from the underlying data provider of the vector layer (originIndex = index in provider's ...
QString join(const QString &separator) const
Edit operation resulted in an empty geometry.
QString expressionField(int index)
Returns the expressoin used for a given expression field.
int addPart(const QList< QgsPoint > &ring, QgsFeatureId featureId)
Adds a new part polygon to a multipart feature.
const_iterator insert(const T &value)
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
QList< QgsRelation > referencingRelations(int idx)
Get relations, where the foreign key is on this layer.
QgsRelationManager * relationManager() const
void drawLine(const QLineF &line)
static const int EditingCapabilities
Bitmask of all provider's editing capabilities.
virtual ~QgsVectorLayer()
Destructor.
virtual QgsAttributeList pkAttributeIndexes()
Return list of indexes of fields that make up the primary key.
virtual QgsCurveV2 * clone() const override=0
Clones the geometry by performing a deep copy.
const QList< QgsVectorJoinInfo > vectorJoins() const
Q_DECL_DEPRECATED void setCheckedState(int idx, const QString &checked, const QString ¬Checked)
Set string representing 'true' for a checkbox.
const QString displayExpression()
Get the preview expression, used to create a human readable preview string.
void beforeCommitChanges()
Is emitted, before changes are commited to the data provider.
bool qgsVariantGreaterThan(const QVariant &lhs, const QVariant &rhs)
Compares two QVariant values and returns whether the first is greater than the second.
void committedFeaturesRemoved(const QString &layerId, const QgsFeatureIds &deletedFeatureIds)
double toDouble(bool *ok) const
void committedAttributesDeleted(const QString &layerId, const QgsAttributeList &deletedAttributes)
Signals emitted after committing changes.
void setBlendMode(QPainter::CompositionMode blendMode)
Set the blending mode used for rendering a layer.
virtual bool isEditable() const override
Returns true if the provider is in editing mode.
virtual QSet< QString > layerDependencies() const
Get the list of layer ids on which this layer depends.
QVariant minimumValue(int index)
Returns the minimum value for an attribute column or an invalid variant in case of error...
bool insertVertex(double x, double y, QgsFeatureId atFeatureId, int beforeVertex)
Insert a new vertex before the given vertex number, in the given ring, item (first number is index 0)...
void setSimplifyHints(const SimplifyHints &simplifyHints)
Sets the simplification hints of the vector layer managed.
QgsMapLayer::LayerType type() const
Get the type of the layer.
virtual Q_DECL_DEPRECATED bool willRenderFeature(QgsFeature &feat)
Returns whether the renderer will render a feature or not.
int count() const
Return number of items.
const QList< ExpressionField > & expressions() const
QString tr(const char *sourceText, const char *disambiguation, int n)
void featureDeleted(QgsFeatureId fid)
Emitted when a feature has been deleted.
QMap< QString, QString > QgsStringMap
long featureCount() const
Returns feature count including changes which have not yet been committed If you need only the count ...
void editCommandEnded()
Signal emitted, when an edit command successfully ended.
AttributeEditorType type() const
The type of this element.
QString mLayerName
Name of the layer - used for display.
bool isGeosEqual(const QgsGeometry &) const
Compares the geometry with another geometry using GEOS.
Q_DECL_DEPRECATED const QgsEditorWidgetConfig editorWidgetV2Config(int fieldIdx) const
Get the configuration for the editor widget used to represent the field at the given index...
QString name() const
Gets the name of the field.
void invertSelection()
Select not selected features and deselect selected ones.
bool qgsVariantLessThan(const QVariant &lhs, const QVariant &rhs)
Compares two QVariant values and returns whether the first is less than the second.
it has not been specified where the field comes from
int splitFeatures(const QList< QgsPoint > &splitLine, bool topologicalEditing=false)
Splits features cut by the given line.
const QgsField & at(int i) const
Get field at particular index (must be in range 0..N-1)
double y() const
Get the y value of the point.
virtual void startRender(QgsRenderContext &context, const QgsFields &fields)=0
Needs to be called when a new render cycle is started.
virtual void updateExtents()
Update the extents for the layer.
Returns diagram settings for a feature.
void writeCustomProperties(QDomNode &layerNode, QDomDocument &doc) const
Write custom properties to project file.
void removeSelection()
Clear selection.
Manages joined fields for a vector layer.
QgsFields fields() const
Returns the list of fields of this layer.
QgsConditionalLayerStyles * conditionalStyles() const
Return the conditional styles that are set for this layer.
void set(const QgsPoint &p1, const QgsPoint &p2)
Set the rectangle from two QgsPoints.
virtual void stopRender(QgsRenderContext &context)=0
Needs to be called when a render cycle has finished to clean up.
int fieldOriginIndex(int fieldIdx) const
Get field's origin index (its meaning is specific to each type of origin)
QgsGeometryMap & cachedGeometries()
static QString capitaliseLayerName(const QString &name)
A convenience function to (un)capitalise the layer name.
double ANALYSIS_EXPORT max(double x, double y)
Returns the maximum of two doubles or the first argument if both are equal.
QDomElement toElement() const
bool hasGeometryType() const
Returns true if this is a geometry layer and false in case of NoGeometry (table only) or UnknownGeome...
virtual QDomElement toDomElement(QDomDocument &doc) const override
Will serialize this containers information into a QDomElement for saving it in an XML file...
Q_DECL_DEPRECATED void setEditorWidgetV2(int attrIdx, const QString &widgetType)
Set the editor widget type for a field.
QString toString(bool automaticPrecision=false) const
returns string representation of form xmin,ymin xmax,ymax
virtual Q_DECL_DEPRECATED QgsSymbolV2List originalSymbolsForFeature(QgsFeature &feat)
Equivalent of originalSymbolsForFeature() call extended to support renderers that may use more symbol...
void setData(const QString &v)
int indexIn(const QString &str, int offset, CaretMode caretMode) const
virtual int listStylesInDatabase(QStringList &ids, QStringList &names, QStringList &descriptions, QString &msgError)
Lists all the style in db split into related to the layer and not related to.
SnappingType
Snap to vertex, to segment or both.
float maximumScale() const
Returns the maximum scale denominator at which the layer is visible.
virtual void writeXML(QDomElement &layerElem, QDomDocument &doc, const QgsVectorLayer *layer) const =0
virtual QVariant maximumValue(int index)
Returns the maximum value of an attribute.
virtual QgsMapLayerRenderer * createMapRenderer(QgsRenderContext &rendererContext) override
Return new instance of QgsMapLayerRenderer that will be used for rendering of given context...
QgsFeatureRequest & setFilterFid(QgsFeatureId fid)
Set feature ID that should be fetched.
void setValue(int progress)
void setDataSource(const QString &dataSource, const QString &baseName, const QString &provider, bool loadDefaultStyleFlag=false)
Update the data source of the layer.
QgsFeatureRendererV2 * rendererV2()
Return renderer V2.
virtual QDomElement toDomElement(QDomDocument &doc) const override
Will serialize this elements information into a QDomElement for saving it in an XML file...
void geometryChanged(QgsFeatureId fid, QgsGeometry &geom)
QString number(int n, int base)
float maximumScale() const
Gets the maximum scale at which the layer should be simplified.
int count(const T &value) const
void combineExtentWith(QgsRectangle *rect)
expand the rectangle so that covers both the original rectangle and the given rectangle ...
bool addJoin(const QgsVectorJoinInfo &joinInfo)
Joins another vector layer to this layer.
void append(const T &value)
QList< QgsRelation > referencingRelations(QgsVectorLayer *layer=nullptr, int fieldIdx=-2) const
Get all relations where the specified layer (and field) is the referencing part (i.e.
static QgsExpressionContextScope * globalScope()
Creates a new scope which contains variables and functions relating to the global QGIS context...
void deselect(const QgsFeatureId featureId)
Deselect feature by its ID.
void layerDeleted()
TODO QGIS3: remove in favor of QObject::destroyed.
QgsRectangle extent() override
Return the extent of the layer.
void readStyleManager(const QDomNode &layerNode)
Read style manager's configuration (if any).
bool rollBack(bool deleteBuffer=true)
Stop editing and discard the edits.
int toInt(bool *ok) const
virtual bool isClosed() const
Returns true if the curve is closed.
bool writeSld(QDomNode &node, QDomDocument &doc, QString &errorMessage) const
Writes the symbology of the layer into the document provided in SLD 1.1 format.
QgsDataProvider * provider(const QString &providerKey, const QString &dataSource)
Create an instance of the provider.
bool hasAttribute(const QString &name) const
bool isEmpty() const
test if rectangle is empty.
QString typeName() const
Gets the field type.
const QgsRectangle & extent() const
The attribute value should not be shown in the attribute form.
virtual QgsLegendSymbolList legendSymbolItems(double scaleDenominator=-1, const QString &rule="")
return a list of item text / symbol
void featureBlendModeChanged(QPainter::CompositionMode blendMode)
Signal emitted when setFeatureBlendMode() is called.
Represents the result of a snapping operation.
QString database() const
Returns the database.
void readXML(const QDomElement &elem, const QgsVectorLayer *layer)
void setCrs(const QgsCoordinateReferenceSystem &srs, bool emitSignal=true)
Sets layer's spatial reference system.
void setPen(const QColor &color)
void beforeModifiedCheck() const
Is emitted, when layer is checked for modifications.
QStringList capturedTexts() const
void drawEllipse(const QRectF &rectangle)
QString dataComment() const
Returns a comment for the data in the layer.
void setAttribute(const QString &name, const QString &value)
int addTopologicalPoints(const QgsGeometry *geom)
Adds topological points for every vertex of the geometry.
Q_DECL_DEPRECATED EditType editType(int idx)
Get edit type.
virtual bool isReadOnly() const
Returns true if the provider is in read-only mode.
int snapWithContext(const QgsPoint &startPoint, double snappingTolerance, QMultiMap< double, QgsSnappingResult > &snappingResults, QgsSnapper::SnappingType snap_to)
Snaps to segment or vertex within given tolerance.
double width() const
Width of the rectangle.
Point geometry type, with support for z-dimension and m-values.
int toInt(bool *ok, int base) const
virtual void setExtent(const QgsRectangle &rect)
Set the extent.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
void setScaleBasedVisibility(bool theVisibilityFlag)
Accessor and mutator for the scale based visilibility flag.
void committedFeaturesAdded(const QString &layerId, const QgsFeatureList &addedFeatures)
int addPart(const QList< QgsPoint > &ring)
Adds a new part polygon to a multipart feature.
virtual QString dataSourceUri(bool expandAuthConfig=false) const
Get the data source specification.
const_iterator constEnd() const
bool deleteAttribute(int attr)
Delete an attribute field (but does not commit it)
void editingStopped()
Is emitted, when edited changes successfully have been written to the data provider.
void beforeEditingStarted()
Is emitted, before editing on this layer is started.
QgsGeometryMap mChangedGeometries
Changed geometries which are not commited.
int translateFeature(QgsFeatureId featureId, double dx, double dy)
Translates feature by dx, dy.
bool moveVertex(double x, double y, QgsFeatureId atFeatureId, int atVertex)
Moves the vertex at the given position number, ring and item (first number is index 0)...
Arranges candidates in a circle around a point (or centroid of a polygon).
void triggerRepaint()
Will advice the map canvas (and any other interested party) that this layer requires to be repainted...
virtual long featureCount() const =0
Number of features in the layer.
static void logMessage(const QString &message, const QString &tag=QString::null, MessageLevel level=WARNING)
add a message to the instance (and create it if necessary)
virtual QSet< QString > layerDependencies() const
Get the list of layer ids on which this layer depends.
const QString displayField() const
Returns the primary display field name used in the identify results dialog.
virtual bool isModified() const
Returns true if the provider has been modified since the last commit.
This class wraps a request for features to a vector layer (or directly its vector data provider)...
void writeXml(QDomNode &layer_node, QDomDocument &document) const
Saves expressions to xml under the layer node.
QList< int > QgsAttributeList
float threshold() const
Gets the simplification threshold of the vector layer managed.
bool removeJoin(const QString &joinLayerId)
Removes a vector layer join.
void destroyEditCommand()
Destroy active command and reverts all changes in it.
bool isEmpty() const
Returns true if the geometry is empty (ie, contains no underlying geometry accessible via geometry)...
void setBrush(const QBrush &brush)
void setDisplayField(const QString &fldName="")
Set the primary display field to be used in the identify results dialog.
QString publicSource() const
Gets a version of the internal layer definition that has sensitive bits removed (for example...
const QString GEO_EPSG_CRS_AUTHID
Geographic coord sys from EPSG authority.
QMap< Key, T >::iterator insert(const Key &key, const T &value)
virtual bool deleteFeatures(const QgsFeatureIds &fid)
Deletes a set of features from the layer (but does not commit it)
const_iterator constEnd() const
int layerTransparency() const
Returns the current transparency for the vector layer.
bool setReadOnly(bool readonly=true)
Make layer read-only (editing disabled) or not.
bool changeGeometry(QgsFeatureId fid, QgsGeometry *geom)
Change feature's geometry.
QgsFeatureRequest & setFlags(const QgsFeatureRequest::Flags &flags)
Set flags that affect how features will be fetched.
QGis::GeometryType geometryType() const
Returns point, line or polygon.
QgsFeatureIds mDeletedFeatureIds
Deleted feature IDs which are not commited.
int afterVertexNr
The index of the vertex after snappedVertex or -1 if no such vertex.
const QgsVectorJoinList & vectorJoins() const
Encapsulate a field in an attribute table or data source.
virtual bool importNamedStyle(QDomDocument &doc, QString &errorMsg)
Import the properties of this layer from a QDomDocument.
void featureAdded(QgsFeatureId fid)
Emitted when a new feature has been added to the layer.
static QgsFeatureRendererV2 * defaultRenderer(QGis::GeometryType geomType)
return a new renderer - used by default in vector layers
const QgsAbstractVectorLayerLabeling * labeling() const
Access to labeling configuration.
void rendererChanged()
Signal emitted when renderer is changed.
void updateFields(QgsFields &flds)
Adds fields with the expressions buffered in this object to a QgsFields object.
virtual QGis::WkbType geometryType() const =0
Get feature type.
QGis::GeometryType type() const
Returns type of the geometry as a QGis::GeometryType.
Fast access to features using their ID.
virtual int capabilities() const
Returns a bitmask containing the supported capabilities Note, some capabilities may change depending ...
void readXML(const QDomNode &node)
Reads the renderer configuration from an XML file.
QgsFeatureId snappedAtGeometry
Index of the snapped geometry.
bool mValid
Indicates if the layer is valid and can be drawn.
bool scaleBasedVisibility() const
QList< QVariant > getValues(const QString &fieldOrExpression, bool &ok, bool selectedOnly=false)
Fetches all values from a specified field name or expression.
static QPainter::CompositionMode getCompositionMode(BlendMode blendMode)
Returns a QPainter::CompositionMode corresponding to a BlendMode.
void raiseError(const QString &msg)
Signals an error related to this vector layer.
void editingStarted()
Is emitted, when editing on this layer has started.
QgsAttributeList pkAttributeList() const
Returns list of attributes making up the primary key.
QString capabilitiesString() const
Capabilities for this layer in a friendly format.
static void drawVertexMarker(double x, double y, QPainter &p, QgsVectorLayer::VertexMarkerType type, int vertexSize)
Draws a vertex symbol at (screen) coordinates x, y.
bool addFeatures(QgsFeatureList features, bool makeSelected=true)
Insert a copy of the given features into the layer (but does not commit it)
A class to represent a point.
Q_DECL_DEPRECATED bool changeAttributeValue(QgsFeatureId fid, int field, const QVariant &value, bool emitSignal)
Changes an attribute value (but does not commit it)
void addAttributeAlias(int attIndex, const QString &aliasString)
Sets an alias (a display name) for attributes to display in dialogs.
Q_DECL_DEPRECATED void setEditorWidgetV2Config(int attrIdx, const QgsEditorWidgetConfig &config)
Set the editor widget config for a field.
void endEditCommand()
Finish edit command and add it to undo/redo stack.
virtual bool commitChanges(QStringList &commitErrors)
Attempts to commit any changes to disk.
QPainter::CompositionMode featureBlendMode() const
Returns the current blending mode for features.
void committedAttributeValuesChanges(const QString &layerId, const QgsChangedAttributesMap &changedAttributesValues)
QString right(int n) const
virtual bool deleteAttribute(int attr)
Delete an attribute field (but does not commit it)
const QStringList & commitErrors()
QDomText createTextNode(const QString &value)
void invalidateSymbolCountedFlag()
QgsFeatureId id() const
Get the feature ID for this feature.
QByteArray toLocal8Bit() const
static GeometryType geometryType(Type type)
Returns the geometry type for a WKB type, eg both MultiPolygon and CurvePolygon would have a PolygonG...
QgsPoint beforeVertex
The layer coordinates of the vertex before snappedVertex.
Class for storing the component parts of a PostgreSQL/RDBMS datasource URI.
QgsPoint afterVertex
The layer coordinates of the vertex after snappedVertex.
QDomNode namedItem(const QString &name) const
int fieldNameIndex(const QString &fieldName) const
Look up field's index from name also looks up case-insensitive if there is no match otherwise...
bool contains(QChar ch, Qt::CaseSensitivity cs) const
void editCommandDestroyed()
Signal emitted, whan an edit command is destroyed.
void setX(double x)
Sets the x value of the point.
int addExpressionField(const QString &exp, const QgsField &fld)
Add a new field which is calculated by the expression specified.
void setMaximumScale(float maximumScale)
Sets the maximum scale at which the layer should be simplified.
void setY(double y)
Sets the y value of the point.
double yMinimum() const
Get the y minimum value (bottom side of rectangle)
virtual void reload() override
Synchronises with changes in the datasource.
virtual QgsTransaction * transaction() const
Returns the transaction this data provider is included in, if any.
bool contains(const T &value) const
bool countSymbolFeatures(bool showProgress=true)
Count features for symbols.
A class to render labels.
static QgsMapLayerLegend * defaultVectorLegend(QgsVectorLayer *vl)
Create new legend implementation for vector layer.
A registry / canonical manager of data providers.
void setProviderEncoding(const QString &encoding)
Sets the textencoding of the data provider.
QgsExpressionContext & expressionContext()
Gets the expression context.
virtual QString loadNamedStyle(const QString &theURI, bool &theResultFlag, bool loadFromLocalDb)
Load a named style from file/local db/datasource db.
QgsGeometry * geometry()
Get the geometry object associated with this feature.
Implementation of threaded rendering for vector layers.
void writeStyleManager(QDomNode &layerNode, QDomDocument &doc) const
Write style manager's configuration (if exists).
const_iterator constBegin() const
double xMaximum() const
Get the x maximum value (right side of rectangle)
bool contains(const T &value) const
QgsFeatureIterator selectedFeaturesIterator(QgsFeatureRequest request=QgsFeatureRequest())
Get an iterator of the selected features.
QString capabilitiesString() const
Returns the above in friendly format.
const QgsFeatureIds & selectedFeaturesIds() const
Return reference to identifiers of selected features.
const QgsFeatureMap & addedFeatures()
New features which are not commited.
bool useRenderingOptimization() const
Returns true if the rendering optimization (geometry simplification) can be executed.
int snappedVertexNr
The vertex index of snappedVertex or -1 if no such vertex number (e.g.
#define Q_NOWARN_DEPRECATED_POP
const Key key(const T &value) const
bool snapPoint(QgsPoint &point, double tolerance)
Snaps a point to the closest vertex if there is one within the snapping tolerance.
bool removeJoin(const QString &joinLayerId)
Removes a vector layer join.
Q_DECL_DEPRECATED void setEditType(int idx, EditType edit)
Set edit type.
EditResult deleteVertexV2(QgsFeatureId featureId, int vertex)
Deletes a vertex from a feature.
virtual void exportNamedStyle(QDomDocument &doc, QString &errorMsg)
Export the properties of this layer as named style in a QDomDocument.
bool updateFeature(QgsFeature &f)
Updates an existing feature.
void selectionChanged()
This signal is emitted when selection was changed.
bool insertVertex(double x, double y, QgsFeatureId atFeatureId, int beforeVertex)
Insert a new vertex before the given vertex number, in the given ring, item (first number is index 0)...
virtual bool render() override
Do the rendering (based on data stored in the class)
QString & replace(int position, int n, QChar after)
void renderLabel(QgsRenderContext &renderContext, QgsFeature &feature, bool selected, QgsLabelAttributes *classAttributes=nullptr)
render label
double closestSegmentWithContext(const QgsPoint &point, QgsPoint &minDistPoint, int &afterVertex, double *leftOf=nullptr, double epsilon=DEFAULT_SEGMENT_EPSILON) const
Searches for the closest segment of geometry to the given point.
const T & at(int i) const
QVariant value(const QString &key, const QVariant &defaultValue) const
void attributeAdded(int idx)
Will be emitted, when a new attribute has been added to this vector layer.
Q_DECL_DEPRECATED QSize widgetSize(int idx)
Access widget size for photo and webview widget.
void beforeAddingExpressionField(const QString &fieldName)
Will be emitted, when an expression field is going to be added to this vector layer.
int addRing(const QList< QgsPoint > &ring, const QgsFeatureIds &targetFeatureIds=QgsFeatureIds(), QgsFeatureId *modifiedFeatureId=nullptr)
Adds a ring to polygon/multipolygon features.
Contains information about the context of a rendering operation.
int indexFromName(const QString &name) const
Look up field's index from name. Returns -1 on error.
QgsPoint vertexAt(int atVertex) const
Returns coordinates of a vertex.
void setMaxScale(float theMaxScale)
Accessor and mutator for the maximum scale member.
QString name() const
Get the display name of the layer.
Buffers information about expression fields for a vector layer.
QString getStyleById_t(const QString &uri, QString styleID, QString &errCause)
virtual QDomElement toDomElement(QDomDocument &doc) const =0
Is reimplemented in classes inheriting from this to serialize it.
virtual const QgsFields & fields() const =0
Return a map of indexes with field names for this layer.
void editCommandStarted(const QString &text)
Signal emitted when a new edit command has been started.
QString loadStyle_t(const QString &uri, QString &errCause)
static QgsMapLayerRegistry * instance()
Returns the instance pointer, creating the object on the first call.
QgsVectorLayer(const QString &path=QString::null, const QString &baseName=QString::null, const QString &providerLib=QString::null, bool loadDefaultStyleFlag=true)
Constructor - creates a vector layer.
bool simplifyDrawingCanbeApplied(const QgsRenderContext &renderContext, QgsVectorSimplifyMethod::SimplifyHint simplifyHint) const
Returns whether the VectorLayer can apply the specified simplification hint.
QgsFeatureRequest & setFilterFids(const QgsFeatureIds &fids)
Set feature IDs that should be fetched.
virtual QgsRectangle extent()=0
Get the extent of the layer.
bool remove(const T &value)
void setAnnotationForm(const QString &ui)
Set annotation form for layer.
QSet< T > & unite(const QSet< T > &other)
QString mDataSource
Data source description string, varies by layer type.
virtual QString loadDefaultStyle(bool &theResultFlag)
Retrieve the default style for this layer if one exists (either as a .qml file on disk or as a record...
void * resolve(const char *symbol)
static Q_DECL_DEPRECATED const QString convertEditType(QgsVectorLayer::EditType editType, QgsEditorWidgetConfig &cfg, QgsVectorLayer *vl, const QString &name, const QDomElement &editTypeElement=QDomElement())
bool hasScaleBasedVisibility() const
Returns whether scale based visibility is enabled for the layer.
QgsVectorLayer::EditResult deleteVertexV2(QgsFeatureId featureId, int vertex)
Deletes a vertex from a feature.
void setSelectedFeatures(const QgsFeatureIds &ids)
Change selection to the new set of features.
void updateExpression(int index, const QString &exp)
Changes the expression at a given index.
This class manages a set of relations between layers.
static QgsFeatureRendererV2 * load(QDomElement &symbologyElem)
create a renderer from XML element
virtual Q_DECL_DEPRECATED QDomElement writeSld(QDomDocument &doc, const QgsVectorLayer &layer) const
create the SLD UserStyle element following the SLD v1.1 specs
virtual void reloadData()
Reloads the data from the source.
virtual QDomElement save(QDomDocument &doc) const =0
Return labeling configuration as XML element.
virtual QVariant minimumValue(int index)
Returns the minimum value of an attribute.
bool deleteSelectedFeatures(int *deletedCount=nullptr)
Deletes the selected features.
Q_DECL_DEPRECATED RangeData range(int idx)
Access range widget config data.
Edit operation was successful.
virtual bool isValid()=0
Returns true if this is a valid layer.
static QgsAbstractVectorLayerLabeling * create(const QDomElement &element)
Try to create instance of an implementation based on the XML data.
bool forceLocalOptimization() const
Gets where the simplification executes, after fetch the geometries from provider, or when supported...
bool readXml(const QDomNode &node)
Reads field ui properties specific state from Dom node.
The QgsConditionalLayerStyles class holds conditional style information for a layer.
bool moveVertex(double x, double y, QgsFeatureId atFeatureId, int atVertex)
Moves the vertex at the given position number, ring and item (first number is index 0)...
void updateFields(QgsFields &fields)
Updates field map with joined attributes.
void repaintRequested()
By emitting this signal the layer tells that either appearance or content have been changed and any v...
void committedAttributesAdded(const QString &layerId, const QList< QgsField > &addedAttributes)
void readXml(const QDomNode &layer_node)
Reads expressions from project file.
void attributeValueChanged(QgsFeatureId fid, int idx, const QVariant &)
static QgsProject * instance()
access to canonical QgsProject instance
QDomElement firstChildElement(const QString &tagName) const
QgsPoint snappedVertex
The coordinates of the snapping result.
QDomElement lastChildElement(const QString &tagName) const
QgsRectangle boundingBox() const
Returns the bounding box of this feature.
void removeExpression(int index)
Remove an expression from the buffer.
virtual QString dataComment() const
Return a short comment for the data that this provider is providing access to (e.g.
Class for storing a coordinate reference system (CRS)
friend class QgsVectorLayerEditBuffer
virtual bool isModified() const
Returns true if the provider has been modified since the last commit.
int count(const T &value) const
Abstract base class - its implementations define different approaches to the labeling of a vector lay...
QgsLabel * label()
Get the label rendering properties associated with this layer.
SimplifyHints simplifyHints() const
Gets the simplification hints of the vector layer managed.
virtual QString description() const =0
Return description.
int length() const
Gets the length of the field.
QList< T > values() const
QList< T > mid(int pos, int length) const
virtual void readXML(const QDomElement &elem, const QgsVectorLayer *layer)=0
This is a container for attribute editors, used to group them visually in the attribute form if it is...
const QMap< QString, QgsMapLayer * > & mapLayers()
Retrieve the mapLayers collection (mainly intended for use by projection)
void recalculateExtents()
This is used to send a request that any mapcanvas using this layer update its extents.
virtual QDomElement toDomElement(QDomDocument &doc) const override
Will serialize this elements information into a QDomElement for saving it in an XML file...
void writeCustomSymbology(QDomElement &element, QDomDocument &doc, QString &errorMessage) const
Signal emitted whenever the symbology (QML-file) for this layer is being written. ...
virtual bool setSubsetString(const QString &subset)
Set the string (typically sql) used to define a subset of the layer.
double xMinimum() const
Get the x minimum value (left side of rectangle)
virtual QString getStyleFromDatabase(const QString &styleId, QString &msgError)
Will return the named style corresponding to style id provided.
virtual bool deleteFeature(QgsFeatureId fid)
Delete a feature from the layer (but does not commit it)
virtual bool enterUpdateMode()
Enter update mode.
bool readSld(const QDomNode &node, QString &errorMessage) override
Read the symbology of the layer according to the information contained in the UserStyle element of a ...
Basic implementation of the labeling interface.
QString readPath(QString filename) const
Turn filename read from the project file to an absolute path.
QgsFields pendingFields() const
Returns the list of fields of this layer.
void dataChanged()
Data of layer changed.
static QColor colorFromOgcFill(const QDomElement &fillElement)
Parse XML with OGC fill into QColor.
virtual bool changeAttributeValue(QgsFeatureId fid, int field, const QVariant &newValue, const QVariant &oldValue=QVariant())
Changed an attribute value (but does not commit it)
Base class for utility classes that encapsulate information necessary for rendering of map layers...
void setLayerName(const QString &name)
Set the display name of the layer.
Allows deletion of features.
double yMaximum() const
Get the y maximum value (top side of rectangle)
virtual QString loadNamedStyle(const QString &theURI, bool &theResultFlag)
Retrieve a named style for this layer if one exists (either as a .qml file on disk or as a record in ...
double toDouble(bool *ok) const
bool writeSymbology(QDomNode &node, QDomDocument &doc, QString &errorMessage) const override
Write the symbology for the layer into the docment provided.
virtual void addChildElement(QgsAttributeEditorElement *element)
Add a child element to this container.
iterator insert(const Key &key, const T &value)
void checkJoinLayerRemove(const QString &theLayerId)
Check if there is a join with a layer that will be removed.
void(*)() cast_to_fptr(void *p)
virtual QString type() const =0
Unique type string of the labeling configuration implementation.
void addRequiredFields(QgsAttributeList &fields) const
add vector of required fields to existing list of fields
Q_DECL_DEPRECATED const QString editorWidgetV2(int fieldIdx) const
Get the id for the editor widget used to represent the field at the given index.
Edit failed due to invalid layer.
void setMinScale(float theMinScale)
Accessor and mutator for the minimum scale member.
float minimumScale() const
Returns the minimum scale denominator at which the layer is visible.
Custom exception class for Coordinate Reference System related exceptions.
QVariant customProperty(const QString &value, const QVariant &defaultValue=QVariant()) const
Read a custom property from layer.
QUndoStack * undoStack()
Return pointer to layer's undo stack.
virtual QString storageType() const
Returns the permanent storage type for this layer as a friendly name.
QString metadata() override
Obtain Metadata for this layer.
static QgsExpressionContextScope * projectScope()
Creates a new scope which contains variables and functions relating to the current QGIS project...
QgsVectorDataProvider * dataProvider()
Returns the data provider.
double ANALYSIS_EXPORT min(double x, double y)
Returns the minimum of two doubles or the first argument if both are equal.
int splitParts(const QList< QgsPoint > &splitLine, bool topologicalEditing=false)
Splits parts cut by the given line.
static QgsExpressionContextScope * layerScope(const QgsMapLayer *layer)
Creates a new scope which contains variables and functions relating to a QgsMapLayer.
QString providerType() const
Return the provider type for this layer.
const_iterator constEnd() const
void normalize()
Normalize the rectangle so it has non-negative width/height.
QDomElement createElement(const QString &tagName)
bool nextFeature(QgsFeature &f)
const_iterator constBegin() const
void setCoordinateSystem()
Setup the coordinate system transformation for the layer.
This is the base class for vector data providers.
void attributeDeleted(int idx)
Will be emitted, when an attribute has been deleted from this vector layer.
Q_DECL_DEPRECATED bool hasLabelsEnabled() const
Label is on.
Abstract base class for curved geometry type.
Geometry is not required. It may still be returned if e.g. required for a filter condition.
bool intersects(const QgsRectangle &rect) const
returns true when rectangle intersects with other rectangle
virtual bool readXml(const QDomNode &layer_node) override
Reads vector layer specific state from project file Dom node.
void setLegend(QgsMapLayerLegend *legend)
Assign a legend controller to the map layer.
QgsFeatureMap mAddedFeatures
New features which are not commited.
QgsRelation relation(const QString &id) const
Get access to a relation by its id.
int addRing(const QList< QgsPoint > &ring, QgsFeatureId *featureId=nullptr)
Adds a ring to polygon/multipolygon features.
void committedGeometriesChanges(const QString &layerId, const QgsGeometryMap &changedGeometries)
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QgsFeatureIds allFeatureIds()
Get all feature Ids.
static QgsFeatureRendererV2 * readOldRenderer(const QDomNode &layerNode, QGis::GeometryType geomType)
Read old renderer definition from XML and create matching new renderer.
bool hasEvalError() const
Returns true if an error occurred when evaluating last input.
void updateFields(QgsFields &fields)
virtual QgsRectangle extent()
Return the extent of the layer.
bool addAttribute(const QgsField &field)
Add an attribute field (but does not commit it) returns true if the field was added.
QVariant attribute(const QString &name) const
Lookup attribute value from attribute name.
int splitParts(const QList< QgsPoint > &splitLine, bool topologicalEditing=false)
Splits parts cut by the given line.
void modifySelection(QgsFeatureIds selectIds, QgsFeatureIds deselectIds)
Modifies the current selection on this layer.
field is calculated from an expression
int selectedFeatureCount()
The number of features that are selected in this layer.
void updatedFields()
Is emitted, whenever the fields available from this layer have been changed.
QgsPoint closestVertex(const QgsPoint &point, int &atVertex, int &beforeVertex, int &afterVertex, double &sqrDist) const
Returns the vertex closest to the given point, the corresponding vertex index, squared distance snap ...
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
void updateExpressionField(int index, const QString &exp)
Changes the expression used to define an expression based (virtual) field.
EditResult
Result of an edit operation.
const QgsVectorLayer * layer
Layer where the snap occurred.
void layerModified()
This signal is emitted when modifications has been done on layer.
QgsAttributeList mDeletedAttributeIds
Deleted attributes fields which are not commited.
Q_DECL_DEPRECATED void drawLabels(QgsRenderContext &rendererContext) override
Draws the layer labels using the old labeling engine.
QString attributeDisplayName(int attributeIndex) const
Convenience function that returns the attribute alias if defined or the field name else...
bool readXML(const QDomNode &layer_node)
Reads the actions in in XML format.
virtual bool changeGeometry(QgsFeatureId fid, QgsGeometry *geom)
Change feature's geometry.
int beforeVertexNr
The index of the vertex before snappedVertex or -1 if no such vertex.
void writeXML(QDomElement &layerElem, QDomDocument &doc, const QgsVectorLayer *layer) const
void createJoinCaches()
Caches joined attributes if required (and not already done)
virtual void exportSldStyle(QDomDocument &doc, QString &errorMsg)
Export the properties of this layer as SLD style in a QDomDocument.
int fieldNameIndex(const QString &fieldName) const
Returns the index of a field name or -1 if the field does not exist.
double x() const
Get the x value of the point.
int splitFeatures(const QList< QgsPoint > &splitLine, bool topologicalEditing=false)
Splits features cut by the given line.
void writeXML(QDomNode &label_node, QDomDocument &document) const
Writes the contents of the renderer to a configuration file.
virtual bool leaveUpdateMode()
Leave update mode.
QString attributeAlias(int attributeIndex) const
Returns the alias of an attribute name or an empty string if there is no alias.
bool diagramsEnabled() const
Returns whether the layer contains diagrams which are enabled and should be drawn.
QPainter::CompositionMode blendMode() const
Returns the current blending mode for a layer.
double height() const
Height of the rectangle.
bool setContent(const QByteArray &data, bool namespaceProcessing, QString *errorMsg, int *errorLine, int *errorColumn)
QDomNode at(int index) const
const T value(const Key &key) const
virtual void saveStyleToDatabase(const QString &name, const QString &description, bool useAsDefault, const QString &uiFileContent, QString &msgError)
Save named and sld style of the layer to the style table in the db.
Q_DECL_DEPRECATED void enableLabels(bool on)
Set labels on.
int remove(const Key &key)
void setThreshold(float threshold)
Sets the simplification threshold of the vector layer managed.
QgsRectangle boundingBoxOfSelected()
Returns the bounding box of the selected features.
bool saveStyle_t(const QString &uri, const QString &qmlStyle, const QString &sldStyle, const QString &styleName, const QString &styleDescription, const QString &uiFileContent, bool useAsDefault, QString &errCause)
int listStyles_t(const QString &uri, QStringList &ids, QStringList &names, QStringList &descriptions, QString &errCause)
QByteArray toUtf8() const