Skip to content
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

UrlList: allow removal of url from the list #3913

Merged
merged 30 commits into from
Nov 28, 2023
Merged

UrlList: allow removal of url from the list #3913

merged 30 commits into from
Nov 28, 2023

Conversation

payno
Copy link
Member

@payno payno commented Jul 24, 2023

when the UrlList is set editable the selection mode is set to qt.QAbstractItemView.ExtendedSelection

Here are two screenshots of the feature:

  • removing a single item
    Screenshot from 2023-07-24 15-08-19
  • removing several items ()
    Screenshot from 2023-07-24 15-08-49

closes #3911

Changelog:

  • gui.ImageStack.UrlList: allow removal of url from the list (if the list is editable only)

@payno payno requested review from vallsv and t20100 July 24, 2023 13:10
@vallsv
Copy link
Contributor

vallsv commented Jul 25, 2023

Could you put an upper case to Remove?

I also think the change of the selection mode is a bit weird. But maybe you can wait for Thomas feedback.

Also optionally you could as a del keyboard short cut (if it's not already the case), so what you already can have something fast to use.

@payno
Copy link
Member Author

payno commented Jul 25, 2023

Thanks for the review. I rename remove and added a shortcut to the action.

I agree that changing the selection mode is weird. But being able to select several item in 'non-editable' mode is weird as well.
Maybe the better solution could be to define the mode in the constructor and avoid changing it... and get a single mode for the entire widget life. To be see with @t20100 no hurry for having it right away (but if we can have it for the 2.0 it would be great...)

@vallsv
Copy link
Contributor

vallsv commented Jul 25, 2023

I have updated the description to put the Changelog as a single item. I think it is used and extracted by @t20100 scripts, so better to normalize that.

Copy link
Member

@t20100 t20100 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a few comments.
I would not modify the selection mode.

src/silx/gui/plot/ImageStack.py Outdated Show resolved Hide resolved
src/silx/gui/plot/ImageStack.py Outdated Show resolved Hide resolved
src/silx/gui/plot/ImageStack.py Outdated Show resolved Hide resolved
src/silx/gui/plot/ImageStack.py Outdated Show resolved Hide resolved
src/silx/gui/plot/ImageStack.py Outdated Show resolved Hide resolved
@t20100
Copy link
Member

t20100 commented Oct 23, 2023

I agree that changing the selection mode is weird. But being able to select several item in 'non-editable' mode is weird as well.
Maybe the better solution could be to define the mode in the constructor and avoid changing it... and get a single mode for the entire widget life.

Is UrlList part of the public API?
If so, I'd keep it generic and so not change the selection mode when switching editable mode. It would also be best located under silx.gui.widgets.
If it is private, it would be best to rename it _UrlList (with a deprecated UrlList) and then it's behavior can be tuned to whatever ImageStack needs.

@t20100 t20100 added this to the 2.0.0 milestone Oct 23, 2023
@payno
Copy link
Member Author

payno commented Oct 23, 2023

I agree that changing the selection mode is weird. But being able to select several item in 'non-editable' mode is weird as well.
Maybe the better solution could be to define the mode in the constructor and avoid changing it... and get a single mode for the entire widget life.

Is UrlList part of the public API? If so, I'd keep it generic and so not change the selection mode when switching editable mode. It would also be best located under silx.gui.widgets. If it is private, it would be best to rename it _UrlList (with a deprecated UrlList) and then it's behavior can be tuned to whatever ImageStack needs.

For me it should be public because it can have other usage.
When you say 'so not change the selection mode when switching editable mode' you mean that we should remove the 'setEditable' function from the public API- and force the widget to keep the same 'selection mode' during the entire life right ?

@t20100
Copy link
Member

t20100 commented Oct 23, 2023

you mean that we should remove the 'setEditable' function from the public API- and force the widget to keep the same 'selection mode' during the entire life right ?

No, I mean remove calls to setSelectionMode from setEditable and leave it to the user to choose how to handle the selection mode: You might want to keep the multiple selection enabled when not editable if urls corresponds to curves you want to plot or datasets you want to process for example, so I would not make a link between editable and selection mode.

And if ImageStack needs to do so, it can inherit and override setEditable.

@payno
Copy link
Member Author

payno commented Oct 24, 2023

I move UrlList to silx.gui.widgets As this is the 2.0 and as I think I am the only one using it I didn't add a deprecation warning. Please let me know if you think we should have one.

@vallsv
Copy link
Contributor

vallsv commented Oct 24, 2023

Be careful UrlList is used by silx compare no?
BUt yes, it's a good location.

@payno
Copy link
Member Author

payno commented Oct 24, 2023

Be careful UrlList is used by silx compare no? BUt yes, it's a good location.

no silx compare is using UrlSelectionTable. From what I see only ImageStack is using the UrlList

Copy link
Member

@t20100 t20100 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a few last comments.
I would be good to add UrlList to the API documentation and evenutally add missing docstrings for public members

src/silx/gui/plot/ImageStack.py Outdated Show resolved Hide resolved
src/silx/gui/widgets/UrlList.py Outdated Show resolved Hide resolved
src/silx/gui/widgets/UrlList.py Show resolved Hide resolved
src/silx/gui/widgets/UrlList.py Outdated Show resolved Hide resolved
src/silx/gui/widgets/UrlList.py Show resolved Hide resolved
src/silx/gui/widgets/UrlList.py Outdated Show resolved Hide resolved
@t20100
Copy link
Member

t20100 commented Nov 27, 2023

@payno there's a conflict to merge this + an issue spotted by CI:

venv_test\lib\site-packages\silx\gui\plot\test\testImageStack.py:38: in <module>
    from silx.gui.plot.ImageStack import ImageStack
venv_test\lib\site-packages\silx\gui\plot\ImageStack.py:150: in <module>
    class _ToggleableUrlSelectionTable(qt.QWidget):
venv_test\lib\site-packages\silx\gui\plot\ImageStack.py:201: in _ToggleableUrlSelectionTable
    def setUrls(self, urls: Iterable[DataUrl]):
E   TypeError: 'ABCMeta' object is not subscriptable

It sounds from __future__ import annotations is missing in silx\gui\plot\ImageStack.py

payno and others added 10 commits November 27, 2023 16:42
For this purpose we store `_removeAction` and add the action to the widget when necessary (if in 'editable' mode)
Co-authored-by: Thomas VINCENT <thomas.vincent@esrf.fr>
Co-authored-by: Thomas VINCENT <thomas.vincent@esrf.fr>
Co-authored-by: Thomas VINCENT <thomas.vincent@esrf.fr>
Co-authored-by: Thomas VINCENT <thomas.vincent@esrf.fr>
Co-authored-by: Thomas VINCENT <thomas.vincent@esrf.fr>
payno and others added 20 commits November 27, 2023 16:48
Co-authored-by: Thomas VINCENT <thomas.vincent@esrf.fr>
Co-authored-by: Thomas VINCENT <thomas.vincent@esrf.fr>
…Removed`

For now keep reset of the full list of urls.
Avoid resetting the full widget item

Signed-off-by: payno <henri.payno@esrf.fr>
Co-authored-by: Thomas VINCENT <thomas.vincent@esrf.fr>
Co-authored-by: Thomas VINCENT <thomas.vincent@esrf.fr>
Co-authored-by: Thomas VINCENT <thomas.vincent@esrf.fr>
Co-authored-by: Thomas VINCENT <thomas.vincent@esrf.fr>
Co-authored-by: Thomas VINCENT <thomas.vincent@esrf.fr>
Co-authored-by: Thomas VINCENT <thomas.vincent@esrf.fr>
# Conflicts:
#	src/silx/gui/plot/ImageStack.py
…recate 'setUrls' (even if '_ToggleableUrlSelectionTable' is protected)

# Conflicts:
#	src/silx/gui/plot/ImageStack.py
@payno
Copy link
Member Author

payno commented Nov 28, 2023

missing import has been added and a rebase from the main has been done for the PR.

@t20100 t20100 merged commit 8635a88 into main Nov 28, 2023
8 checks passed
@t20100 t20100 deleted the fix_3911 branch November 28, 2023 08:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Url - list: add an option to remove some url from the list
3 participants