[QGIS-Developer] MetaSearch provider connections in master

Alessandro Pasotti apasotti at gmail.com
Mon Nov 13 07:32:57 PST 2017


On Mon, Nov 13, 2017 at 4:24 PM, Tom Kralidis <tomkralidis at gmail.com> wrote:

> On Mon, Nov 13, 2017 at 10:17 AM, Alessandro Pasotti <apasotti at gmail.com>
> wrote:
> > On Mon, Nov 13, 2017 at 3:59 PM, Tom Kralidis <tomkralidis at gmail.com>
> wrote:
> >>
> >> On Mon, Nov 13, 2017 at 9:18 AM, Alessandro Pasotti <apasotti at gmail.com
> >
> >> wrote:
> >> > On Mon, Nov 13, 2017 at 3:06 PM, Tom Kralidis <tomkralidis at gmail.com>
> >> > wrote:
> >> >>
> >> >> Hi devs:
> >> >>
> >> >> Given https://issues.qgis.org/issues/17347 I'm working on fixing
> >> >> MetaSearch
> >> >> provider connections in master. The core part of the code is
> currently
> >> >> at
> >> >> [1]. A
> >> >> standalone example can be found at [2].  Result is that the WMS/WMTS
> >> >> provider
> >> >> opens connecting to the selected WMS/WMTS (good).  When clicking
> 'Ok',
> >> >> 'Close',
> >> >> or 'Add', the WMS/WMTS layer is added (expecting 'Close' to simply
> >> >> close the dialog
> >> >> and 'Ok' to add the layer and then close).  Finally clicking the 'X'
> >> >> (top right) closes
> >> >> the dialog as expected.
> >> >>
> >> >> - are there other slots to call instead?
> >> >> - should the Data Source Manager be used instead [3]?  Are there
> plans
> >> >> for providing
> >> >> Python binding to this?
>
>> >
> >> >
> >> >
> >> > I can't tell if it's a good idea, but you can definitely add whatever
> >> > you
> >> > want to the DataSourceManager dialog with plain python:
> >> >
> >> > class ConcreteDataSourceWidget(QgsAbstractDataSourceWidget):
> >> >     pass
> >> >
> >> > class ConcreteSourceSelectProvider(QgsSourceSelectProvider):
> >> >
> >> >     def providerKey(self):
> >> >         return "MyTestProviderKey"
> >> >
> >> >     def text(self):
> >> >         return "MyTestProviderText"
> >> >
> >> >     def icon(self):
> >> >         return QIcon()
> >> >
> >> >     def createDataSourceWidget(self):
> >> >         return ConcreteDataSourceWidget()
> >> >
> >> >     def ordering(self):
> >> >         return 1
> >> >
> >> > registry = QgsSourceSelectProviderRegistry()
> >> > registry.addProvider(ConcreteSourceSelectProvider())
> >> >
> >> > Note that the DataSourceManager dialog is created when QGIS starts,
> you
> >> > will
> >> > want to register your provider early in the startup process, for now,
> >> > there
> >> > is no way to refresh the dialog after it has been constructed.
> >> >
> >>
> >> Thanks Alessandro.  Is this example to add a provider type?  MetaSearch
> >> simply wants to open a given existing provider dialog, open based on a
> >> given
> >> provider type and let the user interact from there.
> >>
> >> ..Tom
> >
> >
> >
> > Yes, that's the way to add a new "provider" (it does not really need to
> be a
> > provider) to the items in the data source manager dialog.
> >
> > Maybe you wanted to use this:
> > http://qgis.org/api/classQgsDataSourceManagerDialog.html#
> a6b9046d38467a13ec321a70166bff289
> >
>
> Thanks Alessandro.  Is QgsDataSourceManagerDialog planned to be
> available via Python?  See:
>
> http://qgis.org/api/classQgsDataSourceManagerDialog.html (docs say not
> available in Python
> bindings)
>
>

Yes, that was planned. The idea was to build a generic re-usable widget to
select data sources.

But you are probably talking about exposing it through iface, correct?





>
> > Btw you can also get the individual source selects from provider
> registry:
> > QgsProviderRegistry.instance().createSelectionWidget('ogr').show()
> >
>
> This is exactly what MetaSearch is doing currently which results in the
> issues originally mentioned.
>
> ..Tom
>
> >
> >
> > Cheers.
> >
> >>
> >> >
> >> >
> >> >
> >> >>
> >> >>
> >> >> Thanks
> >> >>
> >> >> ..Tom
> >> >>
> >> >> [1]
> >> >>
> >> >> https://github.com/qgis/QGIS/blob/master/python/plugins/
> MetaSearch/dialogs/maindialog.py#L759-L792
> >> >> [2]
> >> >> https://gist.github.com/tomkralidis/dccb49efa760a585be38ee0c3188b8b3
> >> >> [3] http://qgis.org/api/classQgsDataSourceManagerDialog.html
> >> >> _______________________________________________
> >> >> QGIS-Developer mailing list
> >> >> QGIS-Developer at lists.osgeo.org
> >> >> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> >> >> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> >> >
> >> >
> >> >
> >> >
> >> > --
> >> > Alessandro Pasotti
> >> > w3:   www.itopen.it
> >
> >
> >
> >
> > --
> > Alessandro Pasotti
> > w3:   www.itopen.it
>



-- 
Alessandro Pasotti
w3:   www.itopen.it
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20171113/71a90904/attachment-0001.html>


More information about the QGIS-Developer mailing list