43 Commits

Author SHA1 Message Date
Denis Rouzaud
158cd3174d forward options to base constructor 2022-04-14 08:39:15 +02:00
Denis Rouzaud
3926e97cda pyqgis implementation for Qgis.Settings.Options.SaveEnumFlagAsInt 2022-04-14 08:39:15 +02:00
Denis Rouzaud
378c7f594a apply same changes to PyQgsSettingsEntryEnumFlag 2022-03-08 14:37:59 +01:00
Denis Rouzaud
d3d91950bf fix python implementation of enum/flag setting 2022-03-01 12:09:47 +01:00
Denis Rouzaud
d06b1f1ff9 replace setVariantValue method to avoid API break 2022-03-01 12:09:47 +01:00
Hannes
1877b3634a Show full traceback on Python expression function exception 2022-02-19 09:00:34 +10:00
Denis Rouzaud
d2be87210a
fix PyQGIS API docs building (#43387)
* fix PyQGIS API docs building

The current building of the PyQGIS API doc relies on the fact that the first line is a signature.
If not given, it should be empty.

* Update qgssettingsentry.py
2021-05-25 17:26:56 +02:00
Damiano
221d9f7f01 Fix docstrings 2021-04-27 14:15:56 +02:00
Damiano
1def5e7b94 Python QgsSettingsEnum and Flag unified in QgsSettingsEnumFlag 2021-04-26 15:10:53 +02:00
Damiano
97f1a645f0 Changed SettingsType to scoped enum 2021-04-15 09:58:39 +02:00
Damiano
abb8e80c1f Added functionality to override default value for settings entries 2021-04-14 19:49:57 +02:00
Damiano
9082cfa268 Fixed trailing space 2021-04-14 18:13:51 +02:00
Damiano
4891bd6ebb Added support for settings with keys with multiple dynamic parts 2021-04-14 18:05:41 +02:00
Damiano
9762206731 Removed Settings struct / unified Enum/Flag logic in one base class 2021-04-14 15:41:49 +02:00
Damiano
3c5f9b1e91 Python implementation for QgsSettingsEntryEnum/Flag and fixed docstrings 2021-04-07 14:02:08 +02:00
Nyall Dawson
4fe99d8d6c Add better __repr__ methods for QgsDateTimeRange, QgsDateRange 2021-03-25 08:01:51 +10:00
Nyall Dawson
1040fe8705 Don't silently swallow exceptions in python context managers
Notably this causes processing modules to silently fail to load
without any warnings if the required dependancies (such as pyscopg2)
are not installed
2021-03-04 07:39:47 +10:00
Nyall Dawson
278ccb8e85 Fix crash when trying to use meta enums on some platforms
Keeping references to static meta objects and meta enums around seems
to avoid the crash
2020-11-14 14:37:38 +10:00
Denis Rouzaud
cdc2f7fde8
fix PyQGIS docs for QgsProviderMetadata (#37552)
fixes https://github.com/qgis/pyqgis/issues/55
2020-07-03 11:36:11 +02:00
Nyall Dawson
82c298a703 Show startup profile timings in developer/debugging tools panel
Instead of hiding this information on the console, let's expose it
to users. QGIS startup times have been an ongoing issue for a number
of years, so let's help provide users with some tools to help
track down what's causing these (*hint* it's probably a plugin *hint*)
2020-05-19 04:35:34 +10:00
Matthias Kuhn
a5f557f085 Fix escaping issues 2020-05-05 23:22:12 +02:00
Nyall Dawson
a06e707a15 Better repr for QgsProcessingFeatureSourceDefinition 2020-03-29 05:56:23 +10:00
Juergen E. Fischer
b830a4a448 qgsfunction: replace deprecated inspect.getargspec() to inspect.getfullargspec() 2019-11-07 22:47:08 +01:00
Matthias Kuhn
abf9880182 Cleanup python code 2019-11-02 15:01:59 +01:00
Matthias Kuhn
52f0994bf6 Various fixes 2019-11-02 15:01:59 +01:00
Matthias Kuhn
208ea9b033 More Q_GLOBAL_STATIC
Because it's pure fun
2019-11-02 15:01:59 +01:00
Matthias Kuhn
a50287514b Q_GLOBAL_STATIC for QgsDataProvider 2019-11-02 15:01:59 +01:00
Martin Dobias
90910b0447 Patch QgsProviderMetadata in Python to avoid API break
In C++ we do not support QgsProviderMetadata(key, description, createFunc) anymore,
but for python code we can have a patched class that still supports createFunc.

Why not keep the variant with createFunc in C++ as well? Because... SIP!
With newly added virtual methods in QgsProviderMetadata, SIP started to generate
a sip-specific subclass to handle derived classes in Python, however due to the variant
with PyObject* and custom MethodCode it was getting confused about what constructors
are available in C++ and failing to compile.
2019-06-21 18:27:36 +02:00
Nyall Dawson
48d2a37057 [FEATURE] New line symbol type: Hash line
This line symbol type is designed to replicate the ArcGIS Hash Line
symbol layer type. It allows for a repeating line segment to be
drawn over the length of a feature, with a line-sub symbol used
to render each individual segment.

To reduce code duplication, this is heavily based off the current
line marker symbol layer, since the functionality is almost
identical (draw some sub symbol at some interval along a line).
Accordingly, I've split off QgsMarkerLineSymbolLayer to move
as much of the common functionality as possible to a new abstract
base class, so that only the actual marker/line segment rendering
occurs in the marker line/hash line subclasses.

This also gives the hash line all the existing placement options
permissible for marker lines -- e.g. first/last vertex, mid points,
regular intervals, etc.

The hash line length and angle can have data defined overrides,
which are evaluated per-line segment, allowing for the hash line
to change size and angle over the length of a single rendered
feature.
2019-04-03 02:31:27 +10:00
Nyall Dawson
fdfe0cee23 [api][needs-docs] Allow registering PyQGIS using a nice decorator syntax
This allows nice and simple, elegant construction of checks for
Python.

To use, Python based checks should use the decorator syntax:

  from qgis.core import check

  @check.register(type=QgsAbstractValidityCheck.TypeLayoutCheck)
  def my_layout_check(context, feedback):
    results = ...
    return results

Or, a more complete example. This one throws a warning when attempting
to export a layout with a map item set to the Web Mercator projection:

  @check.register(type=QgsAbstractValidityCheck.TypeLayoutCheck)
  def layout_map_crs_choice_check(context, feedback):
    layout = context.layout
    results = []
    for i in layout.items():
      if isinstance(i, QgsLayoutItemMap) and i.crs().authid() == 'EPSG:3857':
        res = QgsValidityCheckResult()
        res.type = QgsValidityCheckResult.Warning
        res.title='Map projection is misleading'
        res.detailedDescription='The projection for the map item {} is set to <i>Web Mercator (EPSG:3857)</i> which misrepresents areas and shapes. Consider using an appropriate local projection instead.'.format(i.displayName())
        results.append(res)

    return results
2019-01-11 09:51:04 +10:00
Matthias Kuhn
a1b6a2cb7f Fix docs 2018-07-02 06:16:49 -05:00
Matthias Kuhn
45fdd0fb31 Add documentation for @qgsfunction 2018-07-01 06:31:26 -05:00
Matthias Kuhn
60730abba7 Add missing import 2018-06-30 09:40:13 -05:00
Matthias Kuhn
773138cf57 Add handlesnull parameter to @qgsfunction
Up to date it was not possible to create a function that handles NULL values with the
@qgsfunction decorator. As soon as any parameter was NULL, the return value would also
be NULL.

Example of a function that returns a value now with a NULL paramter and would have returned NULL before

```
@qgsfunction(args=-1, group='Custom', handlesnull=True)
def mean_value(vals, feature, parent):
    valid_vals = [val for val in vals if val != NULL]
    return sum(valid_vals)/len(valid_vals)
```

[FEATURE]
2018-06-30 09:40:13 -05:00
Denis Rouzaud
ad00020366 QgsSettings.enumValue cast to enum 2018-06-21 05:29:16 -08:00
Denis Rouzaud
01681aba89 fix missing import 2018-06-21 05:29:16 -08:00
Denis Rouzaud
7dfec1fde0 [pyqgis] add misssing QgsSettings.setEnumValue
also fix sections in enumValue and flagValue
2018-06-21 05:29:16 -08:00
Nyall Dawson
1395dc0e9c Add missing license headers 2018-06-04 11:30:32 +10:00
Denis Rouzaud
7cb18cd5f1 [sipify] allow to define python operator in headers
sipify will take care of injecting them in python/{module}/__init__.py
2018-06-03 11:07:09 -08:00
Denis Rouzaud
b4ec9a3190
[pyqgis] add QgsSettings.enumValue and flagValue to the bindings (#7024)
* [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
2018-05-18 09:25:12 -08:00
Denis Rouzaud
deccf205cf
[pyqgis] add method to retrieve metaEnum from an enum value or type (#7023) 2018-05-18 06:47:18 -08:00
Denis Rouzaud
95ecea897a move additions from top __init__ to core.__init__ 2018-05-16 11:29:28 -04:00
Denis Rouzaud
6e33bdcdc4 [pyqgis] move qgis.core tricks to their own python file in additions folder
this makes the code much easier to read
2018-05-14 18:00:39 -04:00