Skip to content

More Search UI/UX Enhancements#7612

Open
JohnAFernandez wants to merge 10 commits into
scp-fs2open:masterfrom
JohnAFernandez:More-search-fixes
Open

More Search UI/UX Enhancements#7612
JohnAFernandez wants to merge 10 commits into
scp-fs2open:masterfrom
JohnAFernandez:More-search-fixes

Conversation

@JohnAFernandez

@JohnAFernandez JohnAFernandez commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

This has a few upgrades to the sexp search system, including:

  • Adding "Search for Replacement" to context (right-click) menu
  • Adding Ctrl+S as a shortcut to initiate search (and item edit)
  • Re-enabling search for numeric sexps (which seems to have been disabled by accident, understandable from how big the original PR was)
  • Keeps the search from picking results that have nothing to do with the searched string
  • Search results will now show strings that start with the search string first. More work would be required to further improve search, like sorting by how soon the search string appears in the text.
  • Double click will also now initiate search or item edit, depending on the node type, if there are no children to expand.

Each feature was individually tested, and I'm open to feedback on adjustments.

Fixes #7604

@JohnAFernandez JohnAFernandez self-assigned this Jul 16, 2026
@JohnAFernandez JohnAFernandez added the enhancement A new feature or upgrade of an existing feature to add additional functionality. label Jul 16, 2026
@JohnAFernandez JohnAFernandez added the qtfred A feature or issue related to qtFred. label Jul 16, 2026
@github-project-automation github-project-automation Bot moved this to Work In Progress (PRs) in qtFRED2 Jul 16, 2026
@JohnAFernandez JohnAFernandez changed the title More search fixes More Search UI/UX Enhancements Jul 16, 2026

@MjnMixael MjnMixael left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Minor things. Looks overall pretty good.

void sexp_tree_view::filterOperatorPopup(const QString& text)
{
_opList->clear();
SCP_set<QString> found_list;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Unused variable? Alternatively if you used it for what it seems like was intended you can change this whole lookup from O(n2) into just O(n), I think.

for (const auto& s : _opAll) {
    if (s.startsWith(text, Qt::CaseInsensitive)) {
        _opList->addItem(s);
        found_list.insert(s);
    }
}
for (const auto& s : _opAll) {
    if (s.contains(text, Qt::CaseInsensitive) && found_list.count(s) == 0)
        _opList->addItem(s);
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for pointing this out. Again, I think my mental state was a little frazzled. Not that we need a ton of speed here, but I added the check before comparing the text.

Comment thread code/missioneditor/sexp_tree_model.cpp Outdated

// find the best operator
int best = sexp_match_closest_operator(str, opf);
int best = sexp_match_closest_operator(str, opf, 10);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should this magic number be a constant? Personally I'd put it at the top of the file with TREE_NODE_INCREMENT and a comment explaining it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Definitely, I think my ADHD was flaring when writing this.


item_index = get_node(item);
// No longer gated to just certain types.
openNodeEditor(currentItem());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could pass item here as you've already got currentItem()


// This keyboard shortcut does not need as much state checking because the helper
// handles security checks and what to call, and any node should work here.
auto* shortcut = new QShortcut(QKeySequence(Qt::CTRL | Qt::Key_S), this);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just a question.. did you verify this doesn't fall through to the editor and call a save action? I don't think it will but just want to be sure.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It still saves the mission after the dialog is closed.

@github-project-automation github-project-automation Bot moved this from Work In Progress (PRs) to In Review (PRs) in qtFRED2 Jul 20, 2026
Items that begin with the search string should be prioritized before those that simply contain the search string.
I didn't see any crashes, but this matches the pattern of other keyboard shortcuts.
The working code existed already
This limits matches on operator searches by setting a minimum size that a string match has to meet.  Function returns -1 on failure, and the warning has been removed to allow this behavior.
This allows ctrl+s (which can be listed instead of spacebar) to initiate search.  There is a new menu item added as well.
We want the item to be inserted here, not ignored.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement A new feature or upgrade of an existing feature to add additional functionality. qtfred A feature or issue related to qtFred.

Projects

Status: In Review (PRs)

Development

Successfully merging this pull request may close these issues.

Sexp View Search Enhancements

2 participants