<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<div id="divtagdefaultwrapper" dir="ltr" style="font-size: 12pt; color: rgb(0, 0, 0); font-family: Calibri, Helvetica, sans-serif, "EmojiFont", "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;">
<p><font size="2"><span style="font-size:10pt">Hi Nyall,</span></font></p>
<p><font size="2"><span style="font-size:10pt"><br>
</span></font></p>
<p><font size="2"><span style="font-size:10pt">> CORE classes must be completely non-gui, so that they work without issue on non-gui platforms like QGIS server (also for clients which have their own GUI, such as QFIeld/Input).</span></font><font size="2"><span style="font-size:10pt"><br>
</span></font></p>
<p><font size="2"><span style="font-size:10pt"><br>
</span></font></p>
<p><font size="2"><span style="font-size:10pt">That sounds totally reasonable.<br>
</span></font></p>
<p><font size="2"><span style="font-size:10pt"><br>
</span></font></p>
<p><font size="2"><span style="font-size:10pt">> Again, none of the core classes are allowed any GUI component, and the correct approach to handle this particular situation is to move that code from the provider level up to app level, specifically via the QgsDataItemGuiProvider
 class.<br>
</span></font></p>
<p><font size="2"><span style="font-size:10pt"><br>
</span></font></p>
<p><font size="2"><span style="font-size:10pt">I had a look into it. If I understood it correctly the class provides a framework for functions to be registered and called by other functions placed in the gui.
<br>
</span></font></p>
<p><font size="2"><span style="font-size:10pt">But what to do when a progress dialog needs to be raised or an application state needs to be read? (see description below)<br>
</span></font></p>
<p><font size="2"><span style="font-size:10pt"><br>
</span></font></p>
<p><font size="2"><span style="font-size:10pt">> So my question would be: why do you need to raise a user-facing message from QgsOgrProvider::extent?</span></font></p>
<p><br>
</p>
<p><font size="2">- One idea was is to inform the user via a simple progress dialog in cases of very time-consuming extent calculations for large layers</font><font style="font-family:Calibri,sans-serif,serif,"EmojiFont"" size="2" face="Calibri,sans-serif"><span style="font-size:11pt"><font style="font-family:Arial,sans-serif,serif,"EmojiFont"" size="1" face="Arial,sans-serif" color="#1F497D"><span style="font-size:8pt; color:rgb(0,0,0)"><font size="2">
 (I observed calc time ranges from 10 min to hours) of what's going on and that QGIS hasn't crashed yet. The design would practically allow this to be implemented in the provider and I also saw the use of <span>QProgressDialog</span> in other parts of the core
 components code. If that's also not how it is intended to be then I'd appreciate a quick hint of how it is intended to be.<br>
</font></span></font></span></font></p>
<p><font style="font-family:Calibri,sans-serif,serif,"EmojiFont"" size="2" face="Calibri,sans-serif"><span style="font-size:11pt"><font style="font-family:Arial,sans-serif,serif,"EmojiFont"" size="1" face="Arial,sans-serif" color="#1F497D"><span style="font-size:8pt; color:rgb(0,0,0)"><font size="2"><br>
</font></span></font></span></font></p>
<p><font style="font-family:Calibri,sans-serif,serif,"EmojiFont"" size="2" face="Calibri,sans-serif"><span style="font-size:11pt"><font style="font-family:Arial,sans-serif,serif,"EmojiFont"" size="1" face="Arial,sans-serif" color="#1F497D"><span style="font-size:8pt; color:rgb(0,0,0)"><font size="2">-
 The second idea was to display an additional message dependant on the current QGIS instance's project state (whether it's loading/loaded/saving/closed) for which I had planned to introduce an enum
<span>QgisApp::ProjectState</span> alongside with a private variable <span>mProjectState</span> and a public function
<span>QgisApp::getProjectState()</span>. So would I make this accessible to the provider?<br>
</font></span></font></span></font></p>
<p><font style="font-family:Calibri,sans-serif,serif,"EmojiFont"" size="2" face="Calibri,sans-serif"><span style="font-size:11pt"><font style="font-family:Arial,sans-serif,serif,"EmojiFont"" size="1" face="Arial,sans-serif" color="#1F497D"><span style="font-size:8pt; color:rgb(0,0,0)"><font size="2"><br>
</font></span></font></span></font></p>
<p><font style="font-family:Calibri,sans-serif,serif,"EmojiFont"" size="2" face="Calibri,sans-serif"><span style="font-size:11pt"><font style="font-family:Arial,sans-serif,serif,"EmojiFont"" size="1" face="Arial,sans-serif" color="#1F497D"><span style="font-size:8pt; color:rgb(0,0,0)"><font size="2">Best
 regards<br>
</font></span></font></span></font></p>
</div>
<p><font size="2"><font face="Arial,sans-serif">Tobias</font></font></p>
<div dir="ltr" style="font-size: 12pt; color: rgb(0, 0, 0); font-family: Calibri, Helvetica, sans-serif, "EmojiFont", "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;">
<font style="font-family:Calibri,sans-serif,serif,"EmojiFont"" size="2" face="Calibri,sans-serif"><span style="font-size:11pt"><font style="font-family:Arial,sans-serif,serif,"EmojiFont"" size="1" face="Arial,sans-serif" color="#1F497D"><span style="font-size:8pt; color:rgb(0,0,0)">--</span></font></span></font>
<div id="Signature">
<div id="divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif,"EmojiFont","Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols">
<div><span style="color:rgb(0,0,0); font-size:8pt"></span>
<div style="margin:0"><font style="font-family:Calibri,sans-serif,serif,"EmojiFont"" size="2" face="Calibri,sans-serif"><span style="font-size:11pt"><font style="font-family:Arial,sans-serif,serif,"EmojiFont"" size="1" face="Arial,sans-serif" color="#1F497D"><span style="font-size:8pt; color:rgb(0,0,0)"> </span></font></span></font></div>
<span style="color:rgb(0,0,0); font-size:8pt"></span>
<div style="margin:0"><font style="font-family:Calibri,sans-serif,serif,"EmojiFont"" size="2" face="Calibri,sans-serif"><span style="font-size:11pt"><font style="font-family:Arial,sans-serif,serif,"EmojiFont"" size="1" face="Arial,sans-serif" color="#1F497D"><span style="font-size:8pt; color:rgb(0,0,0)">ZAE
 Bayern</span></font></span></font></div>
<span style="color:rgb(0,0,0); font-size:8pt"></span>
<div style="margin:0"><font style="font-family:Calibri,sans-serif,serif,"EmojiFont"" size="2" face="Calibri,sans-serif"><span style="font-size:11pt"><font style="font-family:Arial,sans-serif,serif,"EmojiFont"" size="1" face="Arial,sans-serif" color="#1F497D"><span style="font-size:8pt; color:rgb(0,0,0)">Dipl.-Ing.
</span></font><font style="font-family:Arial,sans-serif,serif,"EmojiFont"" size="1" face="Arial,sans-serif" color="#1F497D"><span style="font-size:8pt; color:rgb(0,0,0)">Tobias Schmetzer</span></font></span></font></div>
<span style="color:rgb(0,0,0); font-size:8pt"></span>
<div style="margin:0"><font style="font-family:Calibri,sans-serif,serif,"EmojiFont"" size="2" face="Calibri,sans-serif"><span style="font-size:11pt"><font style="font-family:Arial,sans-serif,serif,"EmojiFont"" size="1" face="Arial,sans-serif" color="#1F497D"><span style="font-size:8pt; color:rgb(0,0,0)">Systementwicklung
</span></font><font style="font-family:Arial,sans-serif,serif,"EmojiFont"" size="1" face="Arial,sans-serif" color="black"><span style="font-size:8pt; color:rgb(0,0,0)">|
</span></font><font style="font-family:Arial,sans-serif,serif,"EmojiFont"" size="1" face="Arial,sans-serif" color="#1F497D"><span style="font-size:8pt; color:rgb(0,0,0)">Systems Engineering</span></font></span></font></div>
<span style="color:rgb(0,0,0); font-size:8pt"></span>
<div style="margin:0"><font style="font-family:Calibri,sans-serif,serif,"EmojiFont"" size="2" face="Calibri,sans-serif"><span style="font-size:11pt"><font style="font-family:Arial,sans-serif,serif,"EmojiFont"" size="1" face="Arial,sans-serif" color="#1F497D"><span style="font-size:8pt; color:rgb(0,0,0)">Bereich
 Energiespeicherung </span></font><font style="font-family:Arial,sans-serif,serif,"EmojiFont"" size="1" face="Arial,sans-serif" color="black"><span style="font-size:8pt; color:rgb(0,0,0)">|
</span></font><font style="font-family:Arial,sans-serif,serif,"EmojiFont"" size="1" face="Arial,sans-serif" color="#1F497D"><span style="font-size:8pt; color:rgb(0,0,0)">Division Energy Storage</span></font></span></font></div>
<span style="color:rgb(0,0,0); font-size:8pt"></span>
<div style="margin:0"><font style="font-family:Calibri,sans-serif,serif,"EmojiFont"" size="2" face="Calibri,sans-serif"><span style="font-size:11pt"><font style="font-family:Arial,sans-serif,serif,"EmojiFont"" size="1" face="Arial,sans-serif" color="#1F497D"><span style="font-size:8pt; color:rgb(0,0,0)">Walther-Meißner-Straße
 6</span></font></span></font></div>
<span style="color:rgb(0,0,0); font-size:8pt"></span>
<div style="margin:0"><font style="font-family:Calibri,sans-serif,serif,"EmojiFont"" size="2" face="Calibri,sans-serif"><span style="font-size:11pt"><font style="font-family:Arial,sans-serif,serif,"EmojiFont"" size="1" face="Arial,sans-serif" color="#1F497D"><span style="font-size:8pt; color:rgb(0,0,0)">85748
 Garching</span></font></span></font></div>
<span style="color:rgb(0,0,0); font-size:8pt"></span>
<div style="margin:0"><font style="font-family:Calibri,sans-serif,serif,"EmojiFont"" size="2" face="Calibri,sans-serif"><span style="font-size:11pt"><font style="font-family:Arial,sans-serif,serif,"EmojiFont"" size="1" face="Arial,sans-serif" color="#1F497D"><span style="font-size:8pt; color:rgb(0,0,0)"> </span></font></span></font></div>
<span style="color:rgb(0,0,0); font-size:8pt"></span>
<div style="margin:0"><font style="font-family:Calibri,sans-serif,serif,"EmojiFont"" size="2" face="Calibri,sans-serif"><span style="font-size:11pt"><font style="font-family:Arial,sans-serif,serif,"EmojiFont"" size="1" face="Arial,sans-serif" color="#1F497D"><span style="font-size:8pt; color:rgb(0,0,0)">Tel.:
 +49 89 329442-</span></font><font style="font-family:Arial,sans-serif,serif,"EmojiFont"" size="1" face="Arial,sans-serif" color="#1F497D"><span style="font-size:8pt; color:rgb(0,0,0)"><span style="font-size:8pt">65</span><span style="font-size:8pt"></span></span></font></span></font></div>
<span style="color:rgb(0,0,0); font-size:8pt"></span>
<div style="margin:0"><font style="font-family:Calibri,sans-serif,serif,"EmojiFont"" size="2" face="Calibri,sans-serif"><span style="font-size:11pt"><font style="font-family:Arial,sans-serif,serif,"EmojiFont"" size="1" face="Arial,sans-serif" color="#1F497D"><span style="font-size:8pt; color:rgb(0,0,0)">Fax:
 +49 89 329442-12</span></font></span></font></div>
<span style="color:rgb(0,0,0); font-size:8pt"></span>
<div style="margin:0"><font style="font-family:Calibri,sans-serif,serif,"EmojiFont"" size="2" face="Calibri,sans-serif"><span style="font-size:11pt"><font style="font-family:Arial,sans-serif,serif,"EmojiFont"" size="1" face="Arial,sans-serif" color="#1F497D"><span style="font-size:8pt; color:rgb(0,0,0)">Mobil
</span></font><font style="font-family:Arial,sans-serif,serif,"EmojiFont"" size="1" face="Arial,sans-serif" color="black"><span style="font-size:8pt; color:rgb(0,0,0)">|
</span></font><font style="font-family:Arial,sans-serif,serif,"EmojiFont"" size="1" face="Arial,sans-serif" color="#1F497D"><span style="font-size:8pt; color:rgb(0,0,0)">Cell: +49
</span></font><font style="font-family:Arial,sans-serif,serif,"EmojiFont"" size="1" face="Arial,sans-serif" color="#1F497D"><span style="font-size:8pt; color:rgb(0,0,0)">151 56964756</span></font></span></font></div>
<span style="color:rgb(0,0,0); font-size:8pt"></span>
<div style="margin:0"><font style="font-family:Calibri,sans-serif,serif,"EmojiFont"" size="2" face="Calibri,sans-serif"><span style="font-size:11pt"><font style="font-family:Arial,sans-serif,serif,"EmojiFont"" size="1" face="Arial,sans-serif" color="#1F497D"><span style="font-size:8pt; color:rgb(0,0,0)">tobias</span></font><font style="font-family:Arial,sans-serif,serif,"EmojiFont"" size="1" face="Arial,sans-serif" color="#1F497D"><span style="font-size:8pt; color:rgb(0,0,0)">.</span></font><font style="font-family:Arial,sans-serif,serif,"EmojiFont"" size="1" face="Arial,sans-serif" color="#1F497D"><span style="font-size:8pt; color:rgb(0,0,0)">schmetzer</span></font><font style="font-family:Arial,sans-serif,serif,"EmojiFont"" size="1" face="Arial,sans-serif" color="#1F497D"><span style="font-size:8pt; color:rgb(0,0,0)">@zae-bayern.de</span></font></span></font></div>
<span style="color:rgb(0,0,0); font-size:8pt"></span>
<div style="margin:0"><font style="font-family:Calibri,sans-serif,serif,"EmojiFont"" size="2" face="Calibri,sans-serif"><span style="font-size:11pt"><font style="font-family:Arial,sans-serif,serif,"EmojiFont"" size="1" face="Arial,sans-serif" color="#1F497D"><span style="font-size:8pt; color:rgb(0,0,0)">https://www.zae-bayern.de</span></font></span></font></div>
<span style="color:rgb(0,0,0); font-size:8pt"></span>
<div style="margin:0"><font style="font-family:Calibri,sans-serif,serif,"EmojiFont"" size="2" face="Calibri,sans-serif"><span style="font-size:11pt"><font style="font-family:Arial,sans-serif,serif,"EmojiFont"" size="1" face="Arial,sans-serif" color="#1F497D"><span style="font-size:8pt; color:rgb(0,0,0)"> </span></font></span></font></div>
<span style="color:rgb(0,0,0); font-size:8pt"></span>
<div style="margin:0"><font style="font-family:Calibri,sans-serif,serif,"EmojiFont"" size="2" face="Calibri,sans-serif"><span style="font-size:11pt"><font style="font-family:Arial,sans-serif,serif,"EmojiFont"" size="1" face="Arial,sans-serif" color="#1F497D"><span style="font-size:8pt; color:rgb(0,0,0)">ZAE
 Bayern</span></font></span></font></div>
<span style="color:rgb(0,0,0); font-size:8pt"></span>
<div style="margin:0"><font style="font-family:Calibri,sans-serif,serif,"EmojiFont"" size="2" face="Calibri,sans-serif"><span style="font-size:11pt"><font style="font-family:Arial,sans-serif,serif,"EmojiFont"" size="1" face="Arial,sans-serif" color="#1F497D"><span style="font-size:8pt; color:rgb(0,0,0)">Bayerisches
 Zentrum für Angewandte Energieforschung e. V. </span></font><font style="font-family:Arial,sans-serif,serif,"EmojiFont"" size="1" face="Arial,sans-serif" color="black"><span style="font-size:8pt; color:rgb(0,0,0)">| Bavarian Center for Applied Energy Research</span></font></span></font></div>
<span style="color:rgb(0,0,0); font-size:8pt"></span>
<div style="margin:0"><font style="font-family:Calibri,sans-serif,serif,"EmojiFont"" size="2" face="Calibri,sans-serif"><span style="font-size:11pt"><font style="font-family:Arial,sans-serif,serif,"EmojiFont"" size="1" face="Arial,sans-serif" color="#1F497D"><span style="font-size:8pt; color:rgb(0,0,0)">Vorstand
</span></font><font style="font-family:Arial,sans-serif,serif,"EmojiFont"" size="1" face="Arial,sans-serif" color="black"><span style="font-size:8pt; color:rgb(0,0,0)">|
</span></font><font style="font-family:Arial,sans-serif,serif,"EmojiFont"" size="1" face="Arial,sans-serif" color="#1F497D"><span style="font-size:8pt; color:rgb(0,0,0)">Board: Dr. Andreas Hauer (Vorsitzender
</span></font><font style="font-family:Arial,sans-serif,serif,"EmojiFont"" size="1" face="Arial,sans-serif" color="black"><span style="font-size:8pt; color:rgb(0,0,0)">|
</span></font><font style="font-family:Arial,sans-serif,serif,"EmojiFont"" size="1" face="Arial,sans-serif" color="#1F497D"><span style="font-size:8pt; color:rgb(0,0,0)">Chairman), Dr. Hans-Peter Ebert</span></font></span></font></div>
<span style="color:rgb(0,0,0); font-size:8pt"></span>
<div style="margin:0"><font style="font-family:Calibri,sans-serif,serif,"EmojiFont"" size="2" face="Calibri,sans-serif"><span style="font-size:11pt"><font style="font-family:Arial,sans-serif,serif,"EmojiFont"" size="1" face="Arial,sans-serif" color="#1F497D"><span style="font-size:8pt; color:rgb(0,0,0)">Sitz
</span></font><font style="font-family:Arial,sans-serif,serif,"EmojiFont"" size="1" face="Arial,sans-serif" color="black"><span style="font-size:8pt; color:rgb(0,0,0)">|
</span></font><font style="font-family:Arial,sans-serif,serif,"EmojiFont"" size="1" face="Arial,sans-serif" color="#1F497D"><span style="font-size:8pt; color:rgb(0,0,0)">Registered Office: Würzburg</span></font></span></font></div>
<span style="color:rgb(0,0,0); font-size:8pt"></span>
<div style="margin:0"><font style="font-family:Calibri,sans-serif,serif,"EmojiFont"" size="2" face="Calibri,sans-serif"><span style="font-size:11pt"><font style="font-family:Arial,sans-serif,serif,"EmojiFont"" size="1" face="Arial,sans-serif" color="#1F497D"><span style="font-size:8pt; color:rgb(0,0,0)">Registergericht
</span></font><font style="font-family:Arial,sans-serif,serif,"EmojiFont"" size="1" face="Arial,sans-serif" color="black"><span style="font-size:8pt; color:rgb(0,0,0)">|
</span></font><font style="font-family:Arial,sans-serif,serif,"EmojiFont"" size="1" face="Arial,sans-serif" color="#1F497D"><span style="font-size:8pt; color:rgb(0,0,0)">Register Court: Amtsgericht Würzburg</span></font></span></font></div>
<span style="color:rgb(0,0,0); font-size:8pt"></span>
<div style="margin:0"><font style="font-family:Calibri,sans-serif,serif,"EmojiFont"" size="2" face="Calibri,sans-serif"><span style="font-size:11pt"><font style="font-family:Arial,sans-serif,serif,"EmojiFont"" size="1" face="Arial,sans-serif" color="#1F497D"><span style="font-size:8pt; color:rgb(0,0,0)">Registernummer
</span></font><font style="font-family:Arial,sans-serif,serif,"EmojiFont"" size="1" face="Arial,sans-serif" color="black"><span style="font-size:8pt; color:rgb(0,0,0)">|
</span></font><font style="font-family:Arial,sans-serif,serif,"EmojiFont"" size="1" face="Arial,sans-serif" color="#1F497D"><span style="font-size:8pt; color:rgb(0,0,0)">Register Number: VR 1386</span></font></span></font></div>
<span style="color:rgb(0,0,0); font-size:8pt"></span>
<div style="margin:0"><font style="font-family:Calibri,sans-serif,serif,"EmojiFont"" size="2" face="Calibri,sans-serif"><span style="font-size:11pt"><font style="font-family:Arial,sans-serif,serif,"EmojiFont"" size="1" face="Arial,sans-serif" color="#1F497D"><span style="font-size:8pt; color:rgb(0,0,0)"> </span></font></span></font></div>
<span style="color:rgb(0,0,0); font-size:8pt"></span>
<div style="margin:0"><font style="font-family:Calibri,sans-serif,serif,"EmojiFont"" size="2" face="Calibri,sans-serif"><span style="font-size:11pt"><font style="font-family:Arial,sans-serif,serif,"EmojiFont"" size="1" face="Arial,sans-serif" color="#1F497D"><span style="font-size:8pt; color:rgb(0,0,0)">Hinweise
 zum Datenschutz unter https://www.zae-bayern.de/datenschutz</span></font></span></font></div>
<span style="color:rgb(0,0,0); font-size:8pt"></span></div>
<br>
</div>
</div>
<br>
<br>
<div style="color:rgb(0,0,0)">
<div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="x_divRplyFwdMsg" dir="ltr"><font style="font-size:11pt" face="Calibri, sans-serif" color="#000000"><b>Von:</b> Nyall Dawson <nyall.dawson@gmail.com><br>
<b>Gesendet:</b> Montag, 7. März 2022 00:03<br>
<b>An:</b> Schmetzer, Tobias<br>
<b>Cc:</b> qgis-developer@lists.osgeo.org<br>
<b>Betreff:</b> Re: [QGIS-Developer] How to access QgisApp::instance() from a core class</font>
<div> </div>
</div>
</div>
<font size="2"><span style="font-size:10pt">
<div class="PlainText">On Sun, 6 Mar 2022 at 00:16, Schmetzer, Tobias via QGIS-Developer<br>
<qgis-developer@lists.osgeo.org> wrote:<br>
><br>
> Hello everyone,<br>
><br>
><br>
> I would like to access QgisApp::instance() (src/app/qgisapp.cpp) from a provider like QgsOgrProvider::extent() (src/core/providers/ogr/qgsogrprovider.cpp.<br>
<br>
You can't, by design.<br>
<br>
CORE classes must be completely non-gui, so that they work without<br>
issue on non-gui platforms like QGIS server (also for clients which<br>
have their own GUI, such as QFIeld/Input).<br>
<br>
Just to be super-blunt: There is 100% no way this will EVER change! ;)<br>
<br>
<br>
> When looking for this information I found some inactivating preprocessor code block comments like this one (qgswfsdataitems.cpp):<br>
><br>
> #if 0<br>
><br>
>     // TODO: how to emit message from provider (which does not know about QgisApp)<br>
>     QgisApp::instance()->messageBar()->pushMessage( tr( "Cannot copy style" ),<br>
>         errorMsg,<br>
>         Qgis::MessageLevel::Critical, messageTimeout() );<br>
> #endif<br>
<br>
This is very old code (hence why it's disabled). Again, none of the<br>
core classes are allowed any GUI component, and the correct approach<br>
to handle this particular situation is to move that code from the<br>
provider level up to app level, specifically via the<br>
QgsDataItemGuiProvider class.<br>
<br>
So my question would be: why do you need to raise a user-facing<br>
message from QgsOgrProvider::extent?<br>
<br>
Nyall<br>
</div>
</span></font></div>
</div>
</div>
</body>
</html>