QGIS API Documentation 3.99.0-Master (2fe06baccd8)
Loading...
Searching...
No Matches
qgsmaskidprovider.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsmaskidprovider.cpp
3 ---------------------
4 begin : August 2019
5 copyright : (C) 2019 by Hugo Mercier / Oslandia
6 email : infos at oslandia dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#include "qgsmaskidprovider.h"
17
19
20int QgsMaskIdProvider::insertLabelLayer( const QString &layerId, const QString &ruleId, const QSet<QgsSymbolLayerReference> &maskedSymbolLayers )
21{
22 const QString strId = layerId + ruleId;
23 // look for an existing symbol layer set
24 const int maskId = mLabelLayers.indexOf( maskedSymbolLayers );
25 if ( maskId != -1 )
26 {
27 // add the layer id / rule id to the existing mask id
28 mMaskIds[maskId].insert( strId );
29 return maskId;
30 }
31 // else
32 mLabelLayers.push_back( maskedSymbolLayers );
33 mMaskIds.push_back( QSet<QString>() << strId );
34 return mMaskIds.size() - 1;
35}
36
37int QgsMaskIdProvider::maskId( const QString &labelLayerId, const QString &labelRuleId ) const
38{
39 if ( labelLayerId.isEmpty() )
40 return -1;
41
42 const QString id = labelLayerId + labelRuleId;
43 for ( int i = 0; i < mMaskIds.size(); i++ )
44 {
45 if ( mMaskIds[i].contains( id ) )
46 return i;
47 }
48 return -1;
49}
50
52{
53 return mMaskIds.size();
54}
int size() const
Returns the number of identifiers allocated.
int maskId(const QString &labelLayerId=QString(), const QString &labelRuleId=QString()) const
Returns the mask id associated with a label layer and its optional label rule.
int insertLabelLayer(const QString &layerId, const QString &ruleId, const QSet< QgsSymbolLayerReference > &maskedSymbolLayers)
Inserts a label layer to the provider and returns its associated mask id.