File: qgslayertreeview.sip.in

package info (click to toggle)
qgis 3.40.11%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,183,800 kB
  • sloc: cpp: 1,595,841; python: 372,637; xml: 23,474; sh: 3,761; perl: 3,664; ansic: 2,257; sql: 2,137; yacc: 1,068; lex: 577; javascript: 540; lisp: 411; makefile: 154
file content (543 lines) | stat: -rw-r--r-- 14,161 bytes parent folder | download | duplicates (14)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
/************************************************************************
 * This file has been generated automatically from                      *
 *                                                                      *
 * src/gui/layertree/qgslayertreeview.h                                 *
 *                                                                      *
 * Do not edit manually ! Edit header and run scripts/sipify.py again   *
 ************************************************************************/






class QgsLayerTreeProxyModel : QSortFilterProxyModel
{
%Docstring(signature="appended")
The :py:class:`QgsLayerTreeProxyModel` class is a proxy model for
:py:class:`QgsLayerTreeModel`, supports private layers and text
filtering.

.. versionadded:: 3.18
%End

%TypeHeaderCode
#include "qgslayertreeview.h"
%End
  public:
    QgsLayerTreeProxyModel( QgsLayerTreeModel *treeModel, QObject *parent );
%Docstring
Constructs QgsLayerTreeProxyModel with source model ``treeModel`` and a
``parent``
%End

    void setFilterText( const QString &filterText = QString() );
%Docstring
Sets filter to ``filterText``.
%End

    bool showPrivateLayers() const;
%Docstring
Returns if private layers are shown.
%End

    void setShowPrivateLayers( bool showPrivate );
%Docstring
Determines if private layers are shown.
%End

    bool hideValidLayers() const;
%Docstring
Returns if valid layers should be hidden (i.e. only invalid layers are
shown).

.. seealso:: :py:func:`setHideValidLayers`

.. versionadded:: 3.38
%End

    void setHideValidLayers( bool hideValid );
%Docstring
Sets whether valid layers should be hidden (i.e. only invalid layers are
shown).

.. seealso:: :py:func:`setHideValidLayers`

.. versionadded:: 3.38
%End

  protected:
    virtual bool filterAcceptsRow( int sourceRow, const QModelIndex &sourceParent ) const;


};


class QgsLayerTreeView : QTreeView
{
%Docstring(signature="appended")
The :py:class:`QgsLayerTreeView` class extends QTreeView and provides
some additional functionality when working with a layer tree.

The view updates expanded state of layer tree nodes and also listens to
changes to expanded states in the layer tree.

The view keeps track of the current layer and emits a signal when the
current layer has changed.

Allows the client to specify a context menu provider with custom
actions. Also it comes with a set of default actions that can be used
when building context menu.

.. seealso:: :py:class:`QgsLayerTreeModel`
%End

%TypeHeaderCode
#include "qgslayertreeview.h"
%End
%ConvertToSubClassCode
    if ( sipCpp->inherits( "QgsLayerTreeView" ) )
      sipType = sipType_QgsLayerTreeView;
    else
      sipType = 0;
%End
  public:
    explicit QgsLayerTreeView( QWidget *parent /TransferThis/ = 0 );
%Docstring
Constructor for QgsLayerTreeView
%End
    ~QgsLayerTreeView();

    virtual void setModel( QAbstractItemModel *model );

%Docstring
Overridden :py:func:`~QgsLayerTreeView.setModel` from base class. Only
:py:class:`QgsLayerTreeModel` is an acceptable model.
%End

    QgsLayerTreeModel *layerTreeModel() const;
%Docstring
Gets access to the model casted to :py:class:`QgsLayerTreeModel`
%End

    QgsLayerTreeProxyModel *proxyModel() const;
%Docstring
Returns the proxy model used by the view.

This can be used to set filters controlling which layers are shown in
the view.

.. versionadded:: 3.18
%End

    QgsLayerTreeNode *index2node( const QModelIndex &index ) const;
%Docstring
Returns layer tree node for given proxy model tree ``index``. Returns
root node for invalid index. Returns ``None`` if index does not refer to
a layer tree node (e.g. it is a legend node)

Unlike :py:func:`QgsLayerTreeModel.index2Node()`, calling this method
correctly accounts for mapping the view indexes through the view's proxy
model to the source model.

.. versionadded:: 3.18
%End

    QModelIndex node2index( QgsLayerTreeNode *node ) const;
%Docstring
Returns proxy model index for a given node. If the node does not belong
to the layer tree, the result is undefined

Unlike :py:func:`QgsLayerTreeModel.node2index()`, calling this method
correctly accounts for mapping the view indexes through the view's proxy
model to the source model.

.. versionadded:: 3.18
%End


    QModelIndex node2sourceIndex( QgsLayerTreeNode *node ) const;
%Docstring
Returns source model index for a given node. If the node does not belong
to the layer tree, the result is undefined

.. versionadded:: 3.18
%End


    QgsLayerTreeModelLegendNode *index2legendNode( const QModelIndex &index ) const;
%Docstring
Returns legend node for given proxy model tree ``index``. Returns
``None`` for invalid index

Unlike :py:func:`QgsLayerTreeModel.index2legendNode()`, calling this
method correctly accounts for mapping the view indexes through the
view's proxy model to the source model.

.. versionadded:: 3.18
%End

    QModelIndex legendNode2index( QgsLayerTreeModelLegendNode *legendNode );
%Docstring
Returns proxy model index for a given legend node. If the legend node
does not belong to the layer tree, the result is undefined. If the
legend node is belongs to the tree but it is filtered out, invalid model
index is returned.

Unlike :py:func:`QgsLayerTreeModel.legendNode2index()`, calling this
method correctly accounts for mapping the view indexes through the
view's proxy model to the source model.

.. versionadded:: 3.18
%End

    QModelIndex legendNode2sourceIndex( QgsLayerTreeModelLegendNode *legendNode );
%Docstring
Returns index for a given legend node. If the legend node does not
belong to the layer tree, the result is undefined. If the legend node is
belongs to the tree but it is filtered out, invalid model index is
returned.

.. versionadded:: 3.18
%End

    QgsLayerTreeViewDefaultActions *defaultActions();
%Docstring
Gets access to the default actions that may be used with the tree view
%End

    void setMenuProvider( QgsLayerTreeViewMenuProvider *menuProvider /Transfer/ );
%Docstring
Sets provider for context menu. Takes ownership of the instance
%End
    QgsLayerTreeViewMenuProvider *menuProvider() const;
%Docstring
Returns pointer to the context menu provider. May be ``None``
%End

    QgsMapLayer *currentLayer() const;
%Docstring
Returns the currently selected layer, or ``None`` if no layers is
selected.

.. seealso:: :py:func:`setCurrentLayer`
%End

    void setLayerVisible( QgsMapLayer *layer, bool visible );
%Docstring
Convenience methods which sets the visible state of the specified map
``layer``.

.. seealso:: :py:func:`QgsLayerTreeNode.setItemVisibilityChecked`

.. versionadded:: 3.10
%End

    void setCurrentNode( QgsLayerTreeNode *node );
%Docstring
Sets the currently selected ``node``.

If ``node`` is ``None`` then all nodes will be deselected.

.. seealso:: :py:func:`currentNode`

.. versionadded:: 3.40
%End

    void setCurrentLayer( QgsMapLayer *layer );
%Docstring
Sets the currently selected ``layer``.

If ``layer`` is ``None`` then all layers will be deselected.

.. seealso:: :py:func:`currentLayer`
%End

    QgsLayerTreeNode *currentNode() const;
%Docstring
Gets current node. May be ``None``
%End
    QgsLayerTreeGroup *currentGroupNode() const;
%Docstring
Gets current group node. If a layer is current node, the function will
return parent group. May be ``None``.
%End

    QgsLayerTreeModelLegendNode *currentLegendNode() const;
%Docstring
Gets current legend node. May be ``None`` if current node is not a
legend node.
%End

    QList<QgsLayerTreeNode *> selectedNodes( bool skipInternal = false ) const;
%Docstring
Returns the list of selected layer tree nodes.

:param skipInternal: If ``True``, will ignore nodes which have an
                     ancestor in the selection

.. seealso:: :py:func:`selectedLayerNodes`

.. seealso:: :py:func:`selectedLegendNodes`

.. seealso:: :py:func:`selectedLayers`
%End

    QList<QgsLayerTreeLayer *> selectedLayerNodes() const;
%Docstring
Returns the list of selected nodes filtered to just layer nodes
(:py:class:`QgsLayerTreeLayer`).

.. seealso:: :py:func:`selectedNodes`

.. seealso:: :py:func:`selectedLayers`

.. seealso:: :py:func:`selectedLegendNodes`
%End

    QList<QgsMapLayer *> selectedLayers() const;
%Docstring
Returns the list of selected layers.

.. seealso:: :py:func:`selectedNodes`

.. seealso:: :py:func:`selectedLayerNodes`

.. seealso:: :py:func:`selectedLegendNodes`
%End

    QList<QgsLayerTreeModelLegendNode *> selectedLegendNodes() const;
%Docstring
Returns the list of selected legend nodes.

.. seealso:: :py:func:`selectedNodes`

.. seealso:: :py:func:`selectedLayerNodes`

.. versionadded:: 3.32
%End

    QList<QgsMapLayer *> selectedLayersRecursive() const;
%Docstring
Gets list of selected layers, including those that are not directly
selected, but their ancestor groups is selected. If we have a group with
two layers L1, L2 and just the group node is selected, this method
returns L1 and L2, while :py:func:`~QgsLayerTreeView.selectedLayers`
returns an empty list.

.. versionadded:: 3.4
%End

    void addIndicator( QgsLayerTreeNode *node, QgsLayerTreeViewIndicator *indicator );
%Docstring
Adds an indicator to the given layer tree node. Indicators are icons
shown next to layer/group names in the layer tree view. They can be used
to show extra information with tree nodes and they allow user
interaction.

Does not take ownership of the indicator. One indicator object may be
used for multiple layer tree nodes.

.. seealso:: :py:func:`removeIndicator`

.. seealso:: :py:func:`indicators`

.. versionadded:: 3.2
%End

    void removeIndicator( QgsLayerTreeNode *node, QgsLayerTreeViewIndicator *indicator );
%Docstring
Removes a previously added indicator to a layer tree node. Does not
delete the indicator.

.. seealso:: :py:func:`addIndicator`

.. seealso:: :py:func:`indicators`

.. versionadded:: 3.2
%End

    QList<QgsLayerTreeViewIndicator *> indicators( QgsLayerTreeNode *node ) const;
%Docstring
Returns list of indicators associated with a particular layer tree node.

.. seealso:: :py:func:`addIndicator`

.. seealso:: :py:func:`removeIndicator`

.. versionadded:: 3.2
%End

    int layerMarkWidth() const;
%Docstring
Returns width of contextual menu mark, at right of layer node items.

.. seealso:: :py:func:`setLayerMarkWidth`

.. versionadded:: 3.8
%End




    bool showPrivateLayers() const;
%Docstring
Returns the show private layers status

.. versionadded:: 3.18
%End

    bool hideValidLayers() const;
%Docstring
Returns if valid layers should be hidden (i.e. only invalid layers are
shown).

.. seealso:: :py:func:`setHideValidLayers`

.. versionadded:: 3.38
%End

  public slots:
    void refreshLayerSymbology( const QString &layerId );
%Docstring
Force refresh of layer symbology. Normally not needed as the changes of
layer's renderer are monitored by the model
%End

    void expandAllNodes();
%Docstring
Enhancement of QTreeView.expandAll() that also records expanded state in
layer tree nodes
%End

    void collapseAllNodes();
%Docstring
Enhancement of QTreeView.collapseAll() that also records expanded state
in layer tree nodes
%End

    void setLayerMarkWidth( int width );
%Docstring
Set width of contextual menu mark, at right of layer node items.

.. seealso:: :py:func:`layerMarkWidth`

.. versionadded:: 3.8
%End

    void setMessageBar( QgsMessageBar *messageBar );
%Docstring
Set the message bar to display messages from the layer tree

.. versionadded:: 3.14
%End

    void setShowPrivateLayers( bool showPrivate );
%Docstring
Set the show private layers to ``showPrivate``

.. versionadded:: 3.18
%End

    void setHideValidLayers( bool hideValid );
%Docstring
Sets whether valid layers should be hidden (i.e. only invalid layers are
shown).

.. seealso:: :py:func:`setHideValidLayers`

.. versionadded:: 3.38
%End

  signals:
    void currentLayerChanged( QgsMapLayer *layer );
%Docstring
Emitted when a current layer is changed
%End

    void datasetsDropped( QDropEvent *event );
%Docstring
Emitted when datasets are dropped onto the layer tree view
%End

    void contextMenuAboutToShow( QMenu *menu );
%Docstring
Emitted when the context menu is about to show.

Allows customization of the menu.

.. versionadded:: 3.32
%End

  protected:
    virtual void contextMenuEvent( QContextMenuEvent *event );


    void updateExpandedStateFromNode( QgsLayerTreeNode *node );

    QgsMapLayer *layerForIndex( const QModelIndex &index ) const;

    virtual void mouseDoubleClickEvent( QMouseEvent *event );

    virtual void mouseReleaseEvent( QMouseEvent *event );

    virtual void keyPressEvent( QKeyEvent *event );


    virtual void dragEnterEvent( QDragEnterEvent *event );

    virtual void dragMoveEvent( QDragMoveEvent *event );

    virtual void dropEvent( QDropEvent *event );


    virtual void resizeEvent( QResizeEvent *event );


  protected slots:

    void modelRowsInserted( const QModelIndex &index, int start, int end );
    void modelRowsRemoved();

    void updateExpandedStateToNode( const QModelIndex &index );

    void onCurrentChanged();
    void onExpandedChanged( QgsLayerTreeNode *node, bool expanded );
    void onModelReset();

  protected:


};


class QgsLayerTreeViewMenuProvider
{
%Docstring(signature="appended")
Implementation of this interface can be implemented to allow
:py:class:`QgsLayerTreeView` instance to provide custom context menus
(opened upon right-click).

.. seealso:: :py:class:`QgsLayerTreeView`
%End

%TypeHeaderCode
#include "qgslayertreeview.h"
%End
  public:
    virtual ~QgsLayerTreeViewMenuProvider();

    virtual QMenu *createContextMenu() = 0 /Factory/;
%Docstring
Returns a newly created menu instance (or ``None`` on error)
%End
};


/************************************************************************
 * This file has been generated automatically from                      *
 *                                                                      *
 * src/gui/layertree/qgslayertreeview.h                                 *
 *                                                                      *
 * Do not edit manually ! Edit header and run scripts/sipify.py again   *
 ************************************************************************/