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

[Macro Execute Dialog] add file name and file content filtering #10714

Merged
merged 1 commit into from Sep 18, 2023

Conversation

mwganson
Copy link
Contributor

@mwganson mwganson commented Sep 17, 2023

This adds 2 labels and 2 line edits above the macro files list box:

Find file: [LineEditFile] Find in files: [LineEditFindInFiles]
[macro file names list box]

LineEditFile text is used to search the filenames for matches to the filter the user has entered. Example: if the user types in "a" (without the quotes) then only files with "a" in the filename get listed in the list box. Regular expressions are supported. A check is done if the text entered is a valid regex expression. If it is not valid, then we use a simpler text search with QString::contains().

LineEditFindInFiles text is used to further filter the results of the first filter to only include files containing text entered in LineEditFindInFiles. This is also a regular expression search unless it's an invalid regex expression, in which case QString::contains() is used instead.

In the filtering process we skip as many loops as possible. For example, if there is no content filter then we don't bother loading and reading the files to search for matches to the empty string. If there is no filename filter, then we just apply the content filter to the unfiltered filenames.

All searches are case-insensitive.
Snip macro screenshot-4e5b33

Notice in the screenshot, the regular expression calls for file names with an _ followed by a capital letter, and yet the results contain lower case matches. I considered adding a checkbox for case-sensitive, but I don't want to clutter up the dialog.

@github-actions github-actions bot added the Core Issue or PR touches core sections (App, Gui, Base) of FreeCAD label Sep 17, 2023
@mwganson
Copy link
Contributor Author

@chennes
Copy link
Member

chennes commented Sep 18, 2023

Works great, nice feature -- thanks!

@chennes chennes merged commit 788c86e into FreeCAD:master Sep 18, 2023
7 checks passed
@mwganson
Copy link
Contributor Author

Thanks for merging. I'll go ahead and start working on the wiki documentation.

@mwganson mwganson deleted the macros_filter branch November 13, 2023 19:24
@Syres916
Copy link
Contributor

Syres916 commented Dec 6, 2023

@mwganson could you please advise why the ... button at the bottom right hand corner next to Macros Location has changed from Search for a Folder to Search for a File, surely a location is a folder and not a file???

@mwganson
Copy link
Contributor Author

mwganson commented Dec 6, 2023

@mwganson could you please advise why the ... button at the bottom right hand corner next to Macros Location has changed from Search for a Folder to Search for a File, surely a location is a folder and not a file???

QtDesigner made that change behind my back and I didn't notice it. I'll submit a PR for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Core Issue or PR touches core sections (App, Gui, Base) of FreeCAD
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants