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

Add filter/search to table viewer #2392

Merged
merged 14 commits into from
May 15, 2023

Conversation

jfoster17
Copy link
Member

@jfoster17 jfoster17 commented Apr 26, 2023

Add filter/search to the Table Viewer

table_filter

Description

This PR adds a search/filter field and component selection widget to the Table Viewer. The displayed elements in the table are then filtered based on applying re.search() to the selected component. The primary motivation is to allow the user to use the GUI to find matching rows in a dataset and create a subset from those rows. I limit the user to searching on categorical components.

This necessitated adding a TableViewerState in order to keep track of the things going into the filter.

I experimented with using QSortFilterProxyModel just for the filtering and although I was able to get a working implementation, I was then getting frequent segfaults that I was unable to diagnose. Since we are already doing sort within our custom DataTableModel it was easy enough to apply the filtering here as well. (I also that using QSortFilterProxyModel was rejected in b7a0f67 for performance concerns, but performance seemed okay for the filtering component).

Still to do:

  • Save/restore tests are failing
  • Add tests specific to the filtering

Closes #2386

@jfoster17 jfoster17 marked this pull request as draft April 26, 2023 19:33
@astrofrog
Copy link
Member

Very nice! Let me know once you would like me to review this :) One request is whether we could hide the search box by default and have a viewer tool with a 'funnel' icon for filtering that when clicked would toggle the search box?

@jfoster17
Copy link
Member Author

Very nice! Let me know once you would like me to review this :) One request is whether we could hide the search box by default and have a viewer tool with a 'funnel' icon for filtering that when clicked would toggle the search box?

I considered that. I think that it is better to have the search box by default because

  1. It does not take up that much space
  2. The "default" reason to open up a Table Viewer is to identify specific rows (perhaps the most common reason is actually to get a look at your dataset, but finding specific items is probably the second most common reason)

Thus I think the friction of requiring a user to correctly identify and toggle the 'funnel' item for the most common interaction with a table is not worth the marginal cost of having a little bit less space in the viewer for showing the data.

@jfoster17 jfoster17 marked this pull request as ready for review April 27, 2023 19:13
@jfoster17
Copy link
Member Author

@astrofrog -- this is ready for your review.

I presented at our glue weekly meeting and they were fine with having the search bar be shown all the time. The main request was to be able to toggle the regex search so that users won't be tripped up if they want to search for unescaped special characters; I have now added this button.

@jfoster17 jfoster17 requested a review from astrofrog May 4, 2023 12:45
Copy link
Member

@astrofrog astrofrog left a comment

Choose a reason for hiding this comment

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

Looks great! Just a few small things

glue/viewers/table/qt/data_viewer.py Outdated Show resolved Hide resolved
glue/viewers/table/compat.py Outdated Show resolved Hide resolved
Copy link
Member

@astrofrog astrofrog left a comment

Choose a reason for hiding this comment

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

Looks great, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Search/Filter in Table Viewer
2 participants