* [pyqgis] add QgsSettings.enumValue and flagValue to the bindings
these are done in pure Python since no implementation is possible in SIP
there is a dirty hack for flags since QgsMapLayerProxyModel.Filters.__qualname__
returns 'Filters' and not 'QgsMapLayerProxyModel.Filters'
* fix typo
project dirtying for the lifetime of an object
Python code can then call:
project = QgsProject.instance()
with QgsProject.blockDirtying(project):
# do something
Use QgsProjectDirtyBlocker to prevent projects being marked as
dirty while creating a new project or while loading an existing
project -- avoids the titlebar temporarily showing the project
state as unsaved while it is being loaded.
Remove support for signal based completion/termination
Also unfortunately disable a lot of the test suite as a result,
since it's not easily translatable
Switch from QtConcurrent::run to QThreadPool::start
QtConcurrent doesn't give us anyway to cancel queued but not
started tasks. QThreadPool does (and also allows us to specify
task priority)
called when the task has completed (successfully or otherwise).
This allows for simpler task design when the signal/slot
based approach is not required. Just implement run() with your
heavy lifting, and finished() to do whatever follow up stuff
should happen after the task is complete. finished is always
called from the main thread, so it's safe to do GUI operations
here.
Python based tasks using the simplified QgsTask.fromFunction
approach can now set a on_finished argument to a function
to call when the task is complete.
eg:
def calculate(task):
# pretend this is some complex maths and stuff we want
# to run in the background
return 5*6
def calculation_finished(result, value=None):
if result == QgsTask.ResultSuccess:
iface.messageBar().pushMessage(
'the magic number is {}'.format(value))
elif result == QgsTask.ResultFail:
iface.messageBar().pushMessage(
'couldn\'t work it out, sorry')
task = QgsTask.fromFunction('my task', calculate,
on_finished=calculation_finished)
QgsTaskManager.instance().addTask(task)
Multiple values can also be returned, eg:
def calculate(task):
return (4, 8, 15)
def calculation_finished(result, count=None, max=None, sum=None):
# here:
# count = 4
# max = 8
# sum = 15
task = QgsTask.fromFunction('my task', calculate,
on_finished=calculation_finished)
QgsTaskManager.instance().addTask(task)
QgsTask subclasses can now return a result (success or fail)
directly from QgsTask::run. If they do so then there's no
need for them to manually call completed() or stopped()
to report their completion.
Alternatively, tasks can also return the ResultPending value
to indicate that the task is still operating and will
manually report its completion by calling completed() or
stopped(). This may be useful for tasks which rely on external
events for completion, eg downloading a file. In this case
Qt slots could be created which are connected to the download
completion or termination and which call completed() or
stopped() to indicate the task has finished operations.
Now all evaluate/prepare/etc methods must be called using QgsExpressionContexts
Also remove most remaining traces of special variables. This brings some
user facing changes, such that existing expressions may need to be
updated if they used these old special variables (eg $scale,
$feature). These changes are noted in doc/qgis3_user_changes.dox
so that we can include them in the release notes.
* pyqtwrappers update (add QtNetwork, QtXml, QtSql, QtTest, uic)
* 2to3 updates
* move QPyNullVariant/NULL to PyQt.QtCore
* add global unicode/basestring/long for Python3
* expand QtGui, QtCore module and star exports
* Qscintilla2
* replace Set import with set builtin