27 #include <QInputDialog> 124 if ( checked != shouldBeChecked )
134 return styleOverrides;
138 Q_FOREACH (
const QString& layerID, lst )
156 styleOverrides[layerID] = layerStyle.
xmlData();
160 return styleOverrides;
174 layerIDs << layerIt.
key();
177 Q_FOREACH (
const QString& layerID, layerIDs )
189 if ( visPresetsElem.
isNull() )
193 while ( !visPresetElem.
isNull() )
198 while ( !visPresetLayerElem.
isNull() )
211 while ( !checkedLegendNodesElem.
isNull() )
216 while ( !checkedLegendNodeElem.
isNull() )
218 checkedLegendNodes << checkedLegendNodeElem.
attribute(
"id" );
219 checkedLegendNodeElem = checkedLegendNodeElem.
nextSiblingElement(
"checked-legend-node" );
225 checkedLegendNodesElem = checkedLegendNodesElem.
nextSiblingElement(
"checked-legend-nodes" );
261 Q_FOREACH (
const QString& checkedLegendNode, layerIt.
value() )
264 checkedLegendNodeElem.
setAttribute(
"id", checkedLegendNode );
265 checkedLegendNodesElem.
appendChild( checkedLegendNodeElem );
267 visPresetElem.
appendChild( checkedLegendNodesElem );
278 Q_FOREACH (
const QString& layerID, layerIDs )
307 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 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 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.
QgsMapLayerStyleManager * styleManager() const
Get access to the layer's style manager.
const_iterator constBegin() 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.
QString ruleKey() const
Return unique identifier of the rule for identification of the item within renderer.
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 ...
QStringList presets() const
Returns a list of existing preset names.
QgsMapLayer * mapLayer(const QString &theLayerId)
Retrieve a pointer to a loaded layer by id.
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.
QStringList presetVisibleLayers(const QString &name) const
Returns the list of layer IDs that should be visible for the specified preset.
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.
Qt::CheckState isVisible() const
QgsFeatureRendererV2 * rendererV2()
Return renderer V2.
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.
QString currentStyle() const
Return name of the current style.
QStringList mVisibleLayerIDs
Ordered list of layers that are visible.
This class is a base class for nodes in a layer tree.
QString id() const
Get this layer's unique ID, this ID is used to access this layer from map layer registry.
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.
QgsMapLayer * layer() const
Get pointer to the associated map layer.
static void addVisibleLayersToPreset(QgsLayerTreeGroup *parent, PresetRecord &rec)
Static method for adding visible layers from a layer tree group to a preset record.
QString xmlData() const
Return XML content of the 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 ...
virtual QgsLegendSymbolListV2 legendSymbolItemsV2() const
Return a list of symbology items for the legend.
virtual bool legendSymbolItemsCheckable() const
items of symbology items in legend should be checkable
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)
bool setOverrideStyle(const QString &styleDef)
Temporarily apply a different style to the layer.
bool hasPreset(const QString &name) const
Returns whether a preset with a matching name exists.
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 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.
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)