EventListDelegate: Avoid using sender()

Amends 1a402984da

Change-Id: I635febfb3c9b3f51a8155491a2e3d8edeb3647c9
Reviewed-by: Qt CI Patch Build Bot <ci_patchbuild_bot@qt.io>
Reviewed-by: Knud Dollereder <knud.dollereder@qt.io>
This commit is contained in:
Jarek Kobus
2023-12-13 22:58:58 +01:00
parent 0b32abdb31
commit 53c4fb0243
2 changed files with 9 additions and 19 deletions

View File

@@ -27,8 +27,15 @@ QWidget *EventListDelegate::createEditor(QWidget *parent,
{
if (index.column() == EventListModel::shortcutColumn) {
auto *editor = new ShortcutWidget(parent);
connect(editor, &ShortcutWidget::done, this, &EventListDelegate::commitAndClose);
connect(editor, &ShortcutWidget::cancel, this, &EventListDelegate::close);
connect(editor, &ShortcutWidget::done, this, [this, editor] {
auto that = const_cast<EventListDelegate *>(this);
emit that->commitData(editor);
emit that->closeEditor(editor);
});
connect(editor, &ShortcutWidget::cancel, this, [this, editor] {
auto that = const_cast<EventListDelegate *>(this);
emit that->closeEditor(editor);
});
return editor;
} else if (index.column() == EventListModel::connectColumn) {
return nullptr;
@@ -170,18 +177,4 @@ QSize EventListDelegate::sizeHint(const QStyleOptionViewItem &option, const QMod
return QStyledItemDelegate::sizeHint(option, index);
}
void EventListDelegate::commitAndClose()
{
if (auto *editor = qobject_cast<ShortcutWidget *>(sender())) {
emit commitData(editor);
emit closeEditor(editor);
}
}
void EventListDelegate::close()
{
if (auto *editor = qobject_cast<ShortcutWidget *>(sender()))
emit closeEditor(editor);
}
} // namespace QmlDesigner.

View File

@@ -39,9 +39,6 @@ protected:
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;
private:
void close();
void commitAndClose();
static bool hasConnectionColumn(QObject *parent);
static QRect connectButtonRect(const QStyleOptionViewItem &option);
};