pyapp-kit / superqt

Missing widgets and components for Qt-python
https://pyapp-kit.github.io/superqt/
BSD 3-Clause "New" or "Revised" License
210 stars 38 forks source link

Port base item model for `SelectableEventedList` backed `ListView` from napari #105

Open alisterburt opened 2 years ago

alisterburt commented 2 years ago

This PR ports the _BaseEventedItemModel, an adapter between the QAbstractItemModel and our SelectableEventedList, from napari to superqt. This is a first step towards a psygnal backed QtListView in superqt

Original code in napari: https://github.com/napari/napari/blob/main/napari/_qt/containers/_base_item_model.py

The code has been updated to work with the psygnal SelectableEventedList, requiring only minimal changes.

I didn't reimplement the process_event hook, I wasn't exactly sure when this would be needed and how it fit with psygnal/qt style events

codecov[bot] commented 2 years ago

Codecov Report

Base: 85.30% // Head: 81.83% // Decreases project coverage by -3.47% :warning:

Coverage data is based on head (60ccb84) compared to base (6ce87d4). Patch coverage: 0.00% of modified lines in pull request are covered.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #105 +/- ## ========================================== - Coverage 85.30% 81.83% -3.48% ========================================== Files 31 34 +3 Lines 2607 2719 +112 ========================================== + Hits 2224 2225 +1 - Misses 383 494 +111 ``` | [Impacted Files](https://codecov.io/gh/pyapp-kit/superqt/pull/105?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pyapp-kit) | Coverage Δ | | |---|---|---| | [src/superqt/listview/\_\_init\_\_.py](https://codecov.io/gh/pyapp-kit/superqt/pull/105/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pyapp-kit#diff-c3JjL3N1cGVycXQvbGlzdHZpZXcvX19pbml0X18ucHk=) | `0.00% <0.00%> (ø)` | | | [src/superqt/listview/\_base\_item\_model.py](https://codecov.io/gh/pyapp-kit/superqt/pull/105/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pyapp-kit#diff-c3JjL3N1cGVycXQvbGlzdHZpZXcvX2Jhc2VfaXRlbV9tb2RlbC5weQ==) | `0.00% <0.00%> (ø)` | | | [src/superqt/listview/\_list\_model.py](https://codecov.io/gh/pyapp-kit/superqt/pull/105/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pyapp-kit#diff-c3JjL3N1cGVycXQvbGlzdHZpZXcvX2xpc3RfbW9kZWwucHk=) | `0.00% <0.00%> (ø)` | | | [src/superqt/utils/\_code\_syntax\_highlight.py](https://codecov.io/gh/pyapp-kit/superqt/pull/105/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pyapp-kit#diff-c3JjL3N1cGVycXQvdXRpbHMvX2NvZGVfc3ludGF4X2hpZ2hsaWdodC5weQ==) | `98.03% <0.00%> (+1.96%)` | :arrow_up: | Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pyapp-kit). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pyapp-kit)

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

tlambert03 commented 2 years ago

hey @alisterburt ... man, I swear I commented on this before, but I guess not :joy: I would love to have this in here. if you're still interested, i think copying over the relevant tests from napari would be a great sanity check to see whether this is working. If you don't have time, I can probably pick it up

alisterburt commented 2 years ago

Ello ello! Thanks for the ping and sorry for shelving this for so long, the curse of trying to contribute things I don't strictly need 😆

I've got a bit of time now so will move the tests over 🙂

alisterburt commented 2 years ago

might be being stupid but the only tests I could see were the listmodel test so I ported that over and fixed a minor bug. I likely won't have much more time for this in the next few days so please feel free to push it over the line if you have momentum!

tlambert03 commented 2 years ago

thanks for what you did! :)