Create groups in python plugins

10 messages Options
Embed this post
Permalink
Andres Manz

Create groups in python plugins

Reply Threaded More More options
Print post
Permalink
Hi there,

I'm writing a little plugin for adding new maps, extracted from zip files.
Everything's fine, I extract the zip file and add a few layers.
Then I need to add a new group (for a country), but up to now,
I could not find a way to do that over QgisInterface.

Is there a way to add new groups in a python plugin, just like selecting "Add group"
when right-clicking in the layer view?

Regards
Andres

_______________________________________________
Qgis-developer mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/qgis-developer
Martin Dobias

Re: Create groups in python plugins

Reply Threaded More More options
Print post
Permalink
On Wed, Nov 4, 2009 at 11:37 AM, Andres Manz <[hidden email]> wrote:

> Hi there,
>
> I'm writing a little plugin for adding new maps, extracted from zip files.
> Everything's fine, I extract the zip file and add a few layers.
> Then I need to add a new group (for a country), but up to now,
> I could not find a way to do that over QgisInterface.
>
> Is there a way to add new groups in a python plugin, just like selecting
> "Add group"
> when right-clicking in the layer view?

Hi Andres,

unfortunately this is currently not possible.

Regards
Martin
_______________________________________________
Qgis-developer mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/qgis-developer
Andres Manz

Re: Create groups in python plugins

Reply Threaded More More options
Print post
Permalink
Hi,

Would it be a good idea to implement that feature?
I'm not sure if anyone could ever need it.
I've read a bit of the code and saw that you would add new
groups in QgsLegend.

Well, adding new groups is not a problem there. But I'm not sure
about how to move a map layer from one group to another.
As far as I understand it, this would need QgsLegend to
be in the qgis API, where I have some doubts. ;)

Regards
Andres


On Wed, Nov 4, 2009 at 1:08 PM, Martin Dobias <[hidden email]> wrote:
> Hi Andres,
>
> unfortunately this is currently not possible.
>
> Regards
> Martin
>
_______________________________________________
Qgis-developer mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/qgis-developer
Lionel Roubeyrie

Re: Create groups in python plugins

Reply Threaded More More options
Print post
Permalink
Hi all,
In this way, is it planned to modify the legend panel? Qgis lacks about a real
grouping option, where we can append layers to only one group and modify
parameters (transparency, visibility, ...). Having to manually DnD sometimes
more than 50 tiles one by one is less than a pleasure...
Cheers

Andres Manz a écrit :

> Hi,
>
> Would it be a good idea to implement that feature?
> I'm not sure if anyone could ever need it.
> I've read a bit of the code and saw that you would add new
> groups in QgsLegend.
>
> Well, adding new groups is not a problem there. But I'm not sure
> about how to move a map layer from one group to another.
> As far as I understand it, this would need QgsLegend to
> be in the qgis API, where I have some doubts. ;)
>
> Regards
> Andres
>
>
> On Wed, Nov 4, 2009 at 1:08 PM, Martin Dobias <[hidden email]> wrote:
>> Hi Andres,
>>
>> unfortunately this is currently not possible.
>>
>> Regards
>> Martin
>>
> _______________________________________________
> Qgis-developer mailing list
> [hidden email]
> http://lists.osgeo.org/mailman/listinfo/qgis-developer
>
>

--
Lionel Roubeyrie - [hidden email]
Chargé d'études et de maintenance
LIMAIR - la Surveillance de l'Air en Limousin
http://www.limair.asso.fr



_______________________________________________
Qgis-developer mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/qgis-developer
Martin Dobias

Re: Create groups in python plugins

Reply Threaded More More options
Print post
Permalink
In reply to this post by Andres Manz
On Thu, Nov 5, 2009 at 9:01 AM, Andres Manz <[hidden email]> wrote:

> Hi,
>
> Would it be a good idea to implement that feature?
> I'm not sure if anyone could ever need it.
> I've read a bit of the code and saw that you would add new
> groups in QgsLegend.
>
> Well, adding new groups is not a problem there. But I'm not sure
> about how to move a map layer from one group to another.
> As far as I understand it, this would need QgsLegend to
> be in the qgis API, where I have some doubts. ;)

Enabling users to work with legend will be a good step forward. I
think we could create a QgsLegendInterface class available in gui
library that would allow manipulation with layers and groups in legend
widget:
- add / remove a group
- add / remove layer to/from a group
- list contents of legend or of one group
- modify layer / group visibility in canvas
- more...

But as always, there has to be someone to create such interface and do
the connection with legend classes - your patches are welcome!

Regards
Martin
_______________________________________________
Qgis-developer mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/qgis-developer
Andres Manz

Re: Create groups in python plugins

Reply Threaded More More options
Print post
Permalink
Hi Martin,

> But as always, there has to be someone to create such interface and do
> the connection with legend classes - your patches are welcome!

I'd like to take a look at it after holiday.
qgis is a very nice program and thus I am familiar with using Qt anyway,
I'd love to help out a little bit.

Regards
Andres

On Tue, Nov 10, 2009 at 1:33 PM, Martin Dobias <[hidden email]> wrote:

> On Thu, Nov 5, 2009 at 9:01 AM, Andres Manz <[hidden email]> wrote:
>> Hi,
>>
>> Would it be a good idea to implement that feature?
>> I'm not sure if anyone could ever need it.
>> I've read a bit of the code and saw that you would add new
>> groups in QgsLegend.
>>
>> Well, adding new groups is not a problem there. But I'm not sure
>> about how to move a map layer from one group to another.
>> As far as I understand it, this would need QgsLegend to
>> be in the qgis API, where I have some doubts. ;)
>
> Enabling users to work with legend will be a good step forward. I
> think we could create a QgsLegendInterface class available in gui
> library that would allow manipulation with layers and groups in legend
> widget:
> - add / remove a group
> - add / remove layer to/from a group
> - list contents of legend or of one group
> - modify layer / group visibility in canvas
> - more...
>
> But as always, there has to be someone to create such interface and do
> the connection with legend classes - your patches are welcome!
>
> Regards
> Martin
>
_______________________________________________
Qgis-developer mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/qgis-developer
Andres Manz

Re: Create groups in python plugins

Reply Threaded More More options
Print post
Permalink
Hi,

I just started working on QgsLegendInterface, so I need a little
more information: Should it be a member of QgisAppInterface (or
QgisApp) or should it be an independent interface class, just like
QgisInterface?

Further feature requests to QgsLegendInterface are welcome, as
detailed as possible. I'll give it a try.

Regards
Andres
_______________________________________________
Qgis-developer mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/qgis-developer
Martin Dobias

Re: Create groups in python plugins

Reply Threaded More More options
Print post
Permalink
On Wed, Nov 18, 2009 at 3:27 PM, Andres Manz <[hidden email]> wrote:
> Hi,
>
> I just started working on QgsLegendInterface, so I need a little
> more information: Should it be a member of QgisAppInterface (or
> QgisApp) or should it be an independent interface class, just like
> QgisInterface?

Hi

my preference is that there will be a new method e.g.
legendInterface() in QgisInterface which will return the pointer to
QgsLegendInterface. And QgsLegend will implement this interface.

Regards
Martin
_______________________________________________
Qgis-developer mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/qgis-developer
Andres Manz

Re: Create groups in python plugins

Reply Threaded More More options
Print post
Permalink
Hi list,

While implementing QgsLegendInterface for the Python API, I ran into
another problem: QgsLegend inherits from QTreeWidget, which inherits
from QObject. As QgsLegendInterface should have signals and slots, it
should inherit from QObject, too. When QgsLegend implements
QgsLegendInterface, I get the diamond problem: Both,
QgsLegendInterface and QTreeWidget inherit from QObject. How should I
handle that? Up to now, there are three possibilities:

1. QgsLegendInterface inherits from QTreeWidget and QgsLegend only
implements QgsLegendInterface. Not a very nice solution, and the
members of QTreeWidget would be exposed to the python scripter.

2. QgsLegendInterface is a "wrapper" class for QgsLegend. It holds a
pointer to the QgsLegend and inherits from QObject.

3. Split up QgsLegend, so the part that doesn't inherit from
QTreeWidget could implement QgsLegendInterface. QgsLegend is a huge
class, so it would be a lot of work to do that.

Do you have any other solutions? Or could you recommend one of the above?

Regards
Andres
_______________________________________________
Qgis-developer mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/qgis-developer
Martin Dobias

Re: Create groups in python plugins

Reply Threaded More More options
Print post
Permalink
On Mon, Nov 23, 2009 at 10:09 AM, Andres Manz <[hidden email]> wrote:

> Hi list,
>
> While implementing QgsLegendInterface for the Python API, I ran into
> another problem: QgsLegend inherits from QTreeWidget, which inherits
> from QObject. As QgsLegendInterface should have signals and slots, it
> should inherit from QObject, too. When QgsLegend implements
> QgsLegendInterface, I get the diamond problem: Both,
> QgsLegendInterface and QTreeWidget inherit from QObject. How should I
> handle that? Up to now, there are three possibilities:
>
> 1. QgsLegendInterface inherits from QTreeWidget and QgsLegend only
> implements QgsLegendInterface. Not a very nice solution, and the
> members of QTreeWidget would be exposed to the python scripter.
>
> 2. QgsLegendInterface is a "wrapper" class for QgsLegend. It holds a
> pointer to the QgsLegend and inherits from QObject.
>
> 3. Split up QgsLegend, so the part that doesn't inherit from
> QTreeWidget could implement QgsLegendInterface. QgsLegend is a huge
> class, so it would be a lot of work to do that.
>
> Do you have any other solutions? Or could you recommend one of the above?

Hi Andres

I would prefer solution 2. This approach is used also for
QgisInterface and its implementation QgisAppInterface. It has a lot of
flexibility - even for cases where e.g. legend widget is interchanged
with a model/view pattern.

Regards
Martin
_______________________________________________
Qgis-developer mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/qgis-developer