mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-13 00:03:09 -04:00
Revert api changes in gui registries to fix some tests
This commit is contained in:
parent
ab261b675e
commit
437f635949
@ -25,10 +25,7 @@ QgsGui.instance()->dataItemGuiProviderRegistry().
|
||||
#include "qgsdataitemguiproviderregistry.h"
|
||||
%End
|
||||
public:
|
||||
QgsDataItemGuiProviderRegistry( QgsProviderGuiRegistry *providerGuiRegistry );
|
||||
%Docstring
|
||||
Initializes the registry. Do not create new instances in client code - use QgsGui.dataItemGuiProviderRegistry() instead
|
||||
%End
|
||||
QgsDataItemGuiProviderRegistry();
|
||||
~QgsDataItemGuiProviderRegistry();
|
||||
|
||||
|
||||
@ -47,6 +44,14 @@ is transferred to the registry.
|
||||
%Docstring
|
||||
Removes a ``provider`` implementation from the registry.
|
||||
The provider object is automatically deleted.
|
||||
%End
|
||||
|
||||
void initializeFromProviderGuiRegistry( QgsProviderGuiRegistry *providerGuiRegistry );
|
||||
%Docstring
|
||||
Initializes the registry. The registry needs to be passed explicitly
|
||||
(instead of using singleton) because this gets called from QgsGui constructor.
|
||||
|
||||
.. versionadded:: 3.10
|
||||
%End
|
||||
|
||||
private:
|
||||
|
@ -29,10 +29,7 @@ QgsProjectStorageGuiRegistry is not usually directly created, but rather accesse
|
||||
#include "qgsprojectstorageguiregistry.h"
|
||||
%End
|
||||
public:
|
||||
QgsProjectStorageGuiRegistry( QgsProviderGuiRegistry *providerGuiRegistry );
|
||||
%Docstring
|
||||
Initializes the registry. Do not create new instances in client code - use QgsGui.projectStorageGuiRegistry() instead
|
||||
%End
|
||||
QgsProjectStorageGuiRegistry();
|
||||
~QgsProjectStorageGuiRegistry();
|
||||
|
||||
|
||||
@ -59,6 +56,12 @@ Registers a storage backend and takes ownership of it
|
||||
void unregisterProjectStorage( QgsProjectStorageGuiProvider *storage );
|
||||
%Docstring
|
||||
Unregisters a storage backend and destroys its instance
|
||||
%End
|
||||
|
||||
void initializeFromProviderGuiRegistry( QgsProviderGuiRegistry *providerGuiRegistry );
|
||||
%Docstring
|
||||
Initializes the registry. The registry needs to be passed explicitly
|
||||
(instead of using singleton) because this gets called from QgsGui constructor.
|
||||
%End
|
||||
|
||||
private:
|
||||
|
@ -27,11 +27,7 @@ QgsSourceSelectProviderRegistry is not usually directly created, but rather acce
|
||||
%End
|
||||
public:
|
||||
|
||||
QgsSourceSelectProviderRegistry( QgsProviderGuiRegistry *providerGuiRegistry );
|
||||
%Docstring
|
||||
Constructor for QgsSourceSelectProviderRegistry.
|
||||
%End
|
||||
|
||||
QgsSourceSelectProviderRegistry();
|
||||
~QgsSourceSelectProviderRegistry();
|
||||
|
||||
|
||||
@ -50,6 +46,14 @@ Add a ``provider`` implementation. Takes ownership of the object.
|
||||
Remove ``provider`` implementation from the list (``provider`` object is deleted)
|
||||
|
||||
:return: ``True`` if the provider was actually removed and deleted
|
||||
%End
|
||||
|
||||
void initializeFromProviderGuiRegistry( QgsProviderGuiRegistry *providerGuiRegistry );
|
||||
%Docstring
|
||||
Initializes the registry. The registry needs to be passed explicitly
|
||||
(instead of using singleton) because this gets called from QgsGui constructor.
|
||||
|
||||
.. versionadded:: 3.10
|
||||
%End
|
||||
|
||||
QgsSourceSelectProvider *providerByName( const QString &name );
|
||||
|
@ -19,20 +19,7 @@
|
||||
#include "qgsdataitemguiprovider.h"
|
||||
#include "qgsproviderguiregistry.h"
|
||||
|
||||
QgsDataItemGuiProviderRegistry::QgsDataItemGuiProviderRegistry( QgsProviderGuiRegistry *providerGuiRegistry )
|
||||
{
|
||||
if ( !providerGuiRegistry )
|
||||
return;
|
||||
|
||||
const QStringList providersList = providerGuiRegistry->providerList();
|
||||
|
||||
for ( const QString &key : providersList )
|
||||
{
|
||||
const QList<QgsDataItemGuiProvider *> providerList = providerGuiRegistry->dataItemGuiProviders( key );
|
||||
// the function is a factory - we keep ownership of the returned providers
|
||||
mProviders << providerList;
|
||||
}
|
||||
}
|
||||
QgsDataItemGuiProviderRegistry::QgsDataItemGuiProviderRegistry() = default;
|
||||
|
||||
QgsDataItemGuiProviderRegistry::~QgsDataItemGuiProviderRegistry()
|
||||
{
|
||||
@ -50,3 +37,18 @@ void QgsDataItemGuiProviderRegistry::removeProvider( QgsDataItemGuiProvider *pro
|
||||
if ( index >= 0 )
|
||||
delete mProviders.takeAt( index );
|
||||
}
|
||||
|
||||
void QgsDataItemGuiProviderRegistry::initializeFromProviderGuiRegistry( QgsProviderGuiRegistry *providerGuiRegistry )
|
||||
{
|
||||
if ( !providerGuiRegistry )
|
||||
return;
|
||||
|
||||
const QStringList providersList = providerGuiRegistry->providerList();
|
||||
|
||||
for ( const QString &key : providersList )
|
||||
{
|
||||
const QList<QgsDataItemGuiProvider *> providerList = providerGuiRegistry->dataItemGuiProviders( key );
|
||||
// the function is a factory - we keep ownership of the returned providers
|
||||
mProviders << providerList;
|
||||
}
|
||||
}
|
||||
|
@ -37,8 +37,7 @@ class QgsProviderGuiRegistry;
|
||||
class GUI_EXPORT QgsDataItemGuiProviderRegistry
|
||||
{
|
||||
public:
|
||||
//! Initializes the registry. Do not create new instances in client code - use QgsGui::dataItemGuiProviderRegistry() instead
|
||||
QgsDataItemGuiProviderRegistry( QgsProviderGuiRegistry *providerGuiRegistry );
|
||||
QgsDataItemGuiProviderRegistry();
|
||||
~QgsDataItemGuiProviderRegistry();
|
||||
|
||||
//! QgsDataItemGuiProviderRegistry cannot be copied.
|
||||
@ -63,6 +62,13 @@ class GUI_EXPORT QgsDataItemGuiProviderRegistry
|
||||
*/
|
||||
void removeProvider( QgsDataItemGuiProvider *provider );
|
||||
|
||||
/**
|
||||
* Initializes the registry. The registry needs to be passed explicitly
|
||||
* (instead of using singleton) because this gets called from QgsGui constructor.
|
||||
* \since QGIS 3.10
|
||||
*/
|
||||
void initializeFromProviderGuiRegistry( QgsProviderGuiRegistry *providerGuiRegistry );
|
||||
|
||||
private:
|
||||
#ifdef SIP_RUN
|
||||
QgsDataItemGuiProviderRegistry( const QgsDataItemGuiProviderRegistry &rh );
|
||||
|
@ -184,9 +184,13 @@ QgsGui::QgsGui()
|
||||
|
||||
// provider gui registry initialize QgsProviderRegistry too
|
||||
mProviderGuiRegistry = new QgsProviderGuiRegistry( QgsApplication::pluginPath() );
|
||||
mProjectStorageGuiRegistry = new QgsProjectStorageGuiRegistry( mProviderGuiRegistry );
|
||||
mDataItemGuiProviderRegistry = new QgsDataItemGuiProviderRegistry( mProviderGuiRegistry );
|
||||
mSourceSelectProviderRegistry = new QgsSourceSelectProviderRegistry( mProviderGuiRegistry );
|
||||
mProjectStorageGuiRegistry = new QgsProjectStorageGuiRegistry();
|
||||
mDataItemGuiProviderRegistry = new QgsDataItemGuiProviderRegistry();
|
||||
mSourceSelectProviderRegistry = new QgsSourceSelectProviderRegistry();
|
||||
|
||||
mProjectStorageGuiRegistry->initializeFromProviderGuiRegistry( mProviderGuiRegistry );
|
||||
mDataItemGuiProviderRegistry->initializeFromProviderGuiRegistry( mProviderGuiRegistry );
|
||||
mSourceSelectProviderRegistry->initializeFromProviderGuiRegistry( mProviderGuiRegistry );
|
||||
|
||||
mEditorWidgetRegistry = new QgsEditorWidgetRegistry();
|
||||
mShortcutsManager = new QgsShortcutsManager();
|
||||
|
@ -19,23 +19,7 @@
|
||||
#include "qgsprojectstorageguiprovider.h"
|
||||
#include "qgsproviderguiregistry.h"
|
||||
|
||||
QgsProjectStorageGuiRegistry::QgsProjectStorageGuiRegistry( QgsProviderGuiRegistry *providerGuiRegistry )
|
||||
{
|
||||
if ( !providerGuiRegistry )
|
||||
return;
|
||||
|
||||
const QStringList providersList = providerGuiRegistry->providerList();
|
||||
|
||||
for ( const QString &key : providersList )
|
||||
{
|
||||
const QList<QgsProjectStorageGuiProvider *> providerList = providerGuiRegistry->projectStorageGuiProviders( key );
|
||||
// the function is a factory - we keep ownership of the returned providers
|
||||
for ( QgsProjectStorageGuiProvider *provider : providerList )
|
||||
{
|
||||
mBackends[key] = provider;
|
||||
}
|
||||
}
|
||||
}
|
||||
QgsProjectStorageGuiRegistry::QgsProjectStorageGuiRegistry() = default;
|
||||
|
||||
QgsProjectStorageGuiRegistry::~QgsProjectStorageGuiRegistry()
|
||||
{
|
||||
@ -73,3 +57,20 @@ void QgsProjectStorageGuiRegistry::unregisterProjectStorage( QgsProjectStorageGu
|
||||
{
|
||||
delete mBackends.take( storage->type() );
|
||||
}
|
||||
|
||||
void QgsProjectStorageGuiRegistry::initializeFromProviderGuiRegistry( QgsProviderGuiRegistry *providerGuiRegistry )
|
||||
{
|
||||
if ( !providerGuiRegistry )
|
||||
return;
|
||||
|
||||
const QStringList providersList = providerGuiRegistry->providerList();
|
||||
for ( const QString &key : providersList )
|
||||
{
|
||||
const QList<QgsProjectStorageGuiProvider *> providerList = providerGuiRegistry->projectStorageGuiProviders( key );
|
||||
// the function is a factory - we keep ownership of the returned providers
|
||||
for ( QgsProjectStorageGuiProvider *provider : providerList )
|
||||
{
|
||||
mBackends[key] = provider;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -44,8 +44,7 @@ class QgsProviderGuiRegistry;
|
||||
class GUI_EXPORT QgsProjectStorageGuiRegistry
|
||||
{
|
||||
public:
|
||||
//! Initializes the registry. Do not create new instances in client code - use QgsGui::projectStorageGuiRegistry() instead
|
||||
QgsProjectStorageGuiRegistry( QgsProviderGuiRegistry *providerGuiRegistry );
|
||||
QgsProjectStorageGuiRegistry();
|
||||
~QgsProjectStorageGuiRegistry();
|
||||
|
||||
//! QgsProjectStorageGuiRegistry cannot be copied.
|
||||
@ -68,6 +67,12 @@ class GUI_EXPORT QgsProjectStorageGuiRegistry
|
||||
//! Unregisters a storage backend and destroys its instance
|
||||
void unregisterProjectStorage( QgsProjectStorageGuiProvider *storage );
|
||||
|
||||
/**
|
||||
* Initializes the registry. The registry needs to be passed explicitly
|
||||
* (instead of using singleton) because this gets called from QgsGui constructor.
|
||||
*/
|
||||
void initializeFromProviderGuiRegistry( QgsProviderGuiRegistry *providerGuiRegistry );
|
||||
|
||||
private:
|
||||
#ifdef SIP_RUN
|
||||
QgsProjectStorageGuiRegistry( const QgsProjectStorageGuiRegistry &rh );
|
||||
|
@ -19,19 +19,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
QgsSourceSelectProviderRegistry::QgsSourceSelectProviderRegistry( QgsProviderGuiRegistry *providerGuiRegistry )
|
||||
{
|
||||
const QStringList providersList = providerGuiRegistry->providerList();
|
||||
for ( const QString &key : providersList )
|
||||
{
|
||||
const QList<QgsSourceSelectProvider *> providerList = providerGuiRegistry->sourceSelectProviders( key );
|
||||
// the function is a factory - we keep ownership of the returned providers
|
||||
for ( auto provider : providerList )
|
||||
{
|
||||
addProvider( provider );
|
||||
}
|
||||
}
|
||||
}
|
||||
QgsSourceSelectProviderRegistry::QgsSourceSelectProviderRegistry() = default;
|
||||
|
||||
QgsSourceSelectProviderRegistry::~QgsSourceSelectProviderRegistry()
|
||||
{
|
||||
@ -63,6 +51,24 @@ bool QgsSourceSelectProviderRegistry::removeProvider( QgsSourceSelectProvider *p
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void QgsSourceSelectProviderRegistry::initializeFromProviderGuiRegistry( QgsProviderGuiRegistry *providerGuiRegistry )
|
||||
{
|
||||
if ( !providerGuiRegistry )
|
||||
return;
|
||||
|
||||
const QStringList providersList = providerGuiRegistry->providerList();
|
||||
for ( const QString &key : providersList )
|
||||
{
|
||||
const QList<QgsSourceSelectProvider *> providerList = providerGuiRegistry->sourceSelectProviders( key );
|
||||
// the function is a factory - we keep ownership of the returned providers
|
||||
for ( auto provider : providerList )
|
||||
{
|
||||
addProvider( provider );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QgsSourceSelectProvider *QgsSourceSelectProviderRegistry::providerByName( const QString &name )
|
||||
{
|
||||
const QList<QgsSourceSelectProvider *> providerList = providers();
|
||||
|
@ -42,11 +42,7 @@ class GUI_EXPORT QgsSourceSelectProviderRegistry
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor for QgsSourceSelectProviderRegistry.
|
||||
*/
|
||||
QgsSourceSelectProviderRegistry( QgsProviderGuiRegistry *providerGuiRegistry );
|
||||
|
||||
QgsSourceSelectProviderRegistry();
|
||||
~QgsSourceSelectProviderRegistry();
|
||||
|
||||
//! QgsDataItemProviderRegistry cannot be copied.
|
||||
@ -66,6 +62,13 @@ class GUI_EXPORT QgsSourceSelectProviderRegistry
|
||||
*/
|
||||
bool removeProvider( QgsSourceSelectProvider *provider SIP_TRANSFER );
|
||||
|
||||
/**
|
||||
* Initializes the registry. The registry needs to be passed explicitly
|
||||
* (instead of using singleton) because this gets called from QgsGui constructor.
|
||||
* \since QGIS 3.10
|
||||
*/
|
||||
void initializeFromProviderGuiRegistry( QgsProviderGuiRegistry *providerGuiRegistry );
|
||||
|
||||
//! Returns a provider by \a name or NULLPTR if not found
|
||||
QgsSourceSelectProvider *providerByName( const QString &name );
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user