[Qgis-developer] Impossible to upload and share a plugin on QGIS plugin repository

2014-07-30 Thread Junior Delaz
Hi all
I'm tring to upload and share my first plugin at [1] but encountered an
error I don't really understand. It says:
*There were errors reading plugin package (please check also your plugin's
metadata). Cannot find __init__.py or metadata.txt in the compressed
package: this does not seems a valid plugin (I searched for
help/__init__.py and help/metadata.txt)*

I have __init__.py and metadata.txt files but they are in the main folder
(I use Plugin Builder plugin) and none of the plugin folders I looked at
has such files in help folder.
So, why is it looking for these files in the help folder?
What did I make wrong? Is it a bug? and if not, what should contain these
files?

Some help? Thanks a lot.

[1] http://plugins.qgis.org/plugins/add/
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer

Re: [Qgis-developer] [Qgis-user] Impossible to upload and share a plugin on QGIS plugin repository

2014-07-30 Thread Junior Delaz
Thanks a lot. You are right!!! I was packaging the contents of my plugin
folder instead of packaging the whole main folder.
It's ok now. all is uploaded.

Thank you!


2014-07-30 18:43 GMT+02:00 Siki Zoltan :

> Dear Junior,
>
> in the zip file you have to use the same directory structure as in the
> .qgis2/python/plugins directory. If the name of your plugin is "xxx" then
> in the zip there sould be a xxx directory which contains the __init__.py
> and metadata.txt and the main python file xxx.py, you can use other
> subdirectories too.
> xxx.zip:
>   xxx - __init__.py
> metadata.txt
> xxx.py
> ...
> help
> ...
>
> Try to download a plugin from plugins.qgis.org and check the structure of
> the zip file.
> I hope this helps you.
>
> Regards,
> Zoltan
>
>
>
> On Wed, 30 Jul 2014, Junior Delaz wrote:
>
>  Hi all
>> I'm tring to upload and share my first plugin at [1] but encountered an
>> error I don't really understand. It says:
>> *There were errors reading plugin package (please check also your plugin's
>>
>> metadata). Cannot find __init__.py or metadata.txt in the compressed
>> package: this does not seems a valid plugin (I searched for
>> help/__init__.py and help/metadata.txt)*
>>
>>
>> I have __init__.py and metadata.txt files but they are in the main folder
>> (I use Plugin Builder plugin) and none of the plugin folders I looked at
>> has such files in help folder.
>> So, why is it looking for these files in the help folder?
>> What did I make wrong? Is it a bug? and if not, what should contain these
>> files?
>>
>> Some help? Thanks a lot.
>>
>> [1] http://plugins.qgis.org/plugins/add/
>>
>>
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer

Re: [Qgis-developer] Get signal on edited feature ?

2014-07-31 Thread Junior Delaz
Hello,
For the first question, I think you have done something like
logFeaturesAdded(Idofmylayer, features) instead of doing
self.logFeaturesAdded(Idofmylayer, features).The function you created has
three args : self, layerId, addfeatures. When using it you should give him
three args. The second expression has three arguments not the first one.
Try that.

for your second question, give a look at self.iface.zoomToActiveLayer(),
after having activated your layer. There may be another way but...

I think one good way to learn how to use all this is to make tests with the
qgis Python Console and you'll quickly find the best functions to call.


2014-07-31 11:08 GMT+02:00 dandrigo :

> Hello, thank for your reply.
>
> 1/ For my pyqgis plugin 2.2, i try to
> ---
> def logFeatureAdded(self,layerId,addfeatures):
> message = str(layerId) + " has features added: "
> for feature in addedFeatures:
> message += str( feature.id() ) + ", "
> QgsMessageLog.logMessage(message)
> QApplication.beep()
> 
>
> When i try to add a feature, this following error message appears:
>
> TypeError : logFeaturesAdded() takes exactly 3 arguments (2 given).
>
> 2/ Always for my plugin, i can load a vector layer succesfully. But when i
> try to zoom to the layer extent. But it does not work. How to do in order
> to
> zoom to the layer extent?
>
>
>
> --
> View this message in context:
> http://osgeo-org.1560.x6.nabble.com/Get-signal-on-edited-feature-tp5154173p5154364.html
> Sent from the Quantum GIS - Developer mailing list archive at Nabble.com.
> ___
> Qgis-developer mailing list
> Qgis-developer@lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-developer
>
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer

[Qgis-developer] Export atlas composition in python console to a single PDF file

2014-08-10 Thread Junior Delaz
Hi All,

A couple of hours I'm trying without success to do something so I ask for
your help.
I would like to export as PDF (in a single file) an atlas composition
within Python Console.
I don't find how to do.
All I obtain is either multiple PDF files corresponding to each iterated
feature of the coverage layer or a single feature corresponding to the last
iterated feature.
Where should I look at, please?
And more generally, where can I find the code used by a tool such as
"Export Atlas to PDF file" in the composer GUI (atlas menu)?

Thanks for your help and advices...
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer

[Qgis-developer] What does mean "empty tables" in "attribute table" item properties in a print composer?

2014-10-08 Thread Junior Delaz
Hi all,
I try to understand the use case of empty tables in print composer and am
still confused.

Create a new print composer and add an attribute table item
set its height enough to show more rows than the maximal values of features
you set.
Add a second frame to this item.

Is this second frame considered as "empty table" (as no feature attribute
will be displayed inside)?
According to the answer, I think I'll have many other questions about the
options in "empty tables" combo box.

The only "empty table" I found in my tests is when the first frame displays
nothing (because "maximal rows" is set to 0 or "show only visible features
within a map" is checked and nothing matches). Is it the only situation?

Can somebody explain to me, please?

Thanks in advance.
Harrissou
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer

Re: [Qgis-developer] What does mean "empty tables" in "attribute table" item properties in a print composer?

2014-10-08 Thread Junior Delaz
Thanks Nyall. This is what I suspected.
Then, none of the "empty tables" options should work on the frames in the
example above, right?
But actually, "Draw empty cells" option does have effect on them. Isn't it
a bug?

2014-10-08 22:33 GMT+02:00 Nyall Dawson :

>
> On 08/10/2014 10:20 pm, "Junior Delaz"  wrote:
> >
> > Hi all,
> > I try to understand the use case of empty tables in print composer and
> am still confused.
> >
> > Create a new print composer and add an attribute table item
> > set its height enough to show more rows than the maximal values of
> features you set.
> > Add a second frame to this item.
> >
> > Is this second frame considered as "empty table" (as no feature
> attribute will be displayed inside)?
>
> No. This behavior only triggers when the entire table is empty. It is
> designed for atlas prints, where the table's contents are being filtered by
> the atlas. In this scenario it's possible that no records match the filter
> for a particular atlas feature and you need to handle empty tables.
>
> Nyall
>
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer

Re: [Qgis-developer] What does mean "empty tables" in "attribute table" item properties in a print composer?

2014-10-11 Thread Junior Delaz
Indeed, this a desirable behavior: user may want to show empty rows when
there are not enough matching features. This is what I was looking for when
using this option. But having this one working for a table and none among
the three other options is a bit confusing for the user. I spent at least
an hour on testing why these options didn't work and I'm afraid I won't be
the last.

Don't you think that "draw empty rows" can be a separate option (may be a
checkbox)? It'll have its effects on every frame with too higher rows for
the features.
The other three options in the combobox will work only when there is no row
(on real empty tables).

2014-10-09 13:28 GMT+02:00 Nyall Dawson :

> On 9 October 2014 08:53, Junior Delaz  wrote:
> > Thanks Nyall. This is what I suspected.
> > Then, none of the "empty tables" options should work on the frames in the
> > example above, right?
> > But actually, "Draw empty cells" option does have effect on them. Isn't
> it a
> > bug?
>
> Well - possibly it's a little inconsistent, but I think this behaviour
> is desirable. If you're wanting to show empty cells, I think you'd
> also want to show them when the table is partially filled, rather than
> only when it's totally empty.
>
> Nyall
>
> >
> > 2014-10-08 22:33 GMT+02:00 Nyall Dawson :
> >>
> >>
> >> On 08/10/2014 10:20 pm, "Junior Delaz"  wrote:
> >> >
> >> > Hi all,
> >> > I try to understand the use case of empty tables in print composer and
> >> > am still confused.
> >> >
> >> > Create a new print composer and add an attribute table item
> >> > set its height enough to show more rows than the maximal values of
> >> > features you set.
> >> > Add a second frame to this item.
> >> >
> >> > Is this second frame considered as "empty table" (as no feature
> >> > attribute will be displayed inside)?
> >>
> >> No. This behavior only triggers when the entire table is empty. It is
> >> designed for atlas prints, where the table's contents are being
> filtered by
> >> the atlas. In this scenario it's possible that no records match the
> filter
> >> for a particular atlas feature and you need to handle empty tables.
> >>
> >> Nyall
> >
> >
> ___
> Qgis-developer mailing list
> Qgis-developer@lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-developer
>
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer

[Qgis-developer] Impossible to keep QGIS 2.4 while updating QGIS master (osgeo4W nightly build)

2014-11-26 Thread Junior Delaz
Hello,
I use OsGeo4W to install both QGIS stable and master releases.
Due to the bug of QGIS 2.6.0-1 that crashes QGIS and ruins some older
project file, I decided to not yet upgrade to 2.6 (and keep 2.4) but still
update nightly builds.
The first time I got 2.7, I choose to keep 2.4. After the install process,
I was unable to run QGis 2.4, getting the error message attached when
launching either the shortcut or the qgis.bat file in install directory.
Two days later, after updating nightly build , QGIS 2.4 worked fine and
stopped again at the next nightly build.
Since, reinstalling QGIS 2.4 in osgeo4w install process doesn't fix it, the
only usable release remains the Master.

Is this a bug or is it impossible to install both master and "not the
latest stable" releases through osgeo4W? If a bug, should I file a ticket
on qgis hub or elsewhere?
Any idea how I can get back a working QGIS 2.4?

I'm on Windows 7 64 bits but I got the same bug on Windows 8 32 bits.

Thanks.
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer

Re: [Qgis-developer] Questions about Dialog for Select by Expression

2014-12-01 Thread Junior Delaz
Hi All

Lene,

The height of the expression frame should indeed have a minimum value, to
avoid closing it. But this is not a new behaviour. In QGIS 2.4, you could
already close totally this frame if you drag down enough. I think it's a
bug and you can fill a ticket unless it's an intended behaviour (and it
would be nice if the dev can explain why such choice - thanks).

About syntax coloring, I have it work as expected here but I'm on 2.6.1
(haven't tried 2.6.0). Maybe, it's already fixed or it's an OS issue (I'm
on Windows 7  64bits, Osgeo4w advanced install).

For the last one, I agree with you, we should have kept "load unique
values" and "All" instead of "load  values" and "All unique". The first one
seems more comprehensive to me and everybody gets that the "unique" term
applies for "All" and "10 samples". It may be confusing now, having
"unique" only on "All" button. No?

2014-11-30 9:30 GMT+01:00 Lene Fischer :

>  Hi,
>
> In the dialog Select by expression there has been some changes in 2.6
>
>
>
> Window dragging in expressions must have a minimum vale so the express
> doesn’t disappear if you drag down.
>
> Secondly – before there was a syntax coloring – now it´s all the same
> color.
>
> At last – why does buttons change name – if there is no change in
> function? Here I refere to Load values.
>
>
>
> Please see the video http://screencast.com/t/VE4PvkT1 that explains the
> questions.
>
> Regards
>
>
>
>
>
>
>
>
>
> *Lene Fischer*
>
> Associate Professor
>
>
>
> *Department of Geosciences and Natural Resource Management*
>
> University of Copenhagen
>
>
>
> MOB +45 40115084
>
> l...@ign.ku.dk
>
>
>
>
>
> [image: SCIENCE_bomaerke_UK]
>
>
>
>
>
> ___
> Qgis-developer mailing list
> Qgis-developer@lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-developer
>
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer

[Qgis-developer] Retrieve value from another layer related to its localisation

2015-01-15 Thread Junior Delaz
Hi all,

I have two shapefiles : a line one (called "section") and a point one
(called "station") shapefiles.
The line shapefiles has fields like ID_section, ID_first, ID_last
The point file has an ID_station.
All these define a kind of network where a section begins on a station and
ends up at another station.
What I need to do is to fill :
- section ID_first field with the ID_station of the station that is the
closest to the beginning of the section
- and section ID_last field with the ID_station of the closest station to
the end of the line.

I can obtain this result while combining many analysis tools and plugins
(QChainage, Spatial_Join...). I know how I can do it. There might be a way
with processing tools and if somebody has an idea, I'll be glad to know it
however.

But what I'm really wondering is if it isn't directly possible to fill
these fields in the Field calculator using all the nice functions we have.
Indeed, QGIS 2.6 and RefFunctions plugin give relational fonctions to
retrieve values on a specific layer according to its fields, features
values or localisation.
I tried many combinations with db_query, geomnearest, geomRedef, xat/yat,
buffer, geometry, within , attribute (not all at the same time :) ) I'm
pretty sure it's possible but I can't find. And I don't want to lose all my
hair...

Does anybody know how I can retrieve in a line shapefile's field the value
of the point feature that is the closest to the first vertex of this line,
within the field calculator?

Thanks ...
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer

Re: [Qgis-developer] [Bulk] Re: [Qgis-user] Retrieve value from another layer related to its localisation

2015-01-15 Thread Junior Delaz
Thanks Enrico for your reply and for the plugin.

I was aware of RefFunctions and has already used it for relational
questions. And I agree with Jean that such functions (and others of your
plugins) might be core functions. I've moreover reported a feature request
to improve usability of all this #11680 <https://hub.qgis.org/issues/11680>.
And I tried it again this time. but the main problem is I don't want to
retrieve field value of the nearest point to my line geometry. I want to
retrieve field value of the nearest point *to the first vertex* of my line
geometry. While using just geomnearest, i'll get only the nearest point to
the whole line. It may be the point at the beginning or the one at the end
of the line, I can't know.
What I did is to create a point file containing my vertices and then use
refFunctions to get the nearest station ID.

But, isn't it possible to do the request without the step of creating new
point file? Using in the condition "being nearest to the geomfromWKT('POINT
(xat(0) yat(0)) ') of line feature"?
How can I write in the field calculator of a line layer such function :
dbquery ('mypointlayer', 'pointID', 'the condition is to be the nearest
point to the first vertex of the line')? Or dbvalue? Is it possible to
combine reference functions with others?

And more generally, are Reference functions conditions intended to be only
internal to the target layer or can I use values/fields from the source
layer? If latter, how can I refer to the source layer in the expression?

Thanks


2015-01-15 12:05 GMT+01:00 Tijan49 :

>  Hi,
> I knew about those functions a few weeks ago, and I was really happy about
> that, because it is a lack in the basic function.
> For I, those new functions should really be in the core project in the
> next release ...
> Thanks to all the programmers.
> Jean
>
> Le 15/01/2015 11:59, Enrico Ferreguti a écrit :
>
>   You can use refFunctions (http://plugins.qgis.org/plugins/refFunctions/)
> plugin that extends Field Calculator with a new Reference group.
>  Within this group you will find a geomnearest and a geomdistance function
> that can help you.
>
>  copy and paste from helper screen:
>
> geomnearest function
>
>
> Retrieve target field value from the nearest target feature in target
> layer
>
> Syntax
>
> geomnearest(targetLayer,targetField)
>
> Arguments
>
> targetLayer → the name of a currently loaded layer, for example 'myLayer'.
> targetField → a field in target layer we want as result when source
> feature is within target feature, for example 'myField'.
> If targetField is equal to '$geometry' The WKT geometry of targetFeature
> willbe retrieved. If otherwise is equal to '$distance' the calculated
> distance between source and target features will be returned
> Number of feature tested is limited to 10 to avoid time wasting loops
>
> Example
>
> geomnearest('targetLayer','TargetField')
> geomnearest('targetLayer','$geometry')
> geomnearest('targetLayer','$distance')
>
>
> 2015-01-15 11:19 GMT+01:00 Junior Delaz :
>
>>Hi all,
>>
>>  I have two shapefiles : a line one (called "section") and a point one
>> (called "station") shapefiles.
>>  The line shapefiles has fields like ID_section, ID_first, ID_last
>>  The point file has an ID_station.
>>  All these define a kind of network where a section begins on a station
>> and ends up at another station.
>>  What I need to do is to fill :
>> - section ID_first field with the ID_station of the station that is the
>> closest to the beginning of the section
>> - and section ID_last field with the ID_station of the closest station to
>> the end of the line.
>>
>> I can obtain this result while combining many analysis tools and plugins
>> (QChainage, Spatial_Join...). I know how I can do it. There might be a way
>> with processing tools and if somebody has an idea, I'll be glad to know it
>> however.
>>
>>  But what I'm really wondering is if it isn't directly possible to fill
>> these fields in the Field calculator using all the nice functions we have.
>> Indeed, QGIS 2.6 and RefFunctions plugin give relational fonctions to
>> retrieve values on a specific layer according to its fields, features
>> values or localisation.
>>  I tried many combinations with db_query, geomnearest, geomRedef,
>> xat/yat, buffer, geometry, within , attribute (not all at the same time :)
>> ) I'm pretty sure it's possible but I can't find. And I don't want to
>> lose all my hair...
>>
>>  Does anybody know how I can retrieve in a line shapefile's field the
>> value of the point feature that is the closest to the first vertex of this
>> line, within the field calculator?
>>
>>  Thanks ...
>>
>
>
>
> ___
> Qgis-user mailing 
> listQgis-user@lists.osgeo.orghttp://lists.osgeo.org/mailman/listinfo/qgis-user
>
>
>
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer

Re: [Qgis-developer] [Bulk] Re: [Qgis-user] Retrieve value from another layer related to its localisation

2015-01-15 Thread Junior Delaz
Ok, this is somehow what I did. With QChainage plugin, no need to create
new fields and csv table. It directly creates the point geometry layer
corresponding to xat(0)/yat(0) and xat(-1)/yat(-1) with $id field, when
well setting.
I also assume that what I was trying to do directly within the line layer
field calculator is not (yet) possible.

Thanks.



2015-01-15 15:54 GMT+01:00 Enrico Ferreguti :

> Ok. so i would proceed degrading line geometry to point geometry creating
> two X and Y fields in the original table with xat(0) and yat(0) functions.
> I would add a featureid field with $id function for  a following join. Then
> I would export everything in cvs and import back with "Add Delimited Text
> Layer" creatin geometry from X and Y fields.
> From the the degraded new table is now possible to apply geomnearest
> function joining the added fields with featureid field.
> ...a bit tricky but it should work.
>
> Regards
>
>
>
>
> 2015-01-15 14:25 GMT+01:00 Junior Delaz :
>
>> Thanks Enrico for your reply and for the plugin.
>>
>> I was aware of RefFunctions and has already used it for relational
>> questions. And I agree with Jean that such functions (and others of your
>> plugins) might be core functions. I've moreover reported a feature request
>> to improve usability of all this #11680
>> <https://hub.qgis.org/issues/11680>.
>> And I tried it again this time. but the main problem is I don't want to
>> retrieve field value of the nearest point to my line geometry. I want to
>> retrieve field value of the nearest point *to the first vertex* of my
>> line geometry. While using just geomnearest, i'll get only the nearest
>> point to the whole line. It may be the point at the beginning or the one at
>> the end of the line, I can't know.
>> What I did is to create a point file containing my vertices and then use
>> refFunctions to get the nearest station ID.
>>
>> But, isn't it possible to do the request without the step of creating new
>> point file? Using in the condition "being nearest to the geomfromWKT('POINT
>> (xat(0) yat(0)) ') of line feature"?
>> How can I write in the field calculator of a line layer such function :
>> dbquery ('mypointlayer', 'pointID', 'the condition is to be the nearest
>> point to the first vertex of the line')? Or dbvalue? Is it possible to
>> combine reference functions with others?
>>
>> And more generally, are Reference functions conditions intended to be
>> only internal to the target layer or can I use values/fields from the
>> source layer? If latter, how can I refer to the source layer in the
>> expression?
>>
>> Thanks
>>
>>
>> 2015-01-15 12:05 GMT+01:00 Tijan49 :
>>
>>>  Hi,
>>> I knew about those functions a few weeks ago, and I was really happy
>>> about that, because it is a lack in the basic function.
>>> For I, those new functions should really be in the core project in the
>>> next release ...
>>> Thanks to all the programmers.
>>> Jean
>>>
>>> Le 15/01/2015 11:59, Enrico Ferreguti a écrit :
>>>
>>>   You can use refFunctions (
>>> http://plugins.qgis.org/plugins/refFunctions/) plugin that extends
>>> Field Calculator with a new Reference group.
>>>  Within this group you will find a geomnearest and a geomdistance
>>> function that can help you.
>>>
>>>  copy and paste from helper screen:
>>>
>>> geomnearest function
>>>
>>>
>>> Retrieve target field value from the nearest target feature in target
>>> layer
>>>
>>> Syntax
>>>
>>> geomnearest(targetLayer,targetField)
>>>
>>> Arguments
>>>
>>> targetLayer → the name of a currently loaded layer, for example
>>> 'myLayer'.
>>> targetField → a field in target layer we want as result when source
>>> feature is within target feature, for example 'myField'.
>>> If targetField is equal to '$geometry' The WKT geometry of targetFeature
>>> willbe retrieved. If otherwise is equal to '$distance' the calculated
>>> distance between source and target features will be returned
>>> Number of feature tested is limited to 10 to avoid time wasting loops
>>>
>>> Example
>>>
>>> geomnearest('targetLayer','TargetField')
>>> geomnearest('targetLayer','$geometry')
>>> geomnearest('targetLayer','$distance&#x

Re: [Qgis-developer] Problem when using spatial index

2015-01-21 Thread Junior Delaz
Some users [1] have already encountered this issue and i understood that it
may be related to non correspondance between the number of rows in the .dbf
file and number of geometry (some rows had no geometry). A simple "Save
As.." to another shapefile has solved the problem.
[1] http://georezo.net/forum/viewtopic.php?id=95143 (in french, sorry )

2015-01-21 9:16 GMT+01:00 Nejia Ben Nasr :

> Hi,
>
>
>
> Do you think that this problem is often caused by geometry problems?
>
>
>
> Thanks,
>
> Nejia
>
>
>
> *De :* Junior [mailto:del...@gmail.com]
> *Envoyé :* mardi 20 janvier 2015 13:41
> *À :* Nejia Ben Nasr; 'qgis-developer'
> *Objet :* Re : [Qgis-developer] Problem when using spatial index
>
>
>
> Hi,
>
> Nejia, what about the validity of the geometry of your features? You can
> check with the tool in Vector menu > Geometry tools > check geometry
> validity
>
>
>
> Envoyé depuis mon HTC
>
>
>
> - Reply message -
> De : "Nejia Ben Nasr" 
> Pour : "'qgis-developer'" 
> Objet : [Qgis-developer] Problem when using spatial index
> Date : mar., janv. 20, 2015 13:03
>
>
>
> I use QGIS 2.6.1
>
>
>
> *De :* qgis-developer-boun...@lists.osgeo.org [
> mailto:qgis-developer-boun...@lists.osgeo.org
> ] *De la part de* Nejia Ben Nasr
> *Envoyé :* mardi 20 janvier 2015 09:39
> *À :* qgis-developer
> *Objet :* [Qgis-developer] Problem when using spatial index
>
>
>
> Hi all,
>
>
>
> I load a shapefile, then I create a spatial index to maximize speed of
> zoom and navigate in the map.
>
> The problem is: when I zoom to any area feature appear and other doesn’t.
>
> And it seems To me that the spatial index is automatically created even
> when I delete the .qix file
>
>
>
>
>
> Best regards,
>
> Nejia
>
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer

Re: [Qgis-developer] problem with 'toreal' in field calculator

2015-03-10 Thread Junior Delaz
hi,

If your field is recognized by QGIS as a string one, trying to overwrite
its values type will fail as they are intended to be string in THIS field.
This is why when you create a new numeric field and make conversion, it's
ok (this new field expect numeric values, so it'll recognize your
conversion).

2015-03-10 18:08 GMT+01:00 Matteo Ghetta :

> Hi all,
> I have a filed made up by numeric values but recognized as text (should be
> a WFS issue and not a QGIS problem).
> I've used the 'toreal' function of the field calculator in order to update
> the field but nothing changed (numbers are still read as text).
> Strange is that if I create a new field using the 'toreal' function,
> values are correctly read as numbers and not as text.
>
> Am I missing something or can be a bug?
>
> BTW: debian testing and QGIS 2.8.1
>
> Cheers
>
> Matteo
>
>
> ___
> Qgis-developer mailing list
> Qgis-developer@lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-developer
>
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer

Re: [Qgis-developer] wrong attribute values for postgis data in Feature attribute form

2015-03-26 Thread Junior Delaz
Hi,
Raymond, you can use the row_number function to add a primary key to your
view.
Something like :
CREATE OR REPLACE view myview as
SELECT row_number () over ()::integer as id, fieldA, Field ...
from mytable .
will add an unique integer field _id_ to your view. And this one can be
used in QGIS as primary key

2015-03-26 11:15 GMT+01:00 Raymond Nijssen :

> Thanks Bernhard. I just figured that. But my layer is not a table, it is a
> view. And it seems that PostgreSQL cannot have constraints on views.
>
> So, I think I just need to carefully select the right key field when
> loading it.
>
> (And maybe QGIS could be slightly smarter by not suggesting a boolean
> field by default?)
>
>
>
> On 26-03-15 11:07, Bernhard Ströbl wrote:
>
>> Hi Raymond,
>>
>> Am 26.03.2015 10:57, schrieb Raymond Nijssen:
>>
>>> Thanks Regis, that was exactly the issue. The (boolean!) field
>>> 'inonderzoek' was used as a key. When I change that to 'gid' in the Add
>>> PostGIS Table dialog, everything works correctly.
>>>
>>> Can anyone tell me why QGIS picks that boolean field for most of my
>>> tables? Can I change that behaviour by changing my database structure?
>>>
>>
>> Maybe I can, but I would need the table definition statement for it. Can
>> you post it here.
>> Generally speaking you should define an integer field (use bigint if you
>> expect _many_ datasets) as primary key for the table like:
>>
>> CREATE TABLE my_points
>> (
>>gid integer NOT NULL,
>>the_geom geometry(Point,my_srid),
>>other_fields,
>>CONSTRAINT my_points_pkey PRIMARY KEY (gid)
>> );
>>
>> Bernhard
>>
>>
>>> http://terglobo.nl/downloads/qgis_add_postgis_table_wrong_key.png
>>>
>>> And how can the identify results be correct anyway?
>>>
>>> Tnx,
>>> Raymond
>>>
>>>
>>> dbname='bag' host=localhost port=5432 user='postgres' sslmode=disable
>>> key='inonderzoek' estimatedmetadata=true srid=28992 type=POLYGON
>>> table="bagactueel"."pandactueelbestaand" (geovlak) sql=
>>>
>>>
>>>
>>> On 26-03-15 10:34, Régis Haubourg wrote:
>>>
 Hi, I have seen such troubles when the choosen primary key from qgis
 side is
 not unique .

 Symptoms: selecting one feature select severals unrelated features of
 the
 same layer. relation with attributes is broken also.

 Can you check in your layer's definition (general tab of layer
 properties)
 if you choose gid field as key, and check if it is really unique in
 postgis?

 Cheers
 Régis



 --
 View this message in context:
 http://osgeo-org.1560.x6.nabble.com/wrong-attribute-
 values-for-postgis-data-in-Feature-attribute-form-
 tp5195518p5195523.html


 Sent from the Quantum GIS - Developer mailing list archive at
 Nabble.com.
 ___
 Qgis-developer mailing list
 Qgis-developer@lists.osgeo.org
 http://lists.osgeo.org/mailman/listinfo/qgis-developer


>>>
>>
>>
>> __ Information from ESET Mail Security, version of virus
>> signature database 11379 (20150326) __
>>
>> The message was checked by ESET Mail Security.
>> http://www.eset.com
>>
>>
>> ___
>> Qgis-developer mailing list
>> Qgis-developer@lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/qgis-developer
>>
>
> --
> Terglobo
> Ampèrestraat 110
> 5223 CT 's-Hertogenbosch
> 06-25314983
> ___
> Qgis-developer mailing list
> Qgis-developer@lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-developer
>
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer

[Qgis-developer] Pyqt4 : which signal is sent when dialog comes to foreground?

2015-03-30 Thread Junior Delaz
Hi,
I'm working on a Python plugin for QGIS and need your help to do something.
I'm a beginner in Python and C++ and just used plugin-builder for the
architecture.

My main dialog is a non modal one and does list print composers in the
project. It means that while it's opened, user can delete or create
composer. What I'd like is, when user calls back the dialog to foreground,
it automatically updates the list of composers. I already have the function
to update but don't find which signal to use. I can add a button to do this
but better if it can be done transparently...

I've read about defining a custom showEvent function but can't understand
where to put it and what inside.
If somebody can give some tips...

Thanks in advance,

DelazJ
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer

Re: [Qgis-developer] Re : [Qgis-user] Pyqt4 : which signal is sent when dialog comes to foreground?

2015-03-31 Thread Junior Delaz
Matthias,
Thanks. I just give it a try it and all goes well with composerAdded.
But not really well with composerWillBeRemoved signal. The first deletion
in the composer manager does nothing and deleting a second composer does
remove the first one in my list. and so on...
My update function should be rewritten I think.  I'll try to see how
improving it and may (surely) ask again for help (if needed).

While seeking information about composerWillBeRemoved, I found a
composerRemoved [1] [2] signal (that doesn't appear in the API doc) and
without being able to use it. :(
[1]
https://github.com/qgis/QGIS/blob/master/src/app/composer/qgscomposermanager.cpp
(line 48
[2] https://github.com/qgis/QGIS/blob/master/src/app/qgisapp.cpp (line 5601)

Another thing that may not be related : what the deletePrintComposers
function (https://github.com/qgis/QGIS/blob/master/src/app/qgisapp.cpp line
5698) is for?

Thanks again for the clue.

2015-03-31 9:43 GMT+02:00 Matthias Kuhn :

>  QgisInterface (iface) has a composerAdded and composerWillBeRemoved
> signal.
>
> Did you try to connect to these?
>
> Best,
> Matthias
>
>
> On 03/31/2015 09:34 AM, Junior wrote:
>
>  Hi all, Luca
> Thanks for answering. But i already have an update function that I linked
> to an update list button. I even linked it to the icon on the toolbar so
> that when user calls foreground the dialog it's already updated.
> The case I'd like to manage: user can open plugin dialog and composer
> manager. The two dialogs are visible (to the eyes) even though composer
> manager is the one at foreground. He makes changes and directly clicked on
> the plugin dialog. He should update list but if he forgets and executes,
> this may lead to bug I don't want to / can't yet manage.
> Reason why I want to ensure that list is always up to date when he
> interacts with the dialog
>
>  Envoyé depuis mon HTC
>
> - Reply message -
> De : "Luca Manganelli"  
> Pour :
> Cc : "qgis-u...@lists.osgeo.org" 
>  , "qgis-developer"
>  
> Objet : [Qgis-developer] [Qgis-user] Pyqt4 : which signal is sent when
> dialog comes to foreground?
> Date : mar., mars 31, 2015 07:56
>
> On Mon, Mar 30, 2015 at 6:12 PM, Junior Delaz  
>  wrote:
> > I've read about defining a custom showEvent function but can't understand
> > where to put it and what inside.
> > If somebody can give some tips...
>
> You could add a "Update list" button
> ___
> Qgis-developer mailing 
> listQgis-developer@lists.osgeo.orghttp://lists.osgeo.org/mailman/listinfo/qgis-developer
>
>
>
> ___
> Qgis-developer mailing 
> listQgis-developer@lists.osgeo.orghttp://lists.osgeo.org/mailman/listinfo/qgis-developer
>
>
>
> ___
> Qgis-developer mailing list
> Qgis-developer@lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-developer
>
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer

Re: [Qgis-developer] Re : [Qgis-user] Pyqt4 : which signal is sent when dialog comes to foreground?

2015-04-05 Thread Junior Delaz
Hi,
I do understand nothing.
After I read your message, Matthias, I told myself that using QT.
QueuedConnection should be the easiest way. Then i wrote
self.iface.composerWillBeRemoved.connect(self.refreshList,
Qt.QueuedConnection)
But each time i delete a composer, QGIS crashes.
So I've spent the week on reading about Qt.QueuedConnection and then signal
and slots, function partial, QSignalMapper, sender trying to understand how
I can catch the sender and manage to update my list. All this without
success in the code.
And today, I tried again Qt.QueuedConnection, QGIS crashed. Without any
changes, I tried again and it worked and continues to work. Adding and
deleting composer in the composer manager echoes in my list.
I hope it will remain like that.

But now I realize that I didn't take into account the renaming of a
composer. :(

I think I'd wisely keep the refreshlist button unless someone tells me how
I can reach the composer manager dialog programmatically. So that I will
try to synchronize my list with its widgetlistitems...

Thanks for all...


2015-03-31 14:50 GMT+02:00 Matthias Kuhn :

>  You should get a parameter containing the composer that is being deleted
> with composerWillBeRemoved signal. Try to use that to infer which composer
> has been removed. As the signal name indicates, at the time it is emitted,
> the composer is not deleted yet.
> As an alternative you may make the connection with Qt.QueuedConnection. It
> is possible that with this connection style you will receive the signal
> after deletion and are able to continue using your current update method.
>
> Best
> Matthias
>
>
> On 03/31/2015 02:04 PM, Junior Delaz wrote:
>
>Matthias,
>  Thanks. I just give it a try it and all goes well with composerAdded.
>  But not really well with composerWillBeRemoved signal. The first deletion
> in the composer manager does nothing and deleting a second composer does
> remove the first one in my list. and so on...
> My update function should be rewritten I think.  I'll try to see how
> improving it and may (surely) ask again for help (if needed).
>
>  While seeking information about composerWillBeRemoved, I found a
> composerRemoved [1] [2] signal (that doesn't appear in the API doc) and
> without being able to use it. :(
> [1]
> https://github.com/qgis/QGIS/blob/master/src/app/composer/qgscomposermanager.cpp
> (line 48
> [2] https://github.com/qgis/QGIS/blob/master/src/app/qgisapp.cpp (line
> 5601)
>
>  Another thing that may not be related : what the deletePrintComposers
> function (https://github.com/qgis/QGIS/blob/master/src/app/qgisapp.cpp
> line 5698) is for?
>
> Thanks again for the clue.
>
> 2015-03-31 9:43 GMT+02:00 Matthias Kuhn :
>
>>  QgisInterface (iface) has a composerAdded and composerWillBeRemoved
>> signal.
>>
>> Did you try to connect to these?
>>
>> Best,
>> Matthias
>>
>>
>> On 03/31/2015 09:34 AM, Junior wrote:
>>
>>  Hi all, Luca
>> Thanks for answering. But i already have an update function that I linked
>> to an update list button. I even linked it to the icon on the toolbar so
>> that when user calls foreground the dialog it's already updated.
>> The case I'd like to manage: user can open plugin dialog and composer
>> manager. The two dialogs are visible (to the eyes) even though composer
>> manager is the one at foreground. He makes changes and directly clicked on
>> the plugin dialog. He should update list but if he forgets and executes,
>> this may lead to bug I don't want to / can't yet manage.
>> Reason why I want to ensure that list is always up to date when he
>> interacts with the dialog
>>
>>  Envoyé depuis mon HTC
>>
>> - Reply message -
>> De : "Luca Manganelli"  
>> Pour :
>> Cc : "qgis-u...@lists.osgeo.org" 
>>  ,
>> "qgis-developer" 
>> 
>> Objet : [Qgis-developer] [Qgis-user] Pyqt4 : which signal is sent when
>> dialog comes to foreground?
>> Date : mar., mars 31, 2015 07:56
>>
>> On Mon, Mar 30, 2015 at 6:12 PM, Junior Delaz  
>>  wrote:
>> > I've read about defining a custom showEvent function but can't understand
>> > where to put it and what inside.
>> > If somebody can give some tips...
>>
>> You could add a "Update list" button
>> ___
>> Qgis-developer mailing 
>> listQgis-developer@lists.osgeo.orghttp://lists.osgeo.org/mailman/listinfo/qgis-developer
>>
>>
>>
>> ___
>> Qgis-developer mailing 
>> listQgis-developer@lists.osgeo.orghttp://lists.osgeo.org/mailman/listinfo/qgis-developer
>>
>>
>>
>> ___
>> Qgis-developer mailing list
>> Qgis-developer@lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/qgis-developer
>>
>
>
>
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer

Re: [Qgis-developer] Re : [Qgis-user] Pyqt4 : which signal is sent when dialog comes to foreground?

2015-04-07 Thread Junior Delaz
Thank you Matthias for your perseverance. It's very helpful and encouraging
for beginners.
I have already tried composerRemoved but when loading the plugin, QGIS
complains :

Impossible de charger l'extension MapsPrinter provoque une erreur lors de
l'appel de sa méthode initGui()

Traceback (most recent call last):
  File "C:/OSGeo4W/apps/qgis/./python\qgis\utils.py", line 228, in startPlugin
plugins[packageName].initGui()
  File "C:/Users/harrissou/.qgis2/python/plugins\MapsPrinter\maps_printer.py",
line 129, in initGui
self.iface.composerRemoved.connect(self.refreshList)
AttributeError: 'QgisInterface' object has no attribute 'composerRemoved'

This happens with all the versions of QGIS I use :
- osgeo4w 32bits (windows 8), osgeo4w 64bits (windows 7): either with
QGIS 2.8, 2.8rel-dev and 2.9
- and Mac OS 10.9 (it is a QGIS 2.4 but composerRemoved is supposed to
have been added since QGIS 2.3 [0])

About Qt.QueuedConnection, my first tests were on the Mac OS (x86-64)
and Osgeo4w 64bits versions. But I never encountered crash with the 32
bits version, using the same code. Can the bug be bound to the
architecture?

[0] https://github.com/qgis/QGIS/blob/master/src/app/qgisapp.h#L1260


2015-04-06 22:11 GMT+02:00 Matthias Kuhn :

>  Hi Junior,
>
> The following lines work for a short test-case.
>
> def compAdded( composer ):
>   print composer
>
> def compRemoved( composer ):
>   print composer
>
> iface.composerAdded.connect( compAdded )
> iface.composerRemoved.connect( compRemoved )
>
> It is possible that the QueuedConnection crashes because along with it a
> composer is emitted which at the time the slot is executed is already
> deleted. That was only a possible approach which I did not test and reading
> your report seems unstable.
>
> Matthias
>
>
> On 04/06/2015 12:33 AM, Junior Delaz wrote:
>
>  Hi,
>  I do understand nothing.
>  After I read your message, Matthias, I told myself that using QT.
> QueuedConnection should be the easiest way. Then i wrote
> self.iface.composerWillBeRemoved.connect(self.refreshList,
> Qt.QueuedConnection)
> But each time i delete a composer, QGIS crashes.
>  So I've spent the week on reading about Qt.QueuedConnection and then
> signal and slots, function partial, QSignalMapper, sender trying to
> understand how I can catch the sender and manage to update my list. All
> this without success in the code.
>  And today, I tried again Qt.QueuedConnection, QGIS crashed. Without any
> changes, I tried again and it worked and continues to work. Adding and
> deleting composer in the composer manager echoes in my list.
>  I hope it will remain like that.
>
>  But now I realize that I didn't take into account the renaming of a
> composer. :(
>
>  I think I'd wisely keep the refreshlist button unless someone tells me
> how I can reach the composer manager dialog programmatically. So that I
> will try to synchronize my list with its widgetlistitems...
>
>  Thanks for all...
>
>
> 2015-03-31 14:50 GMT+02:00 Matthias Kuhn :
>
>>  You should get a parameter containing the composer that is being deleted
>> with composerWillBeRemoved signal. Try to use that to infer which composer
>> has been removed. As the signal name indicates, at the time it is emitted,
>> the composer is not deleted yet.
>> As an alternative you may make the connection with Qt.QueuedConnection.
>> It is possible that with this connection style you will receive the signal
>> after deletion and are able to continue using your current update method.
>>
>> Best
>> Matthias
>>
>>
>> On 03/31/2015 02:04 PM, Junior Delaz wrote:
>>
>>Matthias,
>>  Thanks. I just give it a try it and all goes well with composerAdded.
>>  But not really well with composerWillBeRemoved signal. The first
>> deletion in the composer manager does nothing and deleting a second
>> composer does remove the first one in my list. and so on...
>> My update function should be rewritten I think.  I'll try to see how
>> improving it and may (surely) ask again for help (if needed).
>>
>>  While seeking information about composerWillBeRemoved, I found a
>> composerRemoved [1] [2] signal (that doesn't appear in the API doc) and
>> without being able to use it. :(
>> [1]
>> https://github.com/qgis/QGIS/blob/master/src/app/composer/qgscomposermanager.cpp
>> (line 48
>> [2] https://github.com/qgis/QGIS/blob/master/src/app/qgisapp.cpp (line
>> 5601)
>>
>>  Another thing that may not be related : what the deletePrintComposers
>> function (https://github.com/qgis/QGIS/blob/master/src/app/qgisapp.cpp
>> line 5698) is for?
>

Re: [Qgis-developer] Re : [Qgis-user] Pyqt4 : which signal is sent when dialog comes to foreground?

2015-04-07 Thread Junior Delaz
But why does composerRemoved not work? You can find it in the code on
github repo but not on QGIS API website...

2015-04-07 23:35 GMT+02:00 Matthias Kuhn :

>  Oops,
>
> That should have been composerWillBeRemoved
>
> Sorry for that...
>
> Matthias
>
>
> On 04/07/2015 10:07 PM, Junior Delaz wrote:
>
>  Thank you Matthias for your perseverance. It's very helpful and
> encouraging for beginners.
>  I have already tried composerRemoved but when loading the plugin, QGIS
> complains :
>
> Impossible de charger l'extension MapsPrinter provoque une erreur lors de
> l'appel de sa méthode initGui()
>
> Traceback (most recent call last):
>   File "C:/OSGeo4W/apps/qgis/./python\qgis\utils.py", line 228, in startPlugin
> plugins[packageName].initGui()
>   File 
> "C:/Users/harrissou/.qgis2/python/plugins\MapsPrinter\maps_printer.py", line 
> 129, in initGui
> self.iface.composerRemoved.connect(self.refreshList)
> AttributeError: 'QgisInterface' object has no attribute 'composerRemoved'
>
>
> This happens with all the versions of QGIS I use :
> - osgeo4w 32bits (windows 8), osgeo4w 64bits (windows 7): either with QGIS 
> 2.8, 2.8rel-dev and 2.9
> - and Mac OS 10.9 (it is a QGIS 2.4 but composerRemoved is supposed to have 
> been added since QGIS 2.3 [0])
>
>
> About Qt.QueuedConnection, my first tests were on the Mac OS (x86-64) and 
> Osgeo4w 64bits versions. But I never encountered crash with the 32 bits 
> version, using the same code. Can the bug be bound to the architecture?
>
> [0] https://github.com/qgis/QGIS/blob/master/src/app/qgisapp.h#L1260
>
>
> 2015-04-06 22:11 GMT+02:00 Matthias Kuhn :
>
>>  Hi Junior,
>>
>> The following lines work for a short test-case.
>>
>> def compAdded( composer ):
>>   print composer
>>
>> def compRemoved( composer ):
>>   print composer
>>
>> iface.composerAdded.connect( compAdded )
>> iface.composerRemoved.connect( compRemoved )
>>
>> It is possible that the QueuedConnection crashes because along with it a
>> composer is emitted which at the time the slot is executed is already
>> deleted. That was only a possible approach which I did not test and reading
>> your report seems unstable.
>>
>> Matthias
>>
>>
>> On 04/06/2015 12:33 AM, Junior Delaz wrote:
>>
>>  Hi,
>>  I do understand nothing.
>>  After I read your message, Matthias, I told myself that using QT.
>> QueuedConnection should be the easiest way. Then i wrote
>> self.iface.composerWillBeRemoved.connect(self.refreshList,
>> Qt.QueuedConnection)
>> But each time i delete a composer, QGIS crashes.
>>  So I've spent the week on reading about Qt.QueuedConnection and then
>> signal and slots, function partial, QSignalMapper, sender trying to
>> understand how I can catch the sender and manage to update my list. All
>> this without success in the code.
>>  And today, I tried again Qt.QueuedConnection, QGIS crashed. Without any
>> changes, I tried again and it worked and continues to work. Adding and
>> deleting composer in the composer manager echoes in my list.
>>  I hope it will remain like that.
>>
>>  But now I realize that I didn't take into account the renaming of a
>> composer. :(
>>
>>  I think I'd wisely keep the refreshlist button unless someone tells me
>> how I can reach the composer manager dialog programmatically. So that I
>> will try to synchronize my list with its widgetlistitems...
>>
>>  Thanks for all...
>>
>>
>> 2015-03-31 14:50 GMT+02:00 Matthias Kuhn :
>>
>>>  You should get a parameter containing the composer that is being
>>> deleted with composerWillBeRemoved signal. Try to use that to infer which
>>> composer has been removed. As the signal name indicates, at the time it is
>>> emitted, the composer is not deleted yet.
>>> As an alternative you may make the connection with Qt.QueuedConnection.
>>> It is possible that with this connection style you will receive the signal
>>> after deletion and are able to continue using your current update method.
>>>
>>> Best
>>> Matthias
>>>
>>>
>>> On 03/31/2015 02:04 PM, Junior Delaz wrote:
>>>
>>>Matthias,
>>>  Thanks. I just give it a try it and all goes well with composerAdded.
>>>  But not really well with composerWillBeRemoved signal. The first
>>> deletion in the composer manager does nothing and deleting a second
>>> composer does remove the first one in my list. and so on.

Re: [Qgis-developer] Re : [Qgis-user] Pyqt4 : which signal is sent when dialog comes to foreground?

2015-04-08 Thread Junior Delaz
Ahh indeed, you are right... I should have paid attention to the Class in
which I found the signal. But I was too obsessed by composerWillBeRemoved
that I thought I was still in QgisInterface.
If it can be added to QgisInterface, why not?
Any idea about my remark on Qt.QueuedConnection and architecture 64bits vs
32bits?

In the meantime, I think I'll keep the refresh button and find a simple way
to deal with the case user doesn't refresh before executing (it might not
be that hard :) ). And in this case, I also keep compatibility with all 2.x
releases.

2015-04-08 0:16 GMT+02:00 Matthias Kuhn :

>  It's in QgisApp but not in QgisInterface.
>
> It is only used internally by the app (in the composermanager for exactly
> the same purpose as you are trying to use it for AFAICS).
> Anyway, I don't see any reason not to make this available on the public
> interface as well...
>
>
> On 04/07/2015 11:51 PM, Junior Delaz wrote:
>
> But why does composerRemoved not work? You can find it in the code on
> github repo but not on QGIS API website...
>
> 2015-04-07 23:35 GMT+02:00 Matthias Kuhn :
>
>>  Oops,
>>
>> That should have been composerWillBeRemoved
>>
>> Sorry for that...
>>
>> Matthias
>>
>>
>> On 04/07/2015 10:07 PM, Junior Delaz wrote:
>>
>>  Thank you Matthias for your perseverance. It's very helpful and
>> encouraging for beginners.
>>  I have already tried composerRemoved but when loading the plugin, QGIS
>> complains :
>>
>> Impossible de charger l'extension MapsPrinter provoque une erreur lors de
>> l'appel de sa méthode initGui()
>>
>> Traceback (most recent call last):
>>   File "C:/OSGeo4W/apps/qgis/./python\qgis\utils.py", line 228, in 
>> startPlugin
>> plugins[packageName].initGui()
>>   File 
>> "C:/Users/harrissou/.qgis2/python/plugins\MapsPrinter\maps_printer.py", line 
>> 129, in initGui
>> self.iface.composerRemoved.connect(self.refreshList)
>> AttributeError: 'QgisInterface' object has no attribute 'composerRemoved'
>>
>>
>> This happens with all the versions of QGIS I use :
>> - osgeo4w 32bits (windows 8), osgeo4w 64bits (windows 7): either with QGIS 
>> 2.8, 2.8rel-dev and 2.9
>> - and Mac OS 10.9 (it is a QGIS 2.4 but composerRemoved is supposed to have 
>> been added since QGIS 2.3 [0])
>>
>>
>> About Qt.QueuedConnection, my first tests were on the Mac OS (x86-64) and 
>> Osgeo4w 64bits versions. But I never encountered crash with the 32 bits 
>> version, using the same code. Can the bug be bound to the architecture?
>>
>> [0] https://github.com/qgis/QGIS/blob/master/src/app/qgisapp.h#L1260
>>
>>
>> 2015-04-06 22:11 GMT+02:00 Matthias Kuhn :
>>
>>>  Hi Junior,
>>>
>>> The following lines work for a short test-case.
>>>
>>> def compAdded( composer ):
>>>   print composer
>>>
>>> def compRemoved( composer ):
>>>   print composer
>>>
>>> iface.composerAdded.connect( compAdded )
>>> iface.composerRemoved.connect( compRemoved )
>>>
>>> It is possible that the QueuedConnection crashes because along with it a
>>> composer is emitted which at the time the slot is executed is already
>>> deleted. That was only a possible approach which I did not test and reading
>>> your report seems unstable.
>>>
>>> Matthias
>>>
>>>
>>> On 04/06/2015 12:33 AM, Junior Delaz wrote:
>>>
>>>  Hi,
>>>  I do understand nothing.
>>>  After I read your message, Matthias, I told myself that using QT.
>>> QueuedConnection should be the easiest way. Then i wrote
>>> self.iface.composerWillBeRemoved.connect(self.refreshList,
>>> Qt.QueuedConnection)
>>> But each time i delete a composer, QGIS crashes.
>>>  So I've spent the week on reading about Qt.QueuedConnection and then
>>> signal and slots, function partial, QSignalMapper, sender trying to
>>> understand how I can catch the sender and manage to update my list. All
>>> this without success in the code.
>>>  And today, I tried again Qt.QueuedConnection, QGIS crashed. Without
>>> any changes, I tried again and it worked and continues to work. Adding and
>>> deleting composer in the composer manager echoes in my list.
>>>  I hope it will remain like that.
>>>
>>>  But now I realize that I didn't take into account the renaming of a
>>> composer. :(
>>>
>>>  I think I'

[Qgis-developer] Re : Re : [Qgis-user] Pyqt4 : which signal is sent when dialog comes to foreground?

2015-04-09 Thread Junior Delaz
 Ok thank you for the feedbaxk

Envoyé depuis mon HTC

- Reply message -
De : "Matthias Kuhn" 
Pour : "Junior Delaz" 
Cc : "qgis-developer" 
Objet : [Qgis-developer] Re : [Qgis-user] Pyqt4 : which signal is sent when
dialog comes to foreground?
Date : mer., avr. 8, 2015 23:22

On 04/08/2015 06:05 PM, Junior Delaz wrote:
> Ahh indeed, you are right... I should have paid attention to the Class
> in which I found the signal. But I was too obsessed by
> composerWillBeRemoved that I thought I was still in QgisInterface.
> If it can be added to QgisInterface, why 
> not?https://github.com/qgis/QGIS/pull/1978

> Any idea about my remark on Qt.QueuedConnection and architecture
> 64bits vs 32bits?

No I guess it's an issue of some different version or some low-level
compiler differences. If it crashes on one platform, don't use it. It's
probably trying to access a deleted object. It's not a bug but likely
rather a misuse.
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer

[Qgis-developer] Designing a plugin : TypeError raised on MacOS machines but not on Windows

2015-04-15 Thread Junior Delaz
Hi all,
I'm testing a plugin I created with Plugin Builder on different platforms
and encounter a problem I can't understand. The same piece of code works on
Windows machines but not on MacOS ones where I get this error message.


Traceback (most recent call last):
  File
"/Users/harrissou/.qgis2/python/plugins/MapsPrinter/maps_printer.py", line
369, in saveFile
progress.setLabelText(self.tr( u'Exporting maps from {}…'.format(title)
))
  File
"/Users/harrissou/.qgis2/python/plugins/MapsPrinter/maps_printer.py", line
87, in tr
return QCoreApplication.translate('MapsPrinter', message)
TypeError: function takes exactly 5 arguments (1 given)

QCoreApplication.translate is called in a tr function that is generated by
Plugin Builder :

def tr(self, message):
"""Get the translation for a string using Qt translation API.

We implement this ourselves since we do not inherit QObject.

:param message: String for translation.
:type message: str, QString

:returns: Translated version of message.
:rtype: QString
"""
# noinspection PyTypeChecker,PyArgumentList,PyCallByClass
return QCoreApplication.translate('MapsPrinter', message)

Each time I run on MacOS, I get the previous error. But I remark that I
don't get this error if in the saveFile function, instead of
progress.setLabelText(self.tr( u'Exporting maps from {}…'.format(title) ))
I put
progress.setLabelText(self.tr( 'Exporting maps from {}…'.format(title) ))

All goes well except that I can't manage special characters and therefore
can encounter an UnicodeEncodeError error (on both platforms). But it never
complains about QCoreApplication.translate function.

Traceback (most recent call last):
  File
"/Users/harrissou/.qgis2/python/plugins/MapsPrinter/maps_printer.py", line
368, in saveFile
progress.setLabelText(self.tr( 'Exporting maps from {}…'.format(title)
))
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in
position 11: ordinal not in range(128)

Any idea is welcome.
Thanks
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer