<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=us-ascii" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 8.00.6001.18876"></HEAD>
<BODY>
<DIV><FONT size=2 face=Arial><SPAN class=076184518-01032010>Hi
</SPAN></FONT></DIV>
<DIV><FONT size=2 face=Arial><SPAN
class=076184518-01032010></SPAN></FONT> </DIV>
<DIV><FONT size=2 face=Arial><SPAN class=076184518-01032010>I'm wanting to
provide a clearer message to users when layers don't load properly.
</SPAN></FONT></DIV>
<DIV><FONT size=2 face=Arial><SPAN
class=076184518-01032010></SPAN></FONT> </DIV>
<DIV><FONT size=2 face=Arial><SPAN class=076184518-01032010>The particular case
I'm interested in is where a symoblogy V2 plugin renderer is not
installed. I'd like this to generate a message saying something like,
"Renderer named ... could not be loaded for layer ..... Perhaps you need to
install a plugin?"... or something like that! Even better would be to
generate the message, but render the layer with a default
renderer.</SPAN></FONT></DIV>
<DIV><FONT size=2 face=Arial><SPAN
class=076184518-01032010></SPAN></FONT> </DIV>
<DIV><FONT size=2 face=Arial><SPAN class=076184518-01032010>At the moment
failing to load gives a generic error message "Unable to load one or more ...
" leaving it unclear as to why the layer isn't
loading.</SPAN></FONT></DIV>
<DIV><FONT size=2 face=Arial><SPAN
class=076184518-01032010></SPAN></FONT> </DIV>
<DIV><FONT size=2 face=Arial><SPAN class=076184518-01032010>I'm happy to code
and submit a patch to do this, but I'm looking for some input on
architecture. </SPAN></FONT></DIV>
<DIV><FONT size=2 face=Arial><SPAN
class=076184518-01032010></SPAN></FONT> </DIV>
<DIV><FONT size=2 face=Arial><SPAN class=076184518-01032010>The main issue I see
with implementing it is that the error is only detectable deep in the loading
code - in the </SPAN></FONT><FONT size=2 face=Arial><SPAN
class=076184518-01032010>QgsFeatureRendererV2::load function. This is
where the error (or warning) is generated. The old symbology equivalent
generated an error message in QgsVectorLayer::readSymbology, which is passed
back to the QgsVectorLayer::readXml, but then ignored. To be useful it
would need to get passed up from there through QgsMapLayer::readXML to
QgsProject::read(layerNode), to QgsProject::_getmapLayers, and finally
QgsProject::read where the mBadLayerHandler->handleBadLayers is called to
report the problem.</SPAN></FONT></DIV>
<DIV><FONT size=2 face=Arial><SPAN
class=076184518-01032010></SPAN></FONT> </DIV>
<DIV><FONT size=2 face=Arial><SPAN class=076184518-01032010>So I think what I
need to do, with this architecture, is:</SPAN></FONT></DIV>
<DIV><FONT size=2 face=Arial><SPAN
class=076184518-01032010></SPAN></FONT> </DIV>
<DIV><FONT size=2 face=Arial><SPAN class=076184518-01032010>1) Replace the
QList<QDomNode> in the _getMapLayers result set with a
QList(QgsBadLayerError) structure which includes a QString error message (if we
want to bury QString that deeply into the code), a layer name, and possibly a
status (warning/failure).</SPAN></FONT></DIV>
<DIV><FONT size=2 face=Arial><SPAN
class=076184518-01032010></SPAN></FONT> </DIV><SPAN
class=076184518-01032010>
<DIV><FONT size=2 face=Arial><SPAN class=076184518-01032010>2) Pass a
by-reference string into each call from _getMapLayers down to retrieve the error
message. In fact this may need to be a more complex structure than a
string, as the resulting error message will be a parameterised string (eg "Could
not load renderer [name] ..."), and in order to be translatable to other
languages presumably I'd need to keep the template text and the parameters
separated until it gets to the GUI. I'm not sure of a good way of doing
this.</SPAN></FONT></DIV>
<DIV><FONT size=2 face=Arial><SPAN
class=076184518-01032010></SPAN></FONT> </DIV>
<DIV><FONT face=Arial><FONT size=2><SPAN class=076184518-01032010>3</SPAN>)
Update the QgsProjectBadLayerGuiHandler and default handler to use this
information to provide more helpful messages</FONT></FONT></DIV>
<DIV><SPAN class=076184518-01032010><FONT size=2
face=Arial></FONT></SPAN> </DIV>
<DIV><SPAN class=076184518-01032010><FONT size=2 face=Arial>Does this seem like
a good approach? Can you suggest a better one? Would it be supported
as a patch? </FONT></SPAN></DIV>
<DIV><SPAN class=076184518-01032010><FONT size=2
face=Arial></FONT></SPAN> </DIV>
<DIV><SPAN class=076184518-01032010><FONT size=2 face=Arial>Thanks for any
input/suggestions</FONT></SPAN></DIV>
<DIV><SPAN class=076184518-01032010><FONT size=2
face=Arial>Chris</FONT></SPAN></SPAN></DIV>
<DIV>
<HR>
<DIV>This message contains information, which is confidential and may be subject
to legal privilege. <BR>If you are not the intended recipient, you must not
peruse, use, disseminate, distribute or copy this message.<BR>If you have
received this message in error, please notify us immediately (Phone 0800 665 463
or <A href="mailto:sinfo@linz.govt.nz">info@linz.govt.nz</A> ) and destroy the
original message.</DIV>
<DIV>LINZ accepts no responsibility for changes to this email, or for any
attachments, after its transmission from LINZ.</DIV>
<DIV> </DIV>
<DIV><STRONG>Thank you.</STRONG> <BR></DIV>
<HR>
</DIV>
</BODY></HTML>