Skip to content

Commit

Permalink
Merge pull request #45962 from 3nids/ux-db-table-filter
Browse files Browse the repository at this point in the history
improve filtering of layers in DB dialogs
  • Loading branch information
3nids committed Nov 10, 2021
2 parents 8a97de5 + a4439c1 commit 1bb212e
Show file tree
Hide file tree
Showing 40 changed files with 942 additions and 1,181 deletions.
@@ -0,0 +1,51 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/providers/qgsabstractdbtablemodel.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/




class QgsAbstractDbTableModel : QStandardItemModel
{
%Docstring(signature="appended")
The :py:class:`QgsAbstractDbTableModel` class is a pure virtual model class for results in a database source widget selector

.. versionadded:: 3.24
%End

%TypeHeaderCode
#include "qgsabstractdbtablemodel.h"
%End
public:
explicit QgsAbstractDbTableModel( QObject *parent = 0 );
%Docstring
Constructor
%End

virtual QStringList columns() const = 0;
%Docstring
Returns the list of columns in the table
%End

virtual int defaultSearchColumn() const = 0;
%Docstring
Returns the index of the column used by default to filter the results (probably the table name column if it exists)
%End

virtual bool searchableColumn( int column ) const;
%Docstring
Returns if the column should be searchable at the given index
%End
};

/************************************************************************
* This file has been generated automatically from *
* *
* src/core/providers/qgsabstractdbtablemodel.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
4 changes: 3 additions & 1 deletion python/core/auto_generated/qgsdbfilterproxymodel.sip.in
Expand Up @@ -10,12 +10,14 @@



class QgsDatabaseFilterProxyModel: QSortFilterProxyModel
class QgsDatabaseFilterProxyModel : QSortFilterProxyModel /Deprecated/
{
%Docstring(signature="appended")
A class that implements a custom filter and can be used
as a proxy for :py:class:`QgsDbTableModel`

.. deprecated:: QGIS 3.24

.. versionadded:: 3.0
%End

Expand Down
1 change: 1 addition & 0 deletions python/core/core_auto.sip
Expand Up @@ -529,6 +529,7 @@
%Include auto_generated/project/qgsprojectutils.sip
%Include auto_generated/project/qgsprojectversion.sip
%Include auto_generated/project/qgsprojectviewsettings.sip
%Include auto_generated/providers/qgsabstractdbtablemodel.sip
%Include auto_generated/providers/qgsabstractdatabaseproviderconnection.sip
%Include auto_generated/providers/qgsabstractproviderconnection.sip
%Include auto_generated/providers/qgsdataprovider.sip
Expand Down
49 changes: 49 additions & 0 deletions python/gui/auto_generated/providers/qgsdbsourceselectbase.sip.in
@@ -0,0 +1,49 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/providers/qgsdbsourceselectbase.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/





class QgsDbSourceSelectBase : QgsAbstractDataSourceWidget, protected Ui::QgsDbSourceSelectBase
{
%Docstring(signature="appended")
The :py:class:`QgsDbSourceSelectBase` class is a base class for database source widget selector

.. versionadded:: 3.24
%End

%TypeHeaderCode
#include "qgsdbsourceselectbase.h"
%End
public:
QgsDbSourceSelectBase( QWidget *parent = 0, Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags, QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::None );
%Docstring
Constructor
%End

protected:
void setSourceModel( QgsAbstractDbTableModel *model );
%Docstring
Sets the source model for the widget
%End

QSortFilterProxyModel *proxyModel();
%Docstring
Returns the proxy model used to filter the results
%End

};

/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/providers/qgsdbsourceselectbase.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
1 change: 1 addition & 0 deletions python/gui/gui_auto.sip
Expand Up @@ -378,6 +378,7 @@
%Include auto_generated/processing/models/qgsmodelgraphicitem.sip
%Include auto_generated/processing/models/qgsmodelgraphicsscene.sip
%Include auto_generated/processing/models/qgsmodelgraphicsview.sip
%Include auto_generated/providers/qgsdbsourceselectbase.sip
%Include auto_generated/raster/qgscolorrampshaderwidget.sip
%Include auto_generated/raster/qgshillshaderendererwidget.sip
%Include auto_generated/raster/qgsmultibandcolorrendererwidget.sip
Expand Down
1 change: 1 addition & 0 deletions src/core/CMakeLists.txt
Expand Up @@ -1565,6 +1565,7 @@ set(QGIS_CORE_HDRS
project/qgsprojectversion.h
project/qgsprojectviewsettings.h

providers/qgsabstractdbtablemodel.h
providers/qgsabstractdatabaseproviderconnection.h
providers/qgsabstractproviderconnection.h
providers/qgsdataprovider.h
Expand Down
47 changes: 47 additions & 0 deletions src/core/providers/qgsabstractdbtablemodel.h
@@ -0,0 +1,47 @@
/***************************************************************************
qgsabstractdbtablemodel.h
--------------------------------------
Date : 08.11.2021
Copyright : (C) 2021 Denis Rouzaud
Email : denis@opengis.ch
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

#ifndef QGSABSTRACTDBTABLEMODEL_H
#define QGSABSTRACTDBTABLEMODEL_H

#include "qgis_core.h"

#include <QStandardItemModel>

/**
* \ingroup gui
* \brief The QgsAbstractDbTableModel class is a pure virtual model class for results in a database source widget selector
* \since QGIS 3.24
*/
class CORE_EXPORT QgsAbstractDbTableModel : public QStandardItemModel
{
Q_OBJECT
public:
//! Constructor
explicit QgsAbstractDbTableModel( QObject *parent = nullptr )
: QStandardItemModel( parent )
{}

//! Returns the list of columns in the table
virtual QStringList columns() const = 0;

//! Returns the index of the column used by default to filter the results (probably the table name column if it exists)
virtual int defaultSearchColumn() const = 0;

//! Returns if the column should be searchable at the given index
virtual bool searchableColumn( int column ) const {Q_UNUSED( column ) return true;}
};

#endif // QGSABSTRACTDBTABLEMODEL_H
5 changes: 3 additions & 2 deletions src/core/qgsdbfilterproxymodel.h
Expand Up @@ -28,9 +28,10 @@
* \ingroup core
* \brief A class that implements a custom filter and can be used
* as a proxy for QgsDbTableModel
* \since QGIS 3.0
* \deprecated since QGIS 3.24
* \since QGIS 3.0 QSortFilterProxyModel with native recursive filtering can be used instead
*/
class CORE_EXPORT QgsDatabaseFilterProxyModel: public QSortFilterProxyModel
class CORE_EXPORT Q_DECL_DEPRECATED QgsDatabaseFilterProxyModel : public QSortFilterProxyModel SIP_DEPRECATED
{
Q_OBJECT

Expand Down
2 changes: 2 additions & 0 deletions src/gui/CMakeLists.txt
Expand Up @@ -361,6 +361,7 @@ set(QGIS_GUI_SRCS
processing/models/qgsmodelviewtooltemporarymousepan.cpp
processing/models/qgsmodelviewtoolzoom.cpp

providers/qgsdbsourceselectbase.cpp
providers/qgspointcloudproviderguimetadata.cpp
providers/qgspointcloudsourceselect.cpp

Expand Down Expand Up @@ -1180,6 +1181,7 @@ set(QGIS_GUI_HDRS
processing/models/qgsmodelviewtooltemporarymousepan.h
processing/models/qgsmodelviewtoolzoom.h

providers/qgsdbsourceselectbase.h
providers/qgspointcloudsourceselect.h
providers/qgspointcloudproviderguimetadata.h

Expand Down

0 comments on commit 1bb212e

Please sign in to comment.