File tree 3 files changed +42
-0
lines changed
3 files changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -45,8 +45,14 @@ class QgsMapLayerProxyModel : QSortFilterProxyModel
45
45
46
46
//! offer the possibility to except some layers to be listed
47
47
void setExceptedLayerList( const QList<QgsMapLayer*>& exceptList );
48
+ //! Get the list of maplayers which are excluded from the list
48
49
QList<QgsMapLayer*> exceptedLayerList();
49
50
51
+ //! Set the list of maplayer ids which are excluded from the list
52
+ void setExceptedLayerIds( const QStringList& ids );
53
+ //! Get the list of maplayer ids which are excluded from the list
54
+ QStringList exceptedLayerIds() const;
55
+
50
56
// QSortFilterProxyModel interface
51
57
public:
52
58
bool filterAcceptsRow( int source_row, const QModelIndex &source_parent ) const;
Original file line number Diff line number Diff line change 16
16
#include " qgsmaplayerproxymodel.h"
17
17
#include " qgsmaplayermodel.h"
18
18
#include " qgsmaplayer.h"
19
+ #include " qgsmaplayerregistry.h"
19
20
#include " qgsvectorlayer.h"
20
21
21
22
QgsMapLayerProxyModel::QgsMapLayerProxyModel ( QObject *parent )
@@ -40,10 +41,36 @@ QgsMapLayerProxyModel *QgsMapLayerProxyModel::setFilters( const Filters& filters
40
41
41
42
void QgsMapLayerProxyModel::setExceptedLayerList ( const QList<QgsMapLayer*>& exceptList )
42
43
{
44
+ if ( mExceptList == exceptList )
45
+ return ;
46
+
43
47
mExceptList = exceptList;
44
48
invalidateFilter ();
45
49
}
46
50
51
+ void QgsMapLayerProxyModel::setExceptedLayerIds ( const QStringList& ids )
52
+ {
53
+ mExceptList .clear ();
54
+
55
+ Q_FOREACH ( const QString& id, ids )
56
+ {
57
+ QgsMapLayer* l = QgsMapLayerRegistry::instance ()->mapLayer ( id );
58
+ if ( l )
59
+ mExceptList << l;
60
+ }
61
+ invalidateFilter ();
62
+ }
63
+
64
+ QStringList QgsMapLayerProxyModel::exceptedLayerIds () const
65
+ {
66
+ QStringList lst;
67
+
68
+ Q_FOREACH ( QgsMapLayer* l, mExceptList )
69
+ lst << l->id ();
70
+
71
+ return lst;
72
+ }
73
+
47
74
bool QgsMapLayerProxyModel::filterAcceptsRow ( int source_row, const QModelIndex &source_parent ) const
48
75
{
49
76
if ( mFilters .testFlag ( All ) && mExceptList .isEmpty () )
Original file line number Diff line number Diff line change 17
17
#define QGSMAPLAYERPROXYMODEL_H
18
18
19
19
#include < QSortFilterProxyModel>
20
+ #include < QStringList>
20
21
21
22
class QgsMapLayerModel ;
22
23
class QgsMapLayer ;
@@ -31,6 +32,8 @@ class GUI_EXPORT QgsMapLayerProxyModel : public QSortFilterProxyModel
31
32
Q_FLAGS ( Filters )
32
33
33
34
Q_PROPERTY ( QgsMapLayerProxyModel::Filters filters READ filters WRITE setFilters )
35
+ Q_PROPERTY ( QList<QgsMapLayer*> exceptedLayerList READ exceptedLayerList WRITE setExceptedLayerList )
36
+ Q_PROPERTY ( QStringList exceptedLayerIds READ exceptedLayerIds WRITE setExceptedLayerIds )
34
37
35
38
public:
36
39
enum Filter
@@ -68,8 +71,14 @@ class GUI_EXPORT QgsMapLayerProxyModel : public QSortFilterProxyModel
68
71
69
72
// ! offer the possibility to except some layers to be listed
70
73
void setExceptedLayerList ( const QList<QgsMapLayer*>& exceptList );
74
+ // ! Get the list of maplayers which are excluded from the list
71
75
QList<QgsMapLayer*> exceptedLayerList () {return mExceptList ;}
72
76
77
+ // ! Set the list of maplayer ids which are excluded from the list
78
+ void setExceptedLayerIds ( const QStringList& ids );
79
+ // ! Get the list of maplayer ids which are excluded from the list
80
+ QStringList exceptedLayerIds () const ;
81
+
73
82
private:
74
83
Filters mFilters ;
75
84
QList<QgsMapLayer*> mExceptList ;
You can’t perform that action at this time.
0 commit comments