Skip to content

Commit

Permalink
Move browser proxy model to core library and expose as stable API
Browse files Browse the repository at this point in the history
This class is useful for plugins and other areas of QGIS code which
want to expose a limited browser interface (e.g. a vector layer
only type layer picker)

Also add unit tests
  • Loading branch information
nyalldawson committed Oct 18, 2018
1 parent 3543d34 commit 5d9d903
Show file tree
Hide file tree
Showing 12 changed files with 830 additions and 212 deletions.
149 changes: 149 additions & 0 deletions python/core/auto_generated/qgsbrowserproxymodel.sip.in
@@ -0,0 +1,149 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/qgsbrowserproxymodel.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/



class QgsBrowserProxyModel : QSortFilterProxyModel
{
%Docstring
A QSortFilterProxyModel subclass for filtering and sorting browser model items.

.. versionadded:: 3.4
%End

%TypeHeaderCode
#include "qgsbrowserproxymodel.h"
%End
public:

enum FilterSyntax
{
Normal,
Wildcards,
RegularExpression,
};

explicit QgsBrowserProxyModel( QObject *parent /TransferThis/ = 0 );
%Docstring
Constructor for QgsBrowserProxyModel, with the specified ``parent`` object.
%End

void setBrowserModel( QgsBrowserModel *model );
%Docstring
Sets the underlying browser ``model``.

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

QgsBrowserModel *browserModel();
%Docstring
Returns the underlying browser model.

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

QgsDataItem *dataItem( const QModelIndex &index ) const;
%Docstring
Returns the data item at the specified proxy ``index``, or a None if no item
exists at the index.
%End

void setFilterSyntax( FilterSyntax syntax );
%Docstring
Sets the filter ``syntax``.

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

FilterSyntax filterSyntax() const;
%Docstring
Returns the filter syntax.

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

void setFilterString( const QString &filter );
%Docstring
Sets the ``filter`` string to use when filtering items in the model.

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

QString filterString() const;
%Docstring
Returns the filter string used when filtering items in the model.

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

void setFilterCaseSensitivity( Qt::CaseSensitivity sensitivity );
%Docstring
Sets whether item filtering should be case sensitive.

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

Qt::CaseSensitivity caseSensitivity() const;
%Docstring
Returns whether item filtering is case sensitive.

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

bool filterByLayerType() const;
%Docstring
Returns true if the model is filtered by map layer type.

.. seealso:: :py:func:`layerType`

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

void setFilterByLayerType( bool enabled );
%Docstring
Sets whether the model is filtered by map layer type.

.. seealso:: :py:func:`filterByLayerType`

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

QgsMapLayer::LayerType layerType() const;
%Docstring
Returns the layer type to filter the model by. This is only used if
filterByLayerType() is true.

.. seealso:: :py:func:`setLayerType`

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

void setLayerType( QgsMapLayer::LayerType type );
%Docstring
Sets the layer ``type`` to filter the model by. This is only used if
filterByLayerType() is true.

.. seealso:: :py:func:`layerType`

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

protected:

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


};

/************************************************************************
* This file has been generated automatically from *
* *
* src/core/qgsbrowserproxymodel.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
1 change: 1 addition & 0 deletions python/core/core_auto.sip
Expand Up @@ -312,6 +312,7 @@
%Include auto_generated/qgsanimatedicon.sip
%Include auto_generated/qgsauxiliarystorage.sip
%Include auto_generated/qgsbrowsermodel.sip
%Include auto_generated/qgsbrowserproxymodel.sip
%Include auto_generated/qgscoordinatereferencesystem.sip
%Include auto_generated/qgscredentials.sip
%Include auto_generated/qgsdataitem.sip
Expand Down
2 changes: 2 additions & 0 deletions src/core/CMakeLists.txt
Expand Up @@ -151,6 +151,7 @@ SET(QGIS_CORE_SRCS
qgsauxiliarystorage.cpp
qgsbearingutils.cpp
qgsbrowsermodel.cpp
qgsbrowserproxymodel.cpp
qgscachedfeatureiterator.cpp
qgscacheindex.cpp
qgscacheindexfeatureid.cpp
Expand Down Expand Up @@ -590,6 +591,7 @@ SET(QGIS_CORE_MOC_HDRS
qgsanimatedicon.h
qgsauxiliarystorage.h
qgsbrowsermodel.h
qgsbrowserproxymodel.h
qgscoordinatereferencesystem.h
qgscredentials.h
qgsdataitem.h
Expand Down

0 comments on commit 5d9d903

Please sign in to comment.