@@ -37,6 +37,24 @@ class QgsVisibilityGroups : public QObject
3737 Q_OBJECT
3838 public:
3939
40+ typedef struct GroupRecord
41+ {
42+ bool operator ==( const GroupRecord& other ) const
43+ {
44+ return mVisibleLayerIDs == other.mVisibleLayerIDs && mPerLayerCheckedLegendSymbols == other.mPerLayerCheckedLegendSymbols ;
45+ }
46+ bool operator !=( const GroupRecord& other ) const
47+ {
48+ return !( *this == other );
49+ }
50+
51+ // ! List of layers that are visible
52+ QSet<QString> mVisibleLayerIDs ;
53+ // ! For layers that have checkable legend symbols and not all symbols are checked - list which ones are
54+ QMap<QString, QSet<QString> > mPerLayerCheckedLegendSymbols ;
55+ } GroupRecord;
56+
57+
4058 static QgsVisibilityGroups* instance ();
4159
4260 // ! Add a new group using the current state of project's layer tree
@@ -52,6 +70,9 @@ class QgsVisibilityGroups : public QObject
5270 // ! Return list of existing group names
5371 QStringList groups () const ;
5472
73+ // ! Return recorded state of a group
74+ GroupRecord groupState ( const QString& groupName ) const { return mGroups [groupName]; }
75+
5576 // ! Return list of layer IDs that should be visible for particular group
5677 QStringList groupVisibleLayers ( const QString& name ) const ;
5778
@@ -61,6 +82,9 @@ class QgsVisibilityGroups : public QObject
6182 // ! Convenience menu that lists available groups and actions for management
6283 QMenu* menu ();
6384
85+ // ! Create group record given a list of visible layers (needs to store per-layer checked legend symbols)
86+ GroupRecord currentStateFromLayerList ( const QStringList& layerIDs );
87+
6488 signals:
6589 void groupsChanged ();
6690
@@ -78,27 +102,11 @@ class QgsVisibilityGroups : public QObject
78102 protected:
79103 QgsVisibilityGroups (); // singleton
80104
81- typedef struct GroupRecord
82- {
83- bool operator ==( const GroupRecord& other ) const
84- {
85- return mVisibleLayerIDs == other.mVisibleLayerIDs && mPerLayerCheckedLegendSymbols == other.mPerLayerCheckedLegendSymbols ;
86- }
87- bool operator !=( const GroupRecord& other ) const
88- {
89- return !( *this == other );
90- }
91-
92- // ! List of layers that are visible
93- QSet<QString> mVisibleLayerIDs ;
94- // ! For layers that have checkable legend symbols and not all symbols are checked - list which ones are
95- QMap<QString, QSet<QString> > mPerLayerCheckedLegendSymbols ;
96- } GroupRecord;
97-
98105 typedef QMap<QString, GroupRecord> GroupRecordMap;
99106
100107 void addVisibleLayersToGroup ( QgsLayerTreeGroup* parent, GroupRecord& rec );
101108 void applyStateToLayerTreeGroup ( QgsLayerTreeGroup* parent, const GroupRecord& rec );
109+ void addPerLayerCheckedLegendSymbols ( GroupRecord& rec );
102110
103111 GroupRecord currentState ();
104112 void applyState ( const QString& groupName );
0 commit comments