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
Move parts of QgsLocatorFilter to core #8404
Conversation
6b2ab23
to
d2fed80
Compare
@nyalldawson I have succesfully tested this change both in QGIS core and QField. Do you want to review before I merge? |
Yes I'd like to review please |
src/core/qgsmapcanvasinterface.h
Outdated
* core components of a map canvas. | ||
* \since QGIS 3.6 | ||
*/ | ||
class CORE_EXPORT QgsMapCanvasInterface |
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 don't like the naming of this class -- it's dangerously bleeding gui specific classes into core. What about something more generic like "QgsMapDisplayInterface" or "QgsRenderedMapInterface"? QgsLayoutItemMap could implement this interface too.
* to be used in a locator widget. | ||
* \since QGIS 3.6 | ||
*/ | ||
class CORE_EXPORT QgsLocatorWidgetCore : public QObject |
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 also don't like the naming of this class. If it's widget specific it doesn't belong in core. How about "QgsLocatorModelBridge" ? (really should be QgsLocatorLocatorModelBridge, but that's horrible).
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.
Perfect for me
//! Constructor of QgsLocatorWidgetCore | ||
explicit QgsLocatorWidgetCore( QObject *parent = nullptr ); | ||
|
||
//! Set the map canvas interface |
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.
Add note about ownership/lifetime
//! Set the map canvas interface | ||
void setMapCanvasInterface( QgsMapCanvasInterface *canvasInterface ); | ||
|
||
//! Perform a search |
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.
Better dox here -- is this blocking? If not, what happens to existing searches? Does it block until they are canceled?
Q_INVOKABLE QgsLocatorProxyModel *proxyModel() const; | ||
|
||
//! Returns true if some text to be search is pending in the queue | ||
bool hasQueueRequested() const; |
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.
Does this need to be public?
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.
This is used in the widget. If I could inherit not. Or I make a friend class?
I am not sold on this approach and I wonder if we really need Alternatives:
|
@wonder-sk having a pointer and returning a const pointer would be perfect. But is that an API break? Or we make a mapSettingsV2? If the approach is fine for @nyalldawson my vote is for this one @nyalldawson thanks for the review and the naming proposals! |
Maybe we mean different things... What I meant in the first alternative was really just to have |
If the only reason we need new map canvas interface is to be able to access
or
|
One of the tricky things here is the identity vs value disucssion. So far QgsMapSettings is treated as value, so it is copied around. Starting to pass around long living pointers to QgsMapSettings around adds some complexity to the current approach. Some things to keep in mind:
|
@wonder-sk From the discussion, the interface seems the safest and most flexible approach. Why are you not sold to it? 💰? |
The interface is not really that flexible in my opinion. It can't have signals/slots in the future because it cannot be derived from QObject because QgsMapCanvas already derives from QObject. Plus generally I try to avoid inheritance, especially multiple inheritance because it often fixes API design too much (and IIRC the SIP casting bugs are related to multiple inheritance too). I think @m-kuhn has good point with identity vs value - which one do we want here? If we need identity (i.e. QObject-based) with signals, then we should probably take QgsQuickMapSettings and put it into qgis_core (and rename it to something like QgsMapSettingsController) because that is essentially it. And QgsMapCanvas would just forward signals from it. In my opinion the safest is the second alternative: "rather than pulling map settings from an interface, why not push required bits of map settings when they change" |
Looks like it can, but it's relying on old style signals. I'm not sure we really want that https://stackoverflow.com/a/18113601/2319028 but I also can't think of a modern approach. If we are ok with that it would be my preferred approach. If...
That statement sounds a bit too general to me ;) While certainly often abused I really like multiple inheritance when it's done in a (java) interface style with only virtual methods but no member variables.
They both work for me too. The latter one has a risk of a connection-orgy for cases where a lot of "required bits" are needed. |
Thinking about it again, the proposal to "rather than pulling map settings from an interface, why not push required bits of map settings when they change" sounds actually good. It's just crs and extents that are under discussion from what I can see. the QgsMapSettingsController can still be implemented in the future. |
This reverts commit 79c5b35.
remove remaining bits of interface
e138f69
to
7c73942
Compare
this is ready for next round of reviews... |
for me it is +1 now (a.k.a. I'm sold! 💰) but I haven't really looked into the locator stuff... thanks a lot for updating the PR! |
@nyalldawson do you want to look at the locator part again or you're happy with this? |
I haven't looked yet sorry, give me 24 hours. |
Looks good to me |
To create a locator item in QML without duplicating much of the code, part of
QgsLocatorWidget
was moved to core.This PR also creates a
QgsMapCanvasInterface
to access core component of map canvas (namely map settings).Sadly, I could not use multiple inheritance (you cannot inherit multiple
QObject
) since the core part needs some signal connections. Therefore,QgsLocatorWidget
has aQgsLocatorWidgetCore
member.