mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-15 00:02:52 -04:00
Moved enum
This commit is contained in:
parent
60042b9b79
commit
c66ca0e420
@ -20,6 +20,9 @@ This is the interface for those who want to add entries to the :py:class:`QgsDat
|
||||
%TypeHeaderCode
|
||||
#include "qgssourceselectprovider.h"
|
||||
%End
|
||||
public:
|
||||
static const QMetaObject staticMetaObject;
|
||||
|
||||
public:
|
||||
|
||||
enum Ordering
|
||||
@ -31,6 +34,14 @@ This is the interface for those who want to add entries to the :py:class:`QgsDat
|
||||
OrderOtherProvider,
|
||||
};
|
||||
|
||||
enum class Capability
|
||||
{
|
||||
NoCapabilities,
|
||||
ConfigureFromUri
|
||||
};
|
||||
typedef QFlags<QgsSourceSelectProvider::Capability> Capabilities;
|
||||
|
||||
|
||||
virtual ~QgsSourceSelectProvider();
|
||||
|
||||
virtual QString providerKey() const = 0;
|
||||
@ -75,6 +86,15 @@ the source selects (ascending) using this integer value
|
||||
Create a new instance of :py:class:`QgsAbstractDataSourceWidget` (or ``None``).
|
||||
Caller takes responsibility of deleting created.
|
||||
%End
|
||||
|
||||
virtual Capabilities capabilities();
|
||||
%Docstring
|
||||
Returns the source select provider capabilities.
|
||||
The default implementation returns no capabilites.
|
||||
|
||||
.. versionadded:: 3.38
|
||||
%End
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -38,6 +38,8 @@
|
||||
#include "qgsaddattrdialog.h"
|
||||
#include "qgsabstractdatabaseproviderconnection.h"
|
||||
#include "qgsprovidermetadata.h"
|
||||
#include "qgssourceselectproviderregistry.h"
|
||||
#include "qgssourceselectprovider.h"
|
||||
#include "qgsnewvectortabledialog.h"
|
||||
#include "qgscolordialog.h"
|
||||
#include "qgsdirectoryitem.h"
|
||||
@ -578,13 +580,17 @@ void QgsAppFileItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu *m
|
||||
|
||||
if ( const auto layerItem = qobject_cast< QgsLayerItem * >( item ) )
|
||||
{
|
||||
QAction *openDataSourceManagerAction = new QAction( tr( "Open with datasource manager…" ), menu );
|
||||
connect( openDataSourceManagerAction, &QAction::triggered, this, [ = ]
|
||||
const QList<QgsSourceSelectProvider *> sourceSelectProviders { QgsGui::sourceSelectProviderRegistry()->providersByKey( layerItem->providerKey() ) };
|
||||
if ( ! sourceSelectProviders.isEmpty() && sourceSelectProviders.first()->capabilities().testFlag( QgsSourceSelectProvider::Capability::ConfigureFromUri ) )
|
||||
{
|
||||
QgisApp::instance()->dataSourceManager( layerItem->providerKey(), layerItem->uri() );
|
||||
} );
|
||||
menu->addAction( openDataSourceManagerAction );
|
||||
menu->addSeparator();
|
||||
QAction *openDataSourceManagerAction = new QAction( tr( "Open with datasource manager…" ), menu );
|
||||
connect( openDataSourceManagerAction, &QAction::triggered, this, [ = ]
|
||||
{
|
||||
QgisApp::instance()->dataSourceManager( layerItem->providerKey(), layerItem->uri() );
|
||||
} );
|
||||
menu->addAction( openDataSourceManagerAction );
|
||||
menu->addSeparator();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2746,7 +2746,7 @@ void QgisApp::dataSourceManager( const QString &pageName, const QString &layerUr
|
||||
|
||||
if ( ! layerUri.isEmpty() )
|
||||
{
|
||||
mDataSourceManagerDialog->configureFromUri( layerUri, pageName );
|
||||
mDataSourceManagerDialog->configureFromUri( pageName, layerUri );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -178,6 +178,10 @@ class QgsGdalRasterSourceSelectProvider : public QgsSourceSelectProvider
|
||||
{
|
||||
return new QgsGdalSourceSelect( parent, fl, widgetMode );
|
||||
}
|
||||
QgsSourceSelectProvider::Capabilities capabilities() override
|
||||
{
|
||||
return QgsSourceSelectProvider::Capability::ConfigureFromUri;
|
||||
};
|
||||
};
|
||||
|
||||
//
|
||||
|
@ -175,7 +175,7 @@ void QgsDataSourceManagerDialog::reset()
|
||||
}
|
||||
}
|
||||
|
||||
void QgsDataSourceManagerDialog::configureFromUri( const QString &uri, const QString &pageName )
|
||||
void QgsDataSourceManagerDialog::configureFromUri( const QString &pageName, const QString &uri )
|
||||
{
|
||||
const int pageIdx = mPageProviderKeys.indexOf( pageName );
|
||||
if ( pageIdx != -1 )
|
||||
|
@ -112,7 +112,7 @@ class GUI_EXPORT QgsDataSourceManagerDialog : public QgsOptionsDialogBase, priva
|
||||
* Shows the page \a pageName and configure the source select widget from the layer \a uri.
|
||||
* \since QGIS 3.38
|
||||
*/
|
||||
void configureFromUri( const QString &uri, const QString &pageName );
|
||||
void configureFromUri( const QString &pageName, const QString &uri );
|
||||
|
||||
|
||||
protected:
|
||||
|
@ -34,6 +34,8 @@ class QWidget;
|
||||
*/
|
||||
class GUI_EXPORT QgsSourceSelectProvider
|
||||
{
|
||||
Q_GADGET
|
||||
|
||||
public:
|
||||
|
||||
//! Provider ordering groups
|
||||
@ -46,6 +48,20 @@ class GUI_EXPORT QgsSourceSelectProvider
|
||||
OrderOtherProvider = 5000, //!< Starting point for other providers (e.g. plugin based providers)
|
||||
};
|
||||
|
||||
/**
|
||||
* The Capability enum describes the capabilities of the source select implementation.
|
||||
* \since QGIS 3.38
|
||||
*/
|
||||
enum class Capability : int
|
||||
{
|
||||
NoCapabilities = 0, //!< No capabilities
|
||||
ConfigureFromUri = 1 //!< The source select can be configured from a URI
|
||||
};
|
||||
Q_ENUM( Capability )
|
||||
//!
|
||||
Q_DECLARE_FLAGS( Capabilities, Capability )
|
||||
Q_FLAG( Capabilities )
|
||||
|
||||
virtual ~QgsSourceSelectProvider() = default;
|
||||
|
||||
//! Data Provider key
|
||||
@ -84,6 +100,17 @@ class GUI_EXPORT QgsSourceSelectProvider
|
||||
* Caller takes responsibility of deleting created.
|
||||
*/
|
||||
virtual QgsAbstractDataSourceWidget *createDataSourceWidget( QWidget *parent = nullptr, Qt::WindowFlags fl = Qt::Widget, QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::Embedded ) const = 0 SIP_FACTORY;
|
||||
|
||||
/**
|
||||
* Returns the source select provider capabilities.
|
||||
* The default implementation returns no capabilites.
|
||||
* \since QGIS 3.38
|
||||
*/
|
||||
virtual Capabilities capabilities()
|
||||
{
|
||||
return Capability::NoCapabilities;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user