Skip to content

New option in the context menu for using the value as filter #1182

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

Merged
merged 2 commits into from
Oct 21, 2017

Conversation

mgrojo
Copy link
Member

@mgrojo mgrojo commented Oct 20, 2017

Added an option in the context menu of the extended table widget for using the currently selected cell value as filter for this column. This allows quick filtering by visible values.

…cell

as filter in this column. This allows quick filtering by selected values.
Copy link
Member

@MKleusberg MKleusberg left a comment

Choose a reason for hiding this comment

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

Thank you for this PR. This is a very good idea and a pretty good and simple implementation 👍 I've found just one minor issue. I hope I can explain it well enough 😉

if (!index.isValid() || !selectionModel()->hasSelection())
return;

m_tableHeader->setFilter(index.column(), "=" + model()->data(index).toString());
Copy link
Member

Choose a reason for hiding this comment

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

One minor thing here: you should probably use the Qt::EditRole in the data() call here. We use that to get the actual, unmodified cell data instead of what is shown to the user. Without this, 1) a low 'Symbol limit in cell' option can mean that we're filtering for the truncated string, 2) filtering for a BLOB value would literally filter for 'BLOB' which doesn't seem right either, and 3) filtering for NULL values wouldn't work if the 'NULL fields Text' option is set to something other than 'NULL'.

When changing to Qt::EditRole you'll need to check for isNull() though and filter for '=NULL' if that's true. Currently this works sort of automatically but only as long as the null text is set to 'NULL' in the settings.

…get internal cell data and check for the NULL special case.
@mgrojo
Copy link
Member Author

mgrojo commented Oct 21, 2017

@MKleusberg I hope I have addressed your requests. Thanks for the feedback.

@justinclift justinclift added the enhancement Feature requests. label Oct 21, 2017
@MKleusberg
Copy link
Member

Yes, that's perfect 😄 Thanks again for your PR. It's very much appreciated 😄 If you ever feel like coding some more, you're welcome to do so. If I can somehow help you with that, just email me or open a half-finished PR.

@MKleusberg MKleusberg merged commit 5cef432 into sqlitebrowser:master Oct 21, 2017
@mgrojo
Copy link
Member Author

mgrojo commented Oct 21, 2017

Thank you. In fact I'm working on updating the Spanish translation so you can expect at least one more :-)

@MKleusberg
Copy link
Member

Awesome 😄 Good luck with that 😉

MKleusberg pushed a commit that referenced this pull request Oct 27, 2017
…ed table name is actually a view (#1196)

* Added an option in the context menu for using the currently selected cell
as filter in this column. This allows quick filtering by selected values.

* Changes to pull request #1182 requested by @MKleusberg: get internal cell data and check for the NULL special case.

* Updated Spanish translation.
Reviewed translation following guidelines the KDE Spanish Translation Team: https://es.l10n.kde.org/
Warnings raised by linguist have been solved.

* Fixed crashed when editing the display format and the currently browsed table name is actually a view.

Now it is checked the object type before the cast. This avoids the crash and the field name is obtained for each case.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature requests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants