forked from qt-creator/qt-creator
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:
@@ -27,8 +27,15 @@ QWidget *EventListDelegate::createEditor(QWidget *parent,
|
|||||||
{
|
{
|
||||||
if (index.column() == EventListModel::shortcutColumn) {
|
if (index.column() == EventListModel::shortcutColumn) {
|
||||||
auto *editor = new ShortcutWidget(parent);
|
auto *editor = new ShortcutWidget(parent);
|
||||||
connect(editor, &ShortcutWidget::done, this, &EventListDelegate::commitAndClose);
|
connect(editor, &ShortcutWidget::done, this, [this, editor] {
|
||||||
connect(editor, &ShortcutWidget::cancel, this, &EventListDelegate::close);
|
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;
|
return editor;
|
||||||
} else if (index.column() == EventListModel::connectColumn) {
|
} else if (index.column() == EventListModel::connectColumn) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@@ -170,18 +177,4 @@ QSize EventListDelegate::sizeHint(const QStyleOptionViewItem &option, const QMod
|
|||||||
return QStyledItemDelegate::sizeHint(option, index);
|
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.
|
} // namespace QmlDesigner.
|
||||||
|
@@ -39,9 +39,6 @@ protected:
|
|||||||
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void close();
|
|
||||||
void commitAndClose();
|
|
||||||
|
|
||||||
static bool hasConnectionColumn(QObject *parent);
|
static bool hasConnectionColumn(QObject *parent);
|
||||||
static QRect connectButtonRect(const QStyleOptionViewItem &option);
|
static QRect connectButtonRect(const QStyleOptionViewItem &option);
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user