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

[Feature Request] Filter the documents #1141

Open
sebojolais opened this issue Oct 19, 2024 · 7 comments
Open

[Feature Request] Filter the documents #1141

sebojolais opened this issue Oct 19, 2024 · 7 comments

Comments

@sebojolais
Copy link
Contributor

sebojolais commented Oct 19, 2024

Is your feature request related to a problem? Please describe.
My use-case of OB leads me to got lot of documents that are not always sorted in folders. So I have a very long list of document in the document mode. Some of them are renamed with a name that make sense for me.
Currently I am not able to find quickly a document with an meaning name due to the list size.

Describe the solution you'd like
If we add a line edit to filter the documents list, it will be very convenient.
We can imagine something like this:

vokoscreenNG-2024-10-19_13-50-56.mp4

By this way, the list is shorter and I am able to find the right document.

Describe alternatives you've considered
I can imagine only one aspect of the feature that could be an issue : if the user types a string in the filter line edit and he forgets it and his action. So he will get a shorter list of documents that could leads him to think some documents are lost.

If we think that this risk could exist, we can set the filter text temporary, for example:

  • At each time we quit the document mode, we clear the filter lineedit.
  • After X seconds, we clear the filter lineedit.

Additional context
I did not find any topic about this feature on the internal project page.

@sebojolais
Copy link
Contributor Author

sebojolais commented Oct 19, 2024

I did not create a pull request before getting some feedback.
But the feature is available on this branch.

[EDIT] The PR is #1142

@letsfindaway
Copy link
Collaborator

Nice feature! And the implementation is so easy. I was just thinking whether a regular expression as you used it in the implementation is the right thing. Most users don't know much about RegExp, so a wildcard string could also be an option. But this are already the details.

@letsfindaway
Copy link
Collaborator

I can imagine only one aspect of the feature that could be an issue : if the user types a string in the filter line edit and he forgets it and his action. So he will get a shorter list of documents that could leads him to think some documents are lost.

At least we could set the property clearButtonEnabled on the QLineEdit. This is what most filters do. I would also support to clear the filter when leaving document mode, but I would not use a timer. I'm sure this would always trigger in the wrong moment.

@sebojolais
Copy link
Contributor Author

sebojolais commented Oct 20, 2024

Nice feature! And the implementation is so easy.

Yes, easy to implement it because everything was there. I had just to connect them together.

I was just thinking whether a regular expression as you used it in the implementation is the right thing. Most users don't know much about RegExp, so a wildcard string could also be an option. But this are already the details.

The Qt API to filter:

methods Qt 5 Qt 6
setFilterWildcard [x] [x]
setFilterRegularExpression [x] [x]
setFilterFixedString [x ] [x] But the behavior is not consistent
setFilterRegExp [x] [ ]

In order to support Qt5 and Qt6, so we can use only setFilterWildcard and setFilterRegularExpression.
I choose setFilterRegularExpression because it works as setFilterWildcard and it can be more powerful thanks to regular expression. There is a sentence in french to say : if you can do more, you can also do lesser. Like one KDE slogan : simple by default, powerful when needed.

At least we could set the property clearButtonEnabled on the QLineEdit. This is what most filters do.

Yes, I will do the modification to provide the clear button.
[EDIT] Done 👍

I would also support to clear the filter when leaving document mode, but I would not use a timer. I'm sure this would always trigger in the wrong moment.

I agree. But it is not yet implemented, waiting @kaamui feedback...

@letsfindaway
Copy link
Collaborator

setFilterFixedString [x ] [x] But the behavior is not consistent

Can you please explain what inconsistent behavior this has? I could not find anything problematic in the documentation.

@sebojolais
Copy link
Contributor Author

It was a mistake in my side because the implementation of the filterAcceptsRow() was too specialized for QRegularExpression. Your comment fixes it.
And because setFilterFixedString() is implemented in Qt 6 with QRegularExpression and with QRegExp in Qt 5, setFilterFixedString() did not work with Qt5.

So this comment was outdated, now setFilterFixedString() works fine with Qt5 and Qt 6. Thanks to your contribution ;-)

@sebojolais
Copy link
Contributor Author

I added a commit to implement the clearing of the filter when the document mode is enable.

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

No branches or pull requests

2 participants