|
21 | 21 |
|
22 | 22 | #include "qgsproject.h" |
23 | 23 | #include "qgslogger.h" |
24 | | -#include <QAction> |
25 | 24 |
|
26 | 25 | QgsLayerTreeRegistryBridge::QgsLayerTreeRegistryBridge( QgsLayerTreeGroup *root, QObject *parent ) |
27 | 26 | : QObject( parent ) |
@@ -72,10 +71,6 @@ void QgsLayerTreeRegistryBridge::layersWillBeRemoved( QStringList layerIds ) |
72 | 71 |
|
73 | 72 | foreach ( QString layerId, layerIds ) |
74 | 73 | { |
75 | | - QgsMapLayer* mapLayer = QgsMapLayerRegistry::instance()->mapLayer( layerId ); |
76 | | - if ( mapLayer ) |
77 | | - removeLegendLayerActionsForLayer( mapLayer ); |
78 | | - |
79 | 74 | QgsLayerTreeLayer* nodeLayer = mRoot->findLayer( layerId ); |
80 | 75 | if ( nodeLayer ) |
81 | 76 | qobject_cast<QgsLayerTreeGroup*>( nodeLayer->parent() )->removeChildNode( nodeLayer ); |
@@ -123,75 +118,3 @@ void QgsLayerTreeRegistryBridge::groupRemovedChildren() |
123 | 118 |
|
124 | 119 | QgsMapLayerRegistry::instance()->removeMapLayers( toRemove ); |
125 | 120 | } |
126 | | - |
127 | | -void QgsLayerTreeRegistryBridge::addLegendLayerAction( QAction* action, QString menu, QString id, |
128 | | - QgsMapLayer::LayerType type, bool allLayers ) |
129 | | -{ |
130 | | - mLegendLayerActionMap[type].append( LegendLayerAction( action, menu, id, allLayers ) ); |
131 | | -} |
132 | | - |
133 | | -bool QgsLayerTreeRegistryBridge::removeLegendLayerAction( QAction* action ) |
134 | | -{ |
135 | | - QMap< QgsMapLayer::LayerType, QList< LegendLayerAction > >::iterator it; |
136 | | - for ( it = mLegendLayerActionMap.begin(); |
137 | | - it != mLegendLayerActionMap.end(); ++it ) |
138 | | - { |
139 | | - for ( int i = 0; i < it->count(); i++ ) |
140 | | - { |
141 | | - if (( *it )[i].action == action ) |
142 | | - { |
143 | | - ( *it ).removeAt( i ); |
144 | | - return true; |
145 | | - } |
146 | | - } |
147 | | - } |
148 | | - return false; |
149 | | -} |
150 | | - |
151 | | -void QgsLayerTreeRegistryBridge::addLegendLayerActionForLayer( QAction* action, QgsMapLayer* layer ) |
152 | | -{ |
153 | | - legendLayerActions( layer->type() ); |
154 | | - if ( !action || !layer || ! mLegendLayerActionMap.contains( layer->type() ) ) |
155 | | - return; |
156 | | - |
157 | | - QMap< QgsMapLayer::LayerType, QList< LegendLayerAction > >::iterator it |
158 | | - = mLegendLayerActionMap.find( layer->type() ); |
159 | | - for ( int i = 0; i < it->count(); i++ ) |
160 | | - { |
161 | | - if ( ( *it )[i].action == action ) |
162 | | - { |
163 | | - ( *it )[i].layers.append( layer ); |
164 | | - return; |
165 | | - } |
166 | | - } |
167 | | -} |
168 | | - |
169 | | -void QgsLayerTreeRegistryBridge::removeLegendLayerActionsForLayer( QgsMapLayer* layer ) |
170 | | -{ |
171 | | - if ( ! layer || ! mLegendLayerActionMap.contains( layer->type() ) ) |
172 | | - return; |
173 | | - |
174 | | - QMap< QgsMapLayer::LayerType, QList< LegendLayerAction > >::iterator it |
175 | | - = mLegendLayerActionMap.find( layer->type() ); |
176 | | - for ( int i = 0; i < it->count(); i++ ) |
177 | | - { |
178 | | - ( *it )[i].layers.removeAll( layer ); |
179 | | - } |
180 | | -} |
181 | | - |
182 | | -QList< LegendLayerAction > QgsLayerTreeRegistryBridge::legendLayerActions( QgsMapLayer::LayerType type ) const |
183 | | -{ |
184 | | -#ifdef QGISDEBUG |
185 | | - if ( mLegendLayerActionMap.contains( type ) ) |
186 | | - { |
187 | | - QgsDebugMsg( QString("legendLayerActions for layers of type %1:").arg( type ) ); |
188 | | - |
189 | | - foreach ( LegendLayerAction lyrAction, mLegendLayerActionMap[ type ] ) |
190 | | - { |
191 | | - QgsDebugMsg( QString("%1/%2 - %3 layers").arg( lyrAction.menu ).arg( lyrAction.action->text() ).arg( lyrAction.layers.count()) ); |
192 | | - } |
193 | | - } |
194 | | -#endif |
195 | | - |
196 | | - return mLegendLayerActionMap.contains( type ) ? mLegendLayerActionMap.value( type ) : QList< LegendLayerAction >() ; |
197 | | -} |
0 commit comments