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.
This commit is contained in:
Simon Edwards 2022-04-30 09:42:18 +02:00
parent 7dcbc32540
commit 9faf63d5d3
2 changed files with 7 additions and 4 deletions

View File

@ -22,9 +22,9 @@ export class QAbstractItemModel extends QObject<any> {
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<any> {
// 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();
}

View File

@ -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();
}