4313 Commits

Author SHA1 Message Date
Nyall Dawson
e1eef7ed19 Allow use of QgsPointXY/QgsReferencedPointXY for point parameter values 2017-09-24 12:09:38 +10:00
Nyall Dawson
8902d5f48f Merge pull request #5244 from nyalldawson/proc_misc
[processing] Misc test related fixes
2017-09-24 10:37:06 +10:00
Nyall Dawson
fe98fe1131 Merge pull request #5236 from nyalldawson/field_default
[processing] Allow setting default values for field parameters in models
2017-09-24 07:58:39 +10:00
Alexander Bruy
f60d8885c9 [processing] more fixes for tests creation 2017-09-24 07:49:55 +10:00
Nyall Dawson
92e481e7c3 Fix creation of SAGA tests 2017-09-24 07:48:46 +10:00
Juergen E. Fischer
9e36fd9c6d remove app startup tests depending on removed options configpath and --optionspath 2017-09-23 19:38:42 +02:00
Nyall Dawson
e3f128b55f Expand test coverage of compound curves 2017-09-23 16:16:13 +10:00
Vincent Mora
02e3916bf5 [FEATURE] layer refresh and trigger actions on provider notification
[needs-docs]

In vector layer properties (only usefull for postgres datasources)

**in the rendering tab**

A "Refresh layer on notification" checkbox has been added to refresh layer
on provider notification.

For a postgres datasource, if a `NOTIFY qgis;` command is issued by one of the database clients,
a refresh of the layer will occur.

If the "Only if message is" checkbox is checked, the notification will trigger the refresh only
if the message contend is the one specified, e.g. if the user enters
"refresh" in the box right next to the "Only if message is" checkbox,
then a `NOTIFY qgis, 'refresh';` command in the datatabase will trigger
a layer refresh, but `NOTIFY qgis;` or `NOTIFY qgis, 'something else';`
won't.

**in the actions tab**

A column "On notification" has been added, the action editor widget
a has text field "Execute if notification message matches" to
specify a filter for notification from the provider. The filter is a
Perl-type regex.

Note that, as opposed to the "layer refresh" that

Exemple:
  - QGIS side "Execute if notification message matches" `^trigger my action`
  - Postgres side: `NOTIFY qgis, 'trigger my action'` will trigger the action
  - Postgres side: `NOTIFY qgis, 'trigger my action some additional data'` will trigger the action
  - Postgres side: `NOTIFY qgis, 'do not trigger my action some additional data'` will NOT trigger the action

Please note that if the `^`, which means "starts with",  in `^trigger my action` had been ommited,
the last notification would have triggered the action because the
notification message contains the `trigger my action`

A new qgis variable `notification_message` is available for use in
actions, it holds the contend of the notification message. To continue
with the previous exemple, if the action is of python type with the code:

```python
print('[% @notification_message %]')
```

The three notifictions above will result in two printed lines
```
trigger my action
trigger my action some additional data
```

User Warning:

For postgres providers, if the "Refresh layer on notification" is checked, or if one layer action has
"On notification" specified, a new connection to the database is made to
listen to postgres notifications. This olds even if transaction groups
are enabled at the project level.

Note that once the notification mechanism is started in a QGIS
session, it will not stop, even if there is no more need for it (Refresh
layer on notification" unchecked and no "On notification" in any
action). Consequently the connection listening to notification will
remain open.

IMPLEMENTATION DETAILS:

A notify signal has been added to the abstract QgsVectorDataProvider
along with a setListening function that enables/disble the notification
mechanism.

For the moment only the postgres provider implements the notification.

QgsAction has a notificationMessage member function that holds the regex
to match to trigger action

QgsActionManager becomes a QObject and is doing the filtering and execute actions on
notifications.

The notification notion extends beyond SRGBD servers (postgres and oracle at
least have the notify) and the "watch file" in the delimitedtext
provider could also benefit from this interface.

For the postgres provider a thread is created with a second connection
to the database. This thread is responsible for listening postgres
notifications.

It would be nice to avoid the creation of one listening chanel per
provider in the case transaction groups are enabled.

Please note that when listening starts (a thread and connection is
created in the postgres provider) it cannot be stopped by removing the
connected actions or unchecking the refresh check box. Indeed, since we
don't know who needs the signals, we dont't want to stop the service.

The service will not restart in the next qgis session though.

If this behavior is not deemed appropriate, we could use
```
int QObject::receivers ( const char * signal ) const
```
and have QgsDataProvider::setListening return a bool to tell the caller
if the signal has actually been closed.
2017-09-22 12:51:51 +02:00
Nyall Dawson
22eddfd4c0 Merge pull request #5238 from nyalldawson/geometry_coverage
Geometry unit test coverage + fixes
2017-09-22 17:18:39 +10:00
Nyall Dawson
cbca7c97bc Boost test coverage of geometry classes 2017-09-22 15:41:41 +10:00
Nyall Dawson
c41dca937c Port processing combineFields to c++ 2017-09-22 15:19:32 +10:00
Nyall Dawson
b4a798e892 Setting field for QgsFieldComboBox should be case-insensitive 2017-09-22 11:39:17 +10:00
Larry Shaffer
559973739c Merge pull request #5202 from dmarteau/fix_ln_option_OSX
Execute ln command with GNU compatible options in install phase
2017-09-21 19:37:42 -06:00
Nyall Dawson
9d6d60727a Expand unit tests for compound curves 2017-09-22 09:54:23 +10:00
Nyall Dawson
f268ccc837 Expand test coverage for compound curves 2017-09-22 09:54:23 +10:00
Nyall Dawson
e7b08d520e Expand geometry test coverage 2017-09-22 09:54:23 +10:00
Nyall Dawson
c77afeda9a Expand geometry unit test coverage 2017-09-22 09:54:23 +10:00
Matthias Kuhn
9caa7224cd Merge pull request #5230 from m-kuhn/taskWaitForFinished
QgsTask::waitForFinished without event loop
2017-09-21 18:35:43 +02:00
Matthias Kuhn
8f2c885436
[travis] Disable flaky test
See https://travis-ci.org/qgis/QGIS/jobs/278224577
https://github.com/qgis/QGIS/pull/5230#issuecomment-331189552
2017-09-21 18:00:46 +02:00
Sandro Mani
a67194df77 [OGR] Add orig_ogc_fid as last field to avoid changing field order 2017-09-21 11:17:12 +02:00
Sandro Mani
4ce2cf1744 [OGR] Add workaround for OGRSQL not recognizing the column name returned by OGR_L_GetFIDColumn 2017-09-21 10:50:39 +02:00
Nyall Dawson
20e1d72007 Merge pull request #5209 from nyalldawson/geometry_coverage
[WIP] Extend geometry classes unit test coverage
2017-09-19 22:15:14 +10:00
Nyall Dawson
38cc5703d7 Improve test cases 2017-09-19 21:18:06 +10:00
Matthias Kuhn
8d34023d6e Merge pull request #5216 from m-kuhn/vectorFileWriter
Make error message accessible for python in vector file writer
2017-09-19 13:17:09 +02:00
Nyall Dawson
6f5d9c94a6 Fix some leaks in geometry tests (valgrind noise) 2017-09-19 20:36:16 +10:00
Matthias Kuhn
d1d26e96b0
Fix test 2017-09-19 12:24:01 +02:00
Nyall Dawson
9526d487ad Astyle 2017-09-19 19:39:54 +10:00
Matthias Kuhn
44e32e18c0
Fix tests for new QgsVectorFileWriter python API 2017-09-19 11:00:49 +02:00
Nyall Dawson
b744820bc3 Boost test coverage of geometry classes 2017-09-19 17:22:33 +10:00
Nyall Dawson
1540448334 Boost test coverage of geometry classes 2017-09-19 17:22:33 +10:00
Nyall Dawson
bb425e4540 Cleaner signature for QgsAbstractGeometry::closestSegment 2017-09-19 17:22:33 +10:00
Nyall Dawson
1f40f62011 Expand geometry test coverage 2017-09-19 17:22:33 +10:00
Nyall Dawson
fd3a38fcd8 More tests 2017-09-19 17:22:33 +10:00
Nyall Dawson
5bb359db90 Boost test coverage of geometry classes 2017-09-19 17:22:33 +10:00
Nyall Dawson
9b6e79cd18 Expand QgsTriangle test coverage 2017-09-19 17:22:32 +10:00
Nyall Dawson
a15340fc2c Extend geometry test coverage 2017-09-19 17:22:32 +10:00
Nyall Dawson
d3db082cd2 Extend unit tests for QgsPolygonV2, QgsPoint 2017-09-19 17:22:32 +10:00
Nyall Dawson
6b07b9bbfb Extend geometry unit test coverage 2017-09-19 17:22:32 +10:00
Nyall Dawson
328fc9cb8d Consistently use unsigned int for QgsRegularPolygon 2017-09-19 17:22:32 +10:00
rldhont
10fbfb3737 [Server] WMS GetPrint refactoring - Update tests 2017-09-19 07:34:33 +02:00
rldhont
7c1d397288 [Server] WMS GetPrint refactoring 2017-09-19 07:34:33 +02:00
rldhont
bb61db2e8d [Server] test: add response content in message when it's not an image 2017-09-19 07:34:33 +02:00
Nyall Dawson
dd441f6154 [processing] A non-optional multiple enum parameter must have at
least one choice selected to be valid
2017-09-16 09:59:13 +10:00
Vincent Mora
f63c302420 [FEATURE] Add undo and redo on transaction groups (#4765)
* [FEATURE] adds undo/redo for transaction groups

[needs-docs] the undo/redo now works with transcation groups. Just check
that there is no restriction in the transaction groups doc concerning
undo.

related to #14799

The undo/redo is implemented using SAVEPOINT.

The QgsTransaction interface has been enlarged to allow savepoints
creation and management. The savepoint is destroyed on
rollbackToSavepoint to have the same behavior has the sql ROLLBACK TO
SAVEPPOINT.

To avoid the creation of a savepoint for each feature modified in bulk
editing (e.g. paste, field calculator) the logic is a bit complicated: the
savepoint is created on QgsVectorLayer::editCommandStarted and the first
actual undo command (QgsVectorLayerUndoPassthroughCommand) is
responsible for the re-creation of the savepoint in case of undo-redo.
Since the behavior must be different in case edition doesn't take place
inside an edit command, a member function has been added to
QgsVectorLayer to expose the mEditCommandActive state.

Another (commented) tricky bit is the modification of the database
structure on add/delete attributes. On undo, the attribute is removed
before the rollback to savepoint, i.e. there is a useless ALTER TABLE
issued to restore the structure just before restoring it with the
ROLLBACK TO SAVEPOINT. This is necessary to make the provider
aware of the change of structure. It could be nicer/cleaner to have a way
to reload providers metadata.

The editPaste function has also been modified to use addFeatures instead of
addFeature (plural/singular), this is at the expense of an additional "cpy"
of the clipboard in memory, but it should improve perf with postgis provider.

* fixup operator aliases
2017-09-15 14:55:43 +02:00
David Marteau
5534d743f1 Execute ln command with GNU compatible options
On some OSX macport installation, GNU commands may be used in favor
    of native commands and 'make install' fail with
         'ln: invalid option -- 'h'"

    As BSD ln support the GNU -n option as an equivalent of the -h option
    it shoud be preferred over the specific BSD option.
2017-09-15 09:27:31 +02:00
Nyall Dawson
9b112284c7 Add method to recover extent parameter CRS 2017-09-15 14:09:27 +10:00
Nyall Dawson
cfdc3c71e7 Use geometry of reproject extent parameters for more accurate clipping 2017-09-15 08:35:42 +10:00
Nyall Dawson
74565e22de Nicer display of rectangle parameter values 2017-09-15 08:34:13 +10:00
Nyall Dawson
ae8bc04b6c Allow use of Qgs(Referenced)Rectangle for processing extent parameter values
And add a new target CRS argument to parameterAsExtent. If set, and
the source CRS of the rectangle parameter can be determined, then
the returned value will be the rectangle automatically reprojected
to the desired target CRS.
2017-09-15 08:33:45 +10:00
Nyall Dawson
4ec1b4b348 [processing] Transparently map 'qgis' algorithms to 'native' algorithms
This allows us to freely move algorithms from the qgis python library
to the c++ native provider without breaking API or existing models
2017-09-14 11:41:38 +10:00