From 9faf63d5d379ba9755f1e8fc2b544594008fc57e Mon Sep 17 00:00:00 2001 From: Simon Edwards Date: Sat, 30 Apr 2022 09:42:18 +0200 Subject: [PATCH] Rename `QAbstractItemModel.parent()` to `parentModelIndex()` The signature on `QAbstractItemModel.parent()` conflicts with `QObject.parent()`. Maybe in C++ you can get away with that, but in TS it is a huge PITA. --- src/lib/QtCore/QAbstractItemModel.ts | 9 ++++++--- src/lib/QtCore/QAbstractTableModel.ts | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/lib/QtCore/QAbstractItemModel.ts b/src/lib/QtCore/QAbstractItemModel.ts index 9825fa207..d4ce916b7 100644 --- a/src/lib/QtCore/QAbstractItemModel.ts +++ b/src/lib/QtCore/QAbstractItemModel.ts @@ -22,9 +22,9 @@ export class QAbstractItemModel extends QObject { case 'parent': try { - return this.parent(new QModelIndex(args[0])).native; + return this.parentModelIndex(new QModelIndex(args[0])).native; } catch (e) { - console.log(`An exception was thrown while dispatching to method 'parent':`); + console.log(`An exception was thrown while dispatching to method 'parentModelIndex':`); console.log(e); } return new QModelIndex().native; @@ -154,7 +154,10 @@ export class QAbstractItemModel extends QObject { // TODO: bool moveRow(const QModelIndex &sourceParent, int sourceRow, const QModelIndex &destinationParent, int destinationChild) // TODO: virtual bool moveRows(const QModelIndex &sourceParent, int sourceRow, int count, const QModelIndex &destinationParent, int destinationChild) - parent(child: QModelIndex): QModelIndex { + /** + * Note: This corresponds to `QAbstractItemModel::parent(QModelIndex)`. It has been given a different name in TS. + */ + parentModelIndex(child: QModelIndex): QModelIndex { return new QModelIndex(); } diff --git a/src/lib/QtCore/QAbstractTableModel.ts b/src/lib/QtCore/QAbstractTableModel.ts index b44ab5412..a3238e1fc 100644 --- a/src/lib/QtCore/QAbstractTableModel.ts +++ b/src/lib/QtCore/QAbstractTableModel.ts @@ -7,7 +7,7 @@ export class QAbstractTableModel extends QAbstractItemModel { return this.hasIndex(row, column, parent) ? this.createIndex(row, column) : new QModelIndex(); } - parent(child: QModelIndex): QModelIndex { + parentModelIndex(child: QModelIndex): QModelIndex { return new QModelIndex(); }