25
25
#include " qgis.h"
26
26
#include " qgsfieldcombobox.h"
27
27
#include " qgisapp.h"
28
- #include " qgsmapcanvas .h"
28
+ #include " qgslayertreemapcanvasbridge .h"
29
29
#include " qgsvisibilitypresets.h"
30
30
31
31
#include < QFileDialog>
@@ -254,7 +254,7 @@ bool QgsVectorLayerAndAttributeModel::setData( const QModelIndex &index, const Q
254
254
QList< QPair<QgsVectorLayer *, int > > QgsVectorLayerAndAttributeModel::layers () const
255
255
{
256
256
QList< QPair<QgsVectorLayer *, int > > layers;
257
- QHash< QgsMapLayer * , int > layerIdx;
257
+ QHash< QString , int > layerIdx;
258
258
259
259
foreach ( const QModelIndex &idx, mCheckedLeafs )
260
260
{
@@ -265,9 +265,9 @@ QList< QPair<QgsVectorLayer *, int> > QgsVectorLayerAndAttributeModel::layers()
265
265
{
266
266
QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( treeLayer->layer () );
267
267
Q_ASSERT ( vl );
268
- if ( !layerIdx.contains ( vl ) )
268
+ if ( !layerIdx.contains ( vl-> id () ) )
269
269
{
270
- layerIdx.insert ( vl, layers.size () );
270
+ layerIdx.insert ( vl-> id () , layers.size () );
271
271
layers << qMakePair<QgsVectorLayer *, int >( vl, mAttributeIdx .value ( vl, -1 ) );
272
272
}
273
273
}
@@ -276,15 +276,16 @@ QList< QPair<QgsVectorLayer *, int> > QgsVectorLayerAndAttributeModel::layers()
276
276
{
277
277
QgsVectorLayer *vl = qobject_cast< QgsVectorLayer *>( QgsLayerTree::toLayer ( node )->layer () );
278
278
Q_ASSERT ( vl );
279
- if ( !layerIdx.contains ( vl ) )
279
+ if ( !layerIdx.contains ( vl-> id () ) )
280
280
{
281
- layerIdx.insert ( vl, layers.size () );
281
+ layerIdx.insert ( vl-> id () , layers.size () );
282
282
layers << qMakePair<QgsVectorLayer *, int >( vl, mAttributeIdx .value ( vl, -1 ) );
283
283
}
284
284
}
285
285
}
286
286
287
- QList<QgsMapLayer*> inDrawingOrder = QgisApp::instance ()->mapCanvas ()->layers ();
287
+ QgsLayerTreeMapCanvasBridge* bridge = QgisApp::instance ()->layerTreeCanvasBridge ();
288
+ QStringList inDrawingOrder = bridge->hasCustomLayerOrder () ? bridge->customLayerOrder () : bridge->defaultLayerOrder ();
288
289
QList< QPair<QgsVectorLayer *, int > > layersInROrder;
289
290
290
291
for ( int i = inDrawingOrder.size () - 1 ; i >= 0 ; i-- )
0 commit comments