27 #include <QInputDialog> 128 if ( checked != shouldBeChecked )
138 return styleOverrides;
142 Q_FOREACH (
const QString& layerID, lst )
160 styleOverrides[layerID] = layerStyle.
xmlData();
164 return styleOverrides;
178 layerIDs << layerIt.
key();
181 Q_FOREACH (
const QString& layerID, layerIDs )
193 if ( visPresetsElem.
isNull() )
197 while ( !visPresetElem.
isNull() )
202 while ( !visPresetLayerElem.
isNull() )
215 while ( !checkedLegendNodesElem.
isNull() )
220 while ( !checkedLegendNodeElem.
isNull() )
222 checkedLegendNodes << checkedLegendNodeElem.
attribute(
"id" );
223 checkedLegendNodeElem = checkedLegendNodeElem.
nextSiblingElement(
"checked-legend-node" );
229 checkedLegendNodesElem = checkedLegendNodesElem.
nextSiblingElement(
"checked-legend-nodes" );
266 Q_FOREACH (
const QString& checkedLegendNode, layerIt.
value() )
269 checkedLegendNodeElem.
setAttribute(
"id", checkedLegendNode );
270 checkedLegendNodesElem.
appendChild( checkedLegendNodeElem );
272 visPresetElem.
appendChild( checkedLegendNodesElem );
283 Q_FOREACH (
const QString& layerID, layerIDs )
313 if ( styleName == oldName )
bool restoreOverrideStyle()
Restore the original store after a call to setOverrideStyle()
Layer tree group node serves as a container for layers and further groups.
void clear()
Remove all presets from the collection.
Base class for all map layer types.
void presetsChanged()
Emitted when presets within the collection are changed.
void layerStyleRenamed(const QString &oldName, const QString &newName)
Update style name if a stored style gets renamed.
bool contains(const Key &key) const
void readXML(const QDomDocument &doc)
Reads the preset collection state from XML.
QDomNode appendChild(const QDomNode &newChild)
QString xmlData() const
Return XML content of the style.
QString attribute(const QString &name, const QString &defValue) const
QMap< QString, QString > presetStyleOverrides(const QString &name)
Get layer style overrides (for QgsMapSettings) of the visible layers for given preset.
QgsMapLayer * mapLayer(const QString &theLayerId) const
Retrieve a pointer to a registered layer by layer ID.
QString ruleKey() const
Return unique identifier of the rule for identification of the item within renderer.
const_iterator constBegin() const
Qt::CheckState isVisible() const
void writeXML(QDomDocument &doc)
Writes the preset collection state to XML.
QDomElement nextSiblingElement(const QString &tagName) const
void applyPresetCheckedLegendNodesToLayer(const QString &name, const QString &layerID)
Apply check states of legend nodes of a given layer as defined in the preset.
virtual QgsLegendSymbolListV2 legendSymbolItemsV2() const
Return a list of symbology items for the legend.
virtual bool legendSymbolItemChecked(const QString &key)
items of symbology items in legend is checked
virtual void checkLegendSymbolItem(const QString &key, bool state=true)
item in symbology was checked
QgsLayerTreeGroup * toGroup(QgsLayerTreeNode *node)
Cast node to a group. No type checking is done - use isGroup() to find out whether this operation is ...
QgsMapLayerStyleManager * styleManager() const
Get access to the layer's style manager.
void readFromLayer(QgsMapLayer *layer)
Store layer's active style information in the instance.
QList< Key > keys() const
void update(const QString &name, const PresetRecord &state)
Updates a preset within the collection.
Stores style information (renderer, transparency, labeling, diagrams etc.) applicable to a map layer...
const char * name() const
void reconnectToLayersStyleManager()
Reconnects all preset layers to handle style renames.
QgsFeatureRendererV2 * rendererV2()
Return renderer V2.
QString id() const
Get this layer's unique ID, this ID is used to access this layer from map layer registry.
void insert(const QString &name, const PresetRecord &state)
Inserts a new preset to the collection.
bool hasAttribute(const QString &name) const
QMap< QString, QString > mPerLayerCurrentStyle
For layers that use multiple styles - which one is currently selected.
void setAttribute(const QString &name, const QString &value)
int removeAll(const T &value)
const_iterator constEnd() const
void removePreset(const QString &name)
Remove existing preset from collection.
QStringList mVisibleLayerIDs
Ordered list of layers that are visible.
This class is a base class for nodes in a layer tree.
QList< QgsLayerTreeNode * > children()
Get list of children of the node. Children are owned by the parent.
bool isLayer(QgsLayerTreeNode *node)
Check whether the node is a valid layer node.
static void addVisibleLayersToPreset(QgsLayerTreeGroup *parent, PresetRecord &rec)
Static method for adding visible layers from a layer tree group to a preset record.
QgsMapLayer * layer() const
Get pointer to the associated map layer.
QString currentStyle() const
Return name of the current style.
const Key key(const T &value) const
static QgsMapLayerRegistry * instance()
Returns the instance pointer, creating the object on the first call.
Individual preset record of visible layers and styles.
QgsLayerTreeLayer * toLayer(QgsLayerTreeNode *node)
Cast node to a layer. No type checking is done - use isLayer() to find out whether this operation is ...
QDomElement firstChildElement(const QString &tagName) const
void registryLayersRemoved(const QStringList &layerIDs)
Handles updates of the preset collection when layers are removed from the registry.
QgsVisibilityPresetCollection()
iterator insert(const Key &key, const T &value)
QStringList presetVisibleLayers(const QString &name) const
Returns the list of layer IDs that should be visible for the specified preset.
bool setOverrideStyle(const QString &styleDef)
Temporarily apply a different style to the layer.
virtual bool legendSymbolItemsCheckable() const
items of symbology items in legend should be checkable
QDomElement createElement(const QString &tagName)
QMap< QString, QSet< QString > > mPerLayerCheckedLegendSymbols
For layers that have checkable legend symbols and not all symbols are checked - list which ones are...
bool hasPreset(const QString &name) const
Returns whether a preset with a matching name exists.
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
Management of styles for use with one map layer.
QStringList presets() const
Returns a list of existing preset names.
Represents a vector layer which manages a vector based data sets.
bool isGroup(QgsLayerTreeNode *node)
Check whether the node is a valid group node.
The class stores information about one class/rule of a vector layer renderer in a unified way that ca...
Layer tree node points to a map layer.
const T value(const Key &key) const
int remove(const Key &key)