-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hide newly added layer(s) when in group. Fixes #19174 #8521
Conversation
When loading a single layer QGIS will set it as invisible if the user have chosen so (new_layers_visible=false) in the settings. When a data set contains more than one layer and the user chooses "Add layers to a group" the layers are added as visible no matter what. This commit is fixing that problem for both GDAL and OGR data sets by setting both the group and its layers as invisible/unchecked. Fixes qgis#19174
Are you able to add unit tests? I can't find test related with adding layers to groups... btw it should only test if the new layer is added in a group with the correct visible configuration. Should be added in this test file: https://github.com/qgis/QGIS/blob/master/tests/src/app/testqgisapp.cpp |
Unless @nyalldawson meant "We're not setup for unit testing of QgisApp yet." I wouldn't know how to invoke the selection of one or more layers from the ...sublayers dialog and making sure to select "Add to group" so that I could check if they actually became visible/invisible as requested in the QGIS settings. |
Sorry, I did mean "we're not setup" |
No worries @nyalldawson, I just want to help this PR along and was wondering how I could unit test this, when it involves UI/user interaction :) |
@nyalldawson my goal was to automate the builds of the testing docker images, and that is done. |
I dont't think you need user interaction... DataItem in the layer list has properties as visible or not or cheked or not. You should only test that the DataItem property is correctly set (after adding the layer to a group) respect different settings configuration. |
@luipir, the user process I need to unit test is:
Is this possible to unit test? |
technically yes, it's possible using QTest [1] (you can move mouse and click) but is it really necessary? should be enough directly test only: |
@luipir,
Which is where I need to make the choices. How would I gain access to that dialog from outside |
effectively... you're right. @elpaso is just adding new test functionalities that allow to run test in a real qgis env. Waiting for this new(old) feature |
@nyalldawson looks like my little experiment is working: https://travis-ci.org/qgis/QGIS/jobs/458069882#L7361 , we should discuss if that's a useful addition to the testing framework and how to add these kind of tests to the mix. |
@elpaso will the new test functionalities allow threaded testing? I my case here, I need to test functionality within the method 'QgisApp::askUserForOGRSublayers(...)' which creates and displays a dialog where I need to make some selections before the method returns. To do this I guess I need one thread to make the test call to the above method and one thread to interact with the displayed dialog, or am I on the wrong track here? |
I wonder if we can defer the test here for a future pr. This is complex stuff and something we don't (yet) have any working examples of that contributors can use as a starting point. @luipir what do you think? |
+1 |
@luipir, @nyalldawson thanks for merging. I hope I can find something more simple to test the next time I make a PR :) |
Thanks @chau-intl -- this contribution is already much appreciated! |
tnx @chau-intl stay tuned when a real qgis test infrastructure will be working :) |
@nyalldawson, You added the |
@chau-intl you should do a PR against
|
When loading a single layer QGIS will set it as invisible if the user have chosen so in the settings (new_layers_visible=false). When a data set contains more than one layer and the user
chooses "Add layers to a group" the layers (and group) are added as visible no matter what.
This commit is fixing that problem for both GDAL and OGR data sets by setting both the group and its layers as invisible/unchecked.
Fixes #19174