Skip to content
Permalink
Browse files

Store layer list in canvas order for visibility presets, fixes

data defined style preset for composer maps changing layer
order
  • Loading branch information
nyalldawson committed Sep 29, 2015
1 parent 63ddb15 commit fea4ed99269395f775df1fe96728dc558d141f73
@@ -22,8 +22,8 @@ class QgsVisibilityPresetCollection : QObject
bool operator==( const QgsVisibilityPresetCollection::PresetRecord& other ) const;
bool operator!=( const QgsVisibilityPresetCollection::PresetRecord& other ) const;

//! List of layers that are visible
QSet<QString> mVisibleLayerIDs;
//! Ordered list of layers that are visible
QStringList mVisibleLayerIDs;
/** For layers that have checkable legend symbols and not all symbols are checked - list which ones are
* @note not available in Python bindings
*/
@@ -281,7 +281,6 @@ void QgsVisibilityPresets::menuAboutToShow()
mMenuPresetActions.append( a );

QAction* replaceAction = new QAction( grpName, mReplaceMenu );
replaceAction->setEnabled( !a->isChecked() ); //can't replace current preset
connect( replaceAction, SIGNAL( triggered() ), this, SLOT( replaceTriggered() ) );
mReplaceMenu->addAction( replaceAction );
}
@@ -93,8 +93,7 @@ QStringList QgsVisibilityPresetCollection::presets() const

QStringList QgsVisibilityPresetCollection::presetVisibleLayers( const QString& name ) const
{
QSet<QString> visibleIds = mPresets.value( name ).mVisibleLayerIDs;
return visibleIds.toList();
return mPresets.value( name ).mVisibleLayerIDs;
}


@@ -275,7 +274,7 @@ void QgsVisibilityPresetCollection::registryLayersRemoved( QStringList layerIDs
Q_FOREACH ( const QString& presetName, mPresets.keys() )
{
PresetRecord& rec = mPresets[presetName];
rec.mVisibleLayerIDs.remove( layerID );
rec.mVisibleLayerIDs.removeAll( layerID );
rec.mPerLayerCheckedLegendSymbols.remove( layerID );
rec.mPerLayerCurrentStyle.remove( layerID );
}
@@ -47,7 +47,7 @@ class CORE_EXPORT QgsVisibilityPresetCollection : public QObject

bool operator==( const PresetRecord& other ) const
{
return mVisibleLayerIDs == other.mVisibleLayerIDs
return mVisibleLayerIDs.toSet() == other.mVisibleLayerIDs.toSet()
&& mPerLayerCheckedLegendSymbols == other.mPerLayerCheckedLegendSymbols
&& mPerLayerCurrentStyle == other.mPerLayerCurrentStyle;
}
@@ -56,8 +56,8 @@ class CORE_EXPORT QgsVisibilityPresetCollection : public QObject
return !( *this == other );
}

//! List of layers that are visible
QSet<QString> mVisibleLayerIDs;
//! Ordered list of layers that are visible
QStringList mVisibleLayerIDs;
/** For layers that have checkable legend symbols and not all symbols are checked - list which ones are
* @note not available in Python bindings
*/
@@ -350,8 +350,8 @@ void TestQgsComposerMap::dataDefinedStyles()
mComposition->addComposerMap( mComposerMap );

QgsVisibilityPresetCollection::PresetRecord rec;
rec.mVisibleLayerIDs.insert( mPointsLayer->id() );
rec.mVisibleLayerIDs.insert( mLinesLayer->id() );
rec.mVisibleLayerIDs << mPointsLayer->id();
rec.mVisibleLayerIDs << mLinesLayer->id();

QgsProject::instance()->visibilityPresetCollection()->insert( "test preset", rec );

0 comments on commit fea4ed9

Please sign in to comment.
You can’t perform that action at this time.