Skip to content

Commit 4bf703c

Browse files
committed
fix ship and wing sexp tree editors in qtfred
1 parent ce73dd2 commit 4bf703c

3 files changed

Lines changed: 28 additions & 4 deletions

File tree

qtfred/src/ui/dialogs/ShipEditor/ShipEditorDialog.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@ ShipEditorDialog::ShipEditorDialog(FredView* parent, EditorViewport* viewport)
3636
connect(viewport->editor, &Editor::currentObjectChanged, this, &ShipEditorDialog::update);
3737
connect(viewport->editor, &Editor::objectMarkingChanged, this, &ShipEditorDialog::update);
3838

39+
connect(ui->arrivalTree, &sexp_tree_view::modified, this, &ShipEditorDialog::on_arrivalTree_modified);
40+
connect(ui->arrivalTree, &sexp_tree_view::helpChanged, this, &ShipEditorDialog::on_arrivalTree_helpChanged);
41+
connect(ui->arrivalTree, &sexp_tree_view::miniHelpChanged, this, &ShipEditorDialog::on_arrivalTree_miniHelpChanged);
42+
connect(ui->departureTree, &sexp_tree_view::modified, this, &ShipEditorDialog::on_departureTree_modified);
43+
connect(ui->departureTree, &sexp_tree_view::helpChanged, this, &ShipEditorDialog::on_departureTree_helpChanged);
44+
connect(ui->departureTree, &sexp_tree_view::miniHelpChanged, this, &ShipEditorDialog::on_departureTree_miniHelpChanged);
45+
3946
// Column One
4047

4148
connect(ui->cargoCombo->lineEdit(), (&QLineEdit::editingFinished), this, &ShipEditorDialog::cargoChanged);
@@ -82,6 +89,7 @@ void ShipEditorDialog::hideEvent(QHideEvent* e)
8289
void ShipEditorDialog::showEvent(QShowEvent* e)
8390
{
8491
_model->initializeData();
92+
updateUI(true);
8593
QDialog::showEvent(e);
8694
}
8795

qtfred/src/ui/dialogs/WingEditorDialog.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ WingEditorDialog::WingEditorDialog(FredView* parent, EditorViewport* viewport)
3535
updateUi();
3636
});
3737

38+
connect(ui->arrivalTree, &sexp_tree_view::modified, this, &WingEditorDialog::on_arrivalTree_modified);
39+
connect(ui->arrivalTree, &sexp_tree_view::helpChanged, this, [this](const QString& help) { ui->helpText->setPlainText(help); });
40+
connect(ui->arrivalTree, &sexp_tree_view::miniHelpChanged, this, [this](const QString& help) { ui->HelpTitle->setText(help); });
41+
connect(ui->departureTree, &sexp_tree_view::modified, this, &WingEditorDialog::on_departureTree_modified);
42+
connect(ui->departureTree, &sexp_tree_view::helpChanged, this, [this](const QString& help) { ui->helpText->setPlainText(help); });
43+
connect(ui->departureTree, &sexp_tree_view::miniHelpChanged, this, [this](const QString& help) { ui->HelpTitle->setText(help); });
44+
3845
refreshAllDynamicCombos();
3946
updateUi();
4047

qtfred/src/ui/widgets/sexp_tree_view.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,11 +1089,11 @@ std::unique_ptr<QMenu> sexp_tree_view::buildContextMenu(QTreeWidgetItem* h) {
10891089
for (j = 0; j < static_cast<int>(op_menu.size()); j++) {
10901090
if (op_menu[j].id == get_category(Operators[i].value)) {
10911091
auto add_act = add_op_submenu[j]->addAction(QString::fromStdString(Operators[i].text),
1092-
this, [this, i]() { _actions.add_or_replace_operator(i, 0); });
1092+
this, [this, i]() { _actions.add_or_replace_operator(i, 0); Q_EMIT modified(); });
10931093
add_act->setEnabled(add_en);
10941094

10951095
auto replace_act = replace_op_submenu[j]->addAction(QString::fromStdString(Operators[i].text),
1096-
this, [this, i]() { _actions.add_or_replace_operator(i, 1); });
1096+
this, [this, i]() { _actions.add_or_replace_operator(i, 1); Q_EMIT modified(); });
10971097
replace_act->setEnabled(replace_en);
10981098

10991099
auto insert_act = insert_op_submenu[j]->addAction(QString::fromStdString(Operators[i].text),
@@ -1106,11 +1106,11 @@ std::unique_ptr<QMenu> sexp_tree_view::buildContextMenu(QTreeWidgetItem* h) {
11061106
for (j = 0; j < static_cast<int>(op_submenu.size()); j++) {
11071107
if (op_submenu[j].id == subcategory_id) {
11081108
auto add_act = add_op_subcategory_menu[j]->addAction(QString::fromStdString(Operators[i].text),
1109-
this, [this, i]() { _actions.add_or_replace_operator(i, 0); });
1109+
this, [this, i]() { _actions.add_or_replace_operator(i, 0); Q_EMIT modified(); });
11101110
add_act->setEnabled(add_en);
11111111

11121112
auto replace_act = replace_op_subcategory_menu[j]->addAction(QString::fromStdString(Operators[i].text),
1113-
this, [this, i]() { _actions.add_or_replace_operator(i, 1); });
1113+
this, [this, i]() { _actions.add_or_replace_operator(i, 1); Q_EMIT modified(); });
11141114
replace_act->setEnabled(replace_en);
11151115

11161116
auto insert_act = insert_op_subcategory_menu[j]->addAction(QString::fromStdString(Operators[i].text),
@@ -1520,6 +1520,7 @@ void sexp_tree_view::endOperatorQuickSearch(bool confirm)
15201520
const int op_num = get_operator_index(chosenOp.toUtf8().constData());
15211521
if (op_num >= 0) {
15221522
_actions.add_or_replace_operator(op_num, /*replace_flag*/ 1);
1523+
Q_EMIT modified();
15231524
if (tree_nodes[node].handle)
15241525
tree_item_handle(tree_nodes[node])->setExpanded(true);
15251526
}
@@ -1580,6 +1581,7 @@ void sexp_tree_view::handleItemChange(QTreeWidgetItem* item, int /*column*/) {
15801581
setCurrentItemIndex(node);
15811582
if (result.operator_index >= 0) {
15821583
_actions.add_or_replace_operator(result.operator_index, 1);
1584+
Q_EMIT modified();
15831585
}
15841586
} else if (result.negative_number_error) {
15851587
QMessageBox::critical(this, "Invalid Number", "Can not enter a negative value");
@@ -1602,6 +1604,7 @@ void sexp_tree_view::copyActionHandler() {
16021604
// Paste handler: replaces the current node with clipboard contents via _actions.clipboard_paste_replace().
16031605
void sexp_tree_view::pasteActionHandler() {
16041606
_actions.clipboard_paste_replace();
1607+
Q_EMIT modified();
16051608
}
16061609

16071610
// Inserts an operator ABOVE the current node, wrapping it as a child.
@@ -1622,6 +1625,7 @@ void sexp_tree_view::insertOperatorAction(int op) {
16221625
}
16231626

16241627
setCurrentItemIndex(node);
1628+
Q_EMIT modified();
16251629
}
16261630

16271631
// Add Number handler: adds a SEXPT_NUMBER data node via _actions.add_data("number", ...),
@@ -1692,11 +1696,13 @@ void sexp_tree_view::beginItemEdit(QTreeWidgetItem* item) {
16921696
// _actions.replace_data() (if replace) or _actions.add_data() (if add). Frees the list after use.
16931697
void sexp_tree_view::addReplaceTypedDataHandler(int data_idx, bool replace) {
16941698
_actions.add_or_replace_typed_data(data_idx, replace, m_add_count, m_replace_count);
1699+
Q_EMIT modified();
16951700
}
16961701

16971702
// Add Paste handler: adds clipboard contents as a new child via _actions.clipboard_paste_add().
16981703
void sexp_tree_view::addPasteActionHandler() {
16991704
_actions.clipboard_paste_add();
1705+
Q_EMIT modified();
17001706
}
17011707

17021708
// Sets item_index and syncs the Qt selection. If node < 0, clears the selection.
@@ -1719,6 +1725,7 @@ void sexp_tree_view::handleReplaceVariableAction(int id) {
17191725
const bool allow_type_coercion =
17201726
(m_modify_variable != 0) || (_model.query_node_argument_type(item_index) == OPF_CONTAINER_VALUE);
17211727
_actions.replace_variable_with_type_validation(id, node_type, allow_type_coercion);
1728+
Q_EMIT modified();
17221729
}
17231730

17241731
// Replace Container Name handler: replaces the current string node with a container name reference.
@@ -1736,6 +1743,7 @@ void sexp_tree_view::handleReplaceContainerNameAction(int idx) {
17361743
type);
17371744

17381745
_actions.replace_container_name(containers[idx]);
1746+
Q_EMIT modified();
17391747
}
17401748

17411749
// Replace Container Data handler: replaces the current data node with container data access.
@@ -1754,6 +1762,7 @@ void sexp_tree_view::handleReplaceContainerDataAction(int idx) {
17541762
// DISCUSSME: what about variable name as SEXP arg type?
17551763
type &= ~(SEXPT_VARIABLE | SEXPT_CONTAINER_NAME);
17561764
_actions.replace_container_data(containers[idx], (type | SEXPT_CONTAINER_DATA), true, true, true);
1765+
Q_EMIT modified();
17571766

17581767
auto *handle = tree_item_handle(tree_nodes[item_index]);
17591768
expand_branch(handle);

0 commit comments

Comments
 (0)