@@ -1681,61 +1681,77 @@ void QgsMapLayer::setExtent( const QgsRectangle &r )
1681
1681
mExtent = r;
1682
1682
}
1683
1683
1684
- static QList<const QgsMapLayer*> _depOutEdges ( const QgsMapLayer* vl, const QgsMapLayer* that, const QSet<QString >& layersIds )
1684
+ static QList<const QgsMapLayer*> _depOutEdges ( const QgsMapLayer* vl, const QgsMapLayer* that, const QSet<QgsMapLayerDependency >& layers )
1685
1685
{
1686
1686
QList<const QgsMapLayer*> lst;
1687
1687
if ( vl == that )
1688
1688
{
1689
- Q_FOREACH ( QString layerId, layersIds )
1689
+ Q_FOREACH ( const QgsMapLayerDependency& dep, layers )
1690
1690
{
1691
- if ( const QgsMapLayer* l = QgsMapLayerRegistry::instance ()->mapLayer ( layerId ) )
1691
+ if ( const QgsMapLayer* l = QgsMapLayerRegistry::instance ()->mapLayer ( dep. layerId () ) )
1692
1692
lst << l;
1693
1693
}
1694
1694
}
1695
1695
else
1696
1696
{
1697
- Q_FOREACH ( QString layerId , vl->dataDependencies () )
1697
+ Q_FOREACH ( const QgsMapLayerDependency& dep , vl->dependencies () )
1698
1698
{
1699
- if ( const QgsMapLayer* l = QgsMapLayerRegistry::instance ()->mapLayer ( layerId ) )
1699
+ if ( const QgsMapLayer* l = QgsMapLayerRegistry::instance ()->mapLayer ( dep. layerId () ) )
1700
1700
lst << l;
1701
1701
}
1702
1702
}
1703
1703
return lst;
1704
1704
}
1705
1705
1706
- static bool _depHasCycleDFS ( const QgsMapLayer* n, QHash<const QgsMapLayer*, int >& mark, const QgsMapLayer* that, const QSet<QString >& layersIds )
1706
+ static bool _depHasCycleDFS ( const QgsMapLayer* n, QHash<const QgsMapLayer*, int >& mark, const QgsMapLayer* that, const QSet<QgsMapLayerDependency >& layers )
1707
1707
{
1708
1708
if ( mark.value ( n ) == 1 ) // temporary
1709
1709
return true ;
1710
1710
if ( mark.value ( n ) == 0 ) // not visited
1711
1711
{
1712
1712
mark[n] = 1 ; // temporary
1713
- Q_FOREACH ( const QgsMapLayer* m, _depOutEdges ( n, that, layersIds ) )
1713
+ Q_FOREACH ( const QgsMapLayer* m, _depOutEdges ( n, that, layers ) )
1714
1714
{
1715
- if ( _depHasCycleDFS ( m, mark, that, layersIds ) )
1715
+ if ( _depHasCycleDFS ( m, mark, that, layers ) )
1716
1716
return true ;
1717
1717
}
1718
1718
mark[n] = 2 ; // permanent
1719
1719
}
1720
1720
return false ;
1721
1721
}
1722
1722
1723
- bool QgsMapLayer::hasDataDependencyCycle ( const QSet<QString >& layersIds ) const
1723
+ bool QgsMapLayer::hasDataDependencyCycle ( const QSet<QgsMapLayerDependency >& layers ) const
1724
1724
{
1725
1725
QHash<const QgsMapLayer*, int > marks;
1726
- return _depHasCycleDFS ( this , marks, this , layersIds );
1726
+ return _depHasCycleDFS ( this , marks, this , layers );
1727
+ }
1728
+
1729
+ QSet<QgsMapLayerDependency> QgsMapLayer::dependencies () const
1730
+ {
1731
+ return mDataDependencies ;
1727
1732
}
1728
1733
1729
1734
bool QgsMapLayer::setDataDependencies ( const QSet<QString>& layersIds )
1730
1735
{
1731
- if ( hasDataDependencyCycle ( layersIds ) )
1736
+ QSet<QgsMapLayerDependency> deps;
1737
+ Q_FOREACH ( QString layerId, layersIds )
1738
+ {
1739
+ deps << QgsMapLayerDependency ( layerId );
1740
+ }
1741
+ if ( hasDataDependencyCycle ( deps ) )
1732
1742
return false ;
1733
1743
1734
- mDataDependencies = layersIds ;
1744
+ mDataDependencies = deps ;
1735
1745
return true ;
1736
1746
}
1737
1747
1738
- QSet<QString> QgsMapLayer::dataDependencies () const
1748
+ bool QgsMapLayer::setDataDependencies ( const QSet<QgsMapLayerDependency>& layers )
1739
1749
{
1740
- return mDataDependencies ;
1750
+ QSet<QString> deps;
1751
+ Q_FOREACH ( const QgsMapLayerDependency& dep, layers )
1752
+ {
1753
+ if ( dep.origin () == QgsMapLayerDependency::FromUser && dep.type () == QgsMapLayerDependency::DataDependency )
1754
+ deps << dep.layerId ();
1755
+ }
1756
+ return setDataDependencies ( deps );
1741
1757
}
0 commit comments