<div dir="ltr">Hi,<br><br><div><div class="gmail_extra"><div class="gmail_quote">On Thu, Feb 28, 2013 at 10:11 AM, Bernhard Ströbl <span dir="ltr"><<a href="mailto:bernhard.stroebl@jena.de" target="_blank">bernhard.stroebl@jena.de</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi Larry,<br>
<br>
Am 28.02.2013 17:38, schrieb Larry Shaffer:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Hi,<br>
<br>
On Thu, Feb 28, 2013 at 12:01 AM, Bernhard Ströbl<br>
<<a href="mailto:bernhard.stroebl@jena.de" target="_blank">bernhard.stroebl@jena.de</a> <mailto:<a href="mailto:bernhard.stroebl@jena.de" target="_blank">bernhard.stroebl@jena.<u></u>de</a>>> wrote:<br>
<br>
    Hi Kelly,<br>
<br>
    I am doing something similar for my company but I am developing it<br>
    for the next release, because master has<br>
    QgsComposition::__<u></u>loadFromTemplate method, which 1.8 has not.<br>
<br>
    However to get a new printComposer you can use<br>
    self.iface.__<u></u>actionPrintComposer().trigger(<u></u>__)<br>
    which adds a new composer to the project's list of composers.<br>
<br>
<br>
In master branch, and in the last week, the actionPrintComposer() (i.e.<br>
QgisApp::createNewComposer) action will now present the user with a<br>
dialog to help choose a unique composer title, before the composer is<br>
created. Since iface.actionPrintComposer().<u></u>trigger() still appears to be<br>
the best means of programmatically creating a new composer, this<br>
presents an issue.<br>
</blockquote>
<br>
hmm, my master dates from Febr. 21, have to update...<br>
Is this a needed feature? I mean any text processing software creates "document1" or "unknown1" if you hit the new document button<br></blockquote><div><br></div><div>IMO, yes. With the text processing software you note, it creates the "document 1" with the understanding that the user will eventually have to save the file, thereby prompting the user to change the default name.<br>
<br>With composers there is no prompted saving; they are automatically saved into the project with the default name. This causes the user to have to find a means of changing the name later, e.g. in the Composer Manager, and in the meantime they have no hint at what content "Composer #n" contains. With a prompt, the user can define the name up front, using existing names to build on (from editable combobox) and use the Manager later, only if needed.<br>
 <br></div><div>Again, we can add a preference in Options for turning it on/off (with a default of on), but that would have to be checked and turned off programmatically in scripts if there is no other means of generating a blank composer.<br>
</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
There are a couple of possible solutions:<br>
<br>
* Expose Qgis::createNewComposer in iface (which returns pointer to new<br>
composer). Maybe adding duplicateComposer, deleteComposer and<br>
deletePrintComposers, as well. Makes the most sense to me. New PyQGIS<br>
code would be different from 1.8.<br>
</blockquote>
<br>
+1<br>
the actionPrintComposer().trigger(<u></u>) thing is not so straightforward<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
* Add a preference in Options for turning it on/off (e.g. [x] Prompt for<br>
composer name), and maybe simple get/set methods to QgisApp and iface.<br>
New PyQGIS code would require a couple of lines of additional code if<br>
the prompt was not to be shown.<br>
<br>
* Use a different action in the GUI than actionPrintComposer(). Might<br>
lead to some confusion, having semi-redundant actions. New PyQGIS code<br>
remains identical to 1.8.<br>
<br>
<br>
    But AFAIK you can not load a template into it with 1.8<br>
<br>
<br>
I think this is possible. QgsComposition has readXML and addItemsFromXML<br>
exposed in 1.8 [0]. If you look at loadFromTemplate[1], the initial<br>
routines are for clearing a composition's existing items (btw: I think<br>
that is bad. IMO loading from a template should always be in a fresh<br>
composer).<br>
</blockquote>
<br>
Not neccessarily, I sometimes happen to work on a composer (created from template) but I somehow screw things up and then it is nice to restart again without leaving the composer. This is the behavior of QGIS, so IMHO it is ok if loadFromTemplate behaves in the same manner.<br>
</blockquote><div><br></div><div>Maybe a parameter option to the function, or a new function, and a new action in the menu, e.g. New from Template, to accompany Load Template? I think 'load' should always mean 'replace existing'. I envision a user accidentally clearing all their work in the current composer, when they thought they were getting a fresh composer based upon the template.<br>
<br></div><div>I don't think "template load replaces existing" is the behavior of QGIS at the QMainWindow level, maybe with styles, etc. For example, when loading a project template, the menu action is New Project from Template (there is no load option). I think we need the distinction, and option, between new and load with templates, especially when they are auto-saved, or users may lose work.<br>
</div><div><br></div><div>Regards,<br><br></div><div>Larry<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Not a concern if you are starting with a fresh composer<br>
anyway. After that, there is substitution replacement (not sure if<br>
relevant to 1.8), reading of the XML doc, then adding the items, all of<br>
which should be doable in Python, unless I am mistaken.<br>
</blockquote>
<br>
I did not fiddle with those 1.8 methods, but thinking about it it should even be possible to do substitution using PyQt methods, i.e.<br>
1) read file<br>
2) do substitutions<br>
3) create the XMLDoc<br>
4) load into composer<br>
<br>
I will check and report back<br>
<br>
Bernhard<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
[0] <a href="http://qgis.org/api/1.8/classQgsComposition.html" target="_blank">http://qgis.org/api/1.8/<u></u>classQgsComposition.html</a><br>
[1]<br>
<a href="https://github.com/qgis/Quantum-GIS/blob/master/src/core/composer/qgscomposition.cpp#L382" target="_blank">https://github.com/qgis/<u></u>Quantum-GIS/blob/master/src/<u></u>core/composer/qgscomposition.<u></u>cpp#L382</a><br>

<br>
<br>
Regards,<br>
<br>
Larry<br>
<br>
    Bernhard<br>
<br>
    Am 28.02.2013 03:38, schrieb Kelly Thomas:<br>
<br>
        Hello,<br>
<br>
<br>
        I am building a python plugin for QGIS 1.8 and am trying to<br>
        manipulate the map composers.<br>
<br>
        The goal is to load a template, customise a few elements, and<br>
        then leave the composer window up for the user to modify / print<br>
        / etc.<br>
<br>
        I know that current composers can be listed by calling<br>
        qgis.utils.iface.__<u></u>activeComposers().<br>
<br>
        However I have been unable to create or destroy composer windows<br>
        without resorting to spoofing user input to the composer manager<br>
        dialog!<br>
<br>
        Is there a technique by which I can add/remove composers<br>
        programmatically?<br>
<br>
        Thanks,<br>
        Kelly Thomas<br>
        ______________________________<u></u>___________________<br>
        Qgis-developer mailing list<br>
        <a href="mailto:Qgis-developer@lists.osgeo.org" target="_blank">Qgis-developer@lists.osgeo.org</a><br>
        <mailto:<a href="mailto:Qgis-developer@lists.osgeo.org" target="_blank">Qgis-developer@lists.<u></u>osgeo.org</a>><br>
        <a href="http://lists.osgeo.org/__mailman/listinfo/qgis-__developer" target="_blank">http://lists.osgeo.org/__<u></u>mailman/listinfo/qgis-__<u></u>developer</a><br>
        <<a href="http://lists.osgeo.org/mailman/listinfo/qgis-developer" target="_blank">http://lists.osgeo.org/<u></u>mailman/listinfo/qgis-<u></u>developer</a>><br>
<br>
<br>
        __________ Information from ESET Mail Security, version of virus<br>
        signature database 8058 (20130227) __________<br>
<br>
        The message was checked by ESET Mail Security.<br>
        <a href="http://www.eset.com" target="_blank">http://www.eset.com</a><br>
<br>
<br>
<br>
<br>
    __________ Information from ESET Mail Security, version of virus<br>
    signature database 8058 (20130227) __________<br>
<br>
    The message was checked by ESET Mail Security.<br>
    <a href="http://www.eset.com" target="_blank">http://www.eset.com</a><br>
<br>
<br>
    ______________________________<u></u>___________________<br>
    Qgis-developer mailing list<br>
    <a href="mailto:Qgis-developer@lists.osgeo.org" target="_blank">Qgis-developer@lists.osgeo.org</a> <mailto:<a href="mailto:Qgis-developer@lists.osgeo.org" target="_blank">Qgis-developer@lists.<u></u>osgeo.org</a>><br>

    <a href="http://lists.osgeo.org/__mailman/listinfo/qgis-__developer" target="_blank">http://lists.osgeo.org/__<u></u>mailman/listinfo/qgis-__<u></u>developer</a><br>
    <<a href="http://lists.osgeo.org/mailman/listinfo/qgis-developer" target="_blank">http://lists.osgeo.org/<u></u>mailman/listinfo/qgis-<u></u>developer</a>><br>
<br>
<br>
</blockquote>
<br>
<br>
<br>
__________ Information from ESET Mail Security, version of virus signature database 8061 (20130228) __________<br>
<br>
The message was checked by ESET Mail Security.<br>
<a href="http://www.eset.com" target="_blank">http://www.eset.com</a><br>
<br>
<br>
</blockquote></div><br></div></div></div>