-
Notifications
You must be signed in to change notification settings - Fork 182
More Search UI/UX Enhancements #7612
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
base: master
Are you sure you want to change the base?
Changes from all commits
c54c330
985a45d
54618d9
7146747
a75a976
343fb38
90a075c
7aec1d6
a26667e
178155c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -260,6 +260,12 @@ sexp_tree_view::sexp_tree_view(QWidget* parent) : QTreeWidget(parent), _actions( | |
| installShortcut(QKeySequence::Delete, | ||
| [](const SexpContextMenuState& s) { return s.can_delete; }, | ||
| [this]() { deleteActionHandler(); }); | ||
|
|
||
| // 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); | ||
| shortcut->setContext(Qt::WidgetShortcut); | ||
| connect(shortcut, &QShortcut::activated, this, &sexp_tree_view::editActionHandlerHelper); | ||
| } | ||
|
|
||
|
|
||
|
|
@@ -1143,8 +1149,9 @@ std::unique_ptr<QMenu> sexp_tree_view::buildContextMenu(QTreeWidgetItem* h) { | |
| popup_menu->addSeparator(); | ||
|
|
||
| auto replace_op_menu = popup_menu->addMenu(tr("Replace Operator")); | ||
|
|
||
| auto replace_data_menu = popup_menu->addMenu(tr("Replace Data")); | ||
|
|
||
| auto replace_number_act = | ||
| replace_data_menu->addAction(tr("Number"), this, [this]() { replaceNumberDataHandler(); }); | ||
| replace_number_act->setEnabled(false); | ||
|
|
@@ -1153,6 +1160,7 @@ std::unique_ptr<QMenu> sexp_tree_view::buildContextMenu(QTreeWidgetItem* h) { | |
| replace_string_act->setEnabled(false); | ||
| replace_data_menu->addSeparator(); | ||
|
|
||
| popup_menu->addAction(tr("Search for Replacement"), QKeySequence(Qt::CTRL | Qt::Key_S), this, [this]() { editActionHandlerHelper(); }); | ||
| popup_menu->addSection("Variables"); | ||
|
|
||
| auto modify_variable_act = popup_menu->addAction(tr("Add/Modify Variable"), this, [this]() { | ||
|
|
@@ -1608,11 +1616,20 @@ void sexp_tree_view::startOperatorQuickSearch(QTreeWidgetItem* item, const QStri | |
| void sexp_tree_view::filterOperatorPopup(const QString& text) | ||
| { | ||
| _opList->clear(); | ||
| SCP_set<QString> found_list; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
|
|
||
| if (text.isEmpty()) { | ||
| _opList->addItems(_opAll); | ||
| } else { | ||
| for (const auto& s : _opAll) { | ||
| if (s.contains(text, Qt::CaseInsensitive)) | ||
| if (s.startsWith(text, Qt::CaseInsensitive)){ | ||
| _opList->addItem(s); | ||
| found_list.insert(s); | ||
| } | ||
| } | ||
|
|
||
| for (const auto& s : _opAll) { | ||
| if (found_list.insert(s).second && s.contains(text, Qt::CaseInsensitive)) | ||
| _opList->addItem(s); | ||
| } | ||
| } | ||
|
|
@@ -1987,13 +2004,16 @@ void sexp_tree_view::handleDoubleClick() { | |
|
|
||
| // Helper function for making sure that search and edit are initiated consistently | ||
| void sexp_tree_view::editActionHandlerHelper(){ | ||
| item_index = get_node(currentItem()); | ||
|
|
||
| if (_model.compute_context_menu_state().can_edit_text) { | ||
| editDataActionHandler(); | ||
| } else { | ||
| openNodeEditor(currentItem()); | ||
| auto item = currentItem(); | ||
|
|
||
| // Just to be extra safe, early exit when an item is not selected | ||
| if (_currently_editing || _opPopupActive || item == nullptr || !_interface) { | ||
| return; | ||
| } | ||
|
|
||
| item_index = get_node(item); | ||
| // No longer gated to just certain types. | ||
| openNodeEditor(item); | ||
| } | ||
|
|
||
| // Public entry point for deleting the currently selected item. Simply delegates to deleteActionHandler(). | ||
|
|
||
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.