forked from qgis/QGIS
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[core] Introduce QgsProfileSourceRegistry #41
Open
gacarrillor
wants to merge
9
commits into
master
Choose a base branch
from
profile_source_registry
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
65e5038
[core] Introduce QgsProfileSourceRegistry to store sources other than…
gacarrillor a383d84
Update SIP file for PyQt6
gacarrillor 2190f1b
Let the elevation profile canvas use the profile source registry
gacarrillor 66eeff8
[core] Allow profile widget export profile sources other than layers
gacarrillor a9e973e
[layout] Allow profiles to be displayed in layouts even if their sour…
gacarrillor 695953e
[profile] Address review
gacarrillor 2378f24
[tests] Add tests for QgsProfileSourceRegistry
gacarrillor 1eb7805
[tests] Fix layout test by using standard QGIS test font
gacarrillor 1986f12
[tests] Fixes for Qt6
gacarrillor File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
60 changes: 60 additions & 0 deletions
60
python/PyQt6/core/auto_generated/elevation/qgsprofilesourceregistry.sip.in
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/core/elevation/qgsprofilesourceregistry.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ | ||
|
||
|
||
|
||
|
||
|
||
|
||
class QgsProfileSourceRegistry | ||
{ | ||
%Docstring(signature="appended") | ||
Registry of profile sources used by :py:class:`QgsProfilePlotRenderer` | ||
|
||
:py:class:`QgsProfileSourceRegistry` is not usually directly created, but rather accessed through | ||
:py:func:`QgsApplication.profileSourceRegistry()`. | ||
|
||
.. versionadded:: 3.38 | ||
%End | ||
|
||
%TypeHeaderCode | ||
#include "qgsprofilesourceregistry.h" | ||
%End | ||
public: | ||
|
||
QgsProfileSourceRegistry(); | ||
%Docstring | ||
Constructor - creates a registry of profile sources | ||
%End | ||
|
||
~QgsProfileSourceRegistry(); | ||
|
||
QList< QgsAbstractProfileSource * > profileSources() const; | ||
%Docstring | ||
Returns a list of registered profile sources | ||
%End | ||
|
||
void registerProfileSource( QgsAbstractProfileSource *source /Transfer/ ); | ||
%Docstring | ||
Registers a profile ``source`` and takes ownership of it | ||
%End | ||
|
||
void unregisterProfileSource( QgsAbstractProfileSource *source ); | ||
%Docstring | ||
Unregisters a profile ``source`` and destroys its instance | ||
%End | ||
|
||
}; | ||
|
||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/core/elevation/qgsprofilesourceregistry.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
python/core/auto_generated/elevation/qgsprofilesourceregistry.sip.in
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/core/elevation/qgsprofilesourceregistry.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ | ||
|
||
|
||
|
||
|
||
|
||
|
||
class QgsProfileSourceRegistry | ||
{ | ||
%Docstring(signature="appended") | ||
Registry of profile sources used by :py:class:`QgsProfilePlotRenderer` | ||
|
||
:py:class:`QgsProfileSourceRegistry` is not usually directly created, but rather accessed through | ||
:py:func:`QgsApplication.profileSourceRegistry()`. | ||
|
||
.. versionadded:: 3.38 | ||
%End | ||
|
||
%TypeHeaderCode | ||
#include "qgsprofilesourceregistry.h" | ||
%End | ||
public: | ||
|
||
QgsProfileSourceRegistry(); | ||
%Docstring | ||
Constructor - creates a registry of profile sources | ||
%End | ||
|
||
~QgsProfileSourceRegistry(); | ||
|
||
QList< QgsAbstractProfileSource * > profileSources() const; | ||
%Docstring | ||
Returns a list of registered profile sources | ||
%End | ||
|
||
void registerProfileSource( QgsAbstractProfileSource *source /Transfer/ ); | ||
%Docstring | ||
Registers a profile ``source`` and takes ownership of it | ||
%End | ||
|
||
void unregisterProfileSource( QgsAbstractProfileSource *source ); | ||
%Docstring | ||
Unregisters a profile ``source`` and destroys its instance | ||
%End | ||
|
||
}; | ||
|
||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/core/elevation/qgsprofilesourceregistry.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/*************************************************************************** | ||
qgsprofilesourceregistry.cpp | ||
-------------------------------------- | ||
Date : April 2024 | ||
Copyright : (C) 2024 by Germán Carrillo | ||
Email : german at opengis dot 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. * | ||
* * | ||
***************************************************************************/ | ||
#include "qgsprofilesourceregistry.h" | ||
|
||
#include "qgsabstractprofilesource.h" | ||
|
||
QgsProfileSourceRegistry::QgsProfileSourceRegistry() | ||
{ | ||
|
||
} | ||
|
||
QgsProfileSourceRegistry::~QgsProfileSourceRegistry() | ||
{ | ||
qDeleteAll( mSources ); | ||
} | ||
|
||
QList< QgsAbstractProfileSource * > QgsProfileSourceRegistry::profileSources() const | ||
{ | ||
return mSources; | ||
} | ||
|
||
void QgsProfileSourceRegistry::registerProfileSource( QgsAbstractProfileSource *profileSource ) | ||
{ | ||
if ( !mSources.contains( profileSource ) ) | ||
mSources.append( profileSource ); | ||
} | ||
|
||
void QgsProfileSourceRegistry::unregisterProfileSource( QgsAbstractProfileSource *profileSource ) | ||
{ | ||
const int index = mSources.indexOf( profileSource ); | ||
if ( index >= 0 ) | ||
delete mSources.takeAt( index ); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/*************************************************************************** | ||
qgsprofilesourceregistry.h | ||
-------------------------------------- | ||
Date : April 2024 | ||
Copyright : (C) 2024 by Germán Carrillo | ||
Email : german at opengis dot 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 QGSPROFILESOURCEREGISTRY_H | ||
#define QGSPROFILESOURCEREGISTRY_H | ||
|
||
#include "qgis_core.h" | ||
#include "qgis_sip.h" | ||
|
||
class QgsAbstractProfileSource; | ||
|
||
#include <QList> | ||
|
||
|
||
/** | ||
* \ingroup core | ||
* \brief Registry of profile sources used by QgsProfilePlotRenderer | ||
* | ||
* QgsProfileSourceRegistry is not usually directly created, but rather accessed through | ||
* QgsApplication::profileSourceRegistry(). | ||
* | ||
* \since QGIS 3.38 | ||
*/ | ||
class CORE_EXPORT QgsProfileSourceRegistry | ||
{ | ||
public: | ||
|
||
/** | ||
* Constructor - creates a registry of profile sources | ||
*/ | ||
QgsProfileSourceRegistry(); | ||
|
||
/** | ||
* Destructor | ||
*/ | ||
~QgsProfileSourceRegistry(); | ||
|
||
/** | ||
* Returns a list of registered profile sources | ||
*/ | ||
QList< QgsAbstractProfileSource * > profileSources() const; | ||
|
||
/** | ||
* Registers a profile \a source and takes ownership of it | ||
*/ | ||
void registerProfileSource( QgsAbstractProfileSource *source SIP_TRANSFER ); | ||
|
||
/** | ||
* Unregisters a profile \a source and destroys its instance | ||
*/ | ||
void unregisterProfileSource( QgsAbstractProfileSource *source ); | ||
|
||
private: | ||
QList< QgsAbstractProfileSource * > mSources; | ||
}; | ||
|
||
#endif // QGSPROFILESOURCEREGISTRY_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure if the registry should return all the sources.
Shouldn't it return a clone of a source if you ask for a given id?
That's the way other registries are working
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I took QgsExternalStorageRegistry as a basis, but I guess I should've had a look at other registries as well.
The rationale behind this is that we need to get the full list in order to iterate the sources in
QgsElevationProfileCanvas
, see https://github.com/gacarrillor/QGIS/pull/41/files#diff-7858eaf011cbfda84a6f705b8e0c0f64b95b113bf9a602d2fe6aa51548495862R848