Utils: Fix connection error

When add / remove buttons are disabled, the connection fails.

Change-Id: I6c9a3233f156b88e516481a6fc8e072ea5e1c13b
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Marcus Tillmanns
2024-05-31 16:17:10 +02:00
parent d8a582d813
commit e078d05f51

View File

@@ -2681,22 +2681,26 @@ void StringListAspect::addToLayout(Layout &parent)
} }
}; };
connect(add, &QPushButton::clicked, this, [this, populate, editor] { if (add) {
d->undoable.setSilently(d->undoable.get() << ""); connect(add, &QPushButton::clicked, this, [this, populate, editor] {
populate(); d->undoable.setSilently(d->undoable.get() << "");
const QTreeWidgetItem *root = editor->invisibleRootItem(); populate();
QTreeWidgetItem *lastChild = root->child(root->childCount() - 1); const QTreeWidgetItem *root = editor->invisibleRootItem();
const QModelIndex index = editor->indexFromItem(lastChild, 0); QTreeWidgetItem *lastChild = root->child(root->childCount() - 1);
editor->edit(index); const QModelIndex index = editor->indexFromItem(lastChild, 0);
}); editor->edit(index);
});
}
connect(remove, &QPushButton::clicked, this, [this, editor, itemsToStringList] { if (remove) {
const QList<QTreeWidgetItem *> selected = editor->selectedItems(); connect(remove, &QPushButton::clicked, this, [this, editor, itemsToStringList] {
QTC_ASSERT(selected.size() == 1, return); const QList<QTreeWidgetItem *> selected = editor->selectedItems();
editor->invisibleRootItem()->removeChild(selected.first()); QTC_ASSERT(selected.size() == 1, return);
delete selected.first(); editor->invisibleRootItem()->removeChild(selected.first());
d->undoable.set(undoStack(), itemsToStringList()); delete selected.first();
}); d->undoable.set(undoStack(), itemsToStringList());
});
}
connect( connect(
&d->undoable.m_signal, &UndoSignaller::changed, editor, [this, populate, itemsToStringList] { &d->undoable.m_signal, &UndoSignaller::changed, editor, [this, populate, itemsToStringList] {