diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2019-02-21 17:35:39 +0100 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2019-02-22 13:13:28 +0000 |
commit | 22435f49499342ff102411c025efb8007dfa62a2 (patch) | |
tree | 51bbc0375849451355e8397a77752c95d83349ed /src/qml/doc/snippets | |
parent | 2d79c167e0e127e99a4b439dc3c8536770c110a9 (diff) |
TableModel.roleDataProvider: replace row, column with index argument
QModelIndex has various advantages over separate int row and column in
TableModel API; we intend to expose it via an invokable index() method and
via a context property for delegates, and use it in the invokable data()
function. So we should be consistent by using it in roleDataProvider too.
This way the callback only requires 3 arguments instead of 4, and the first
one is potentially extensible, just in case.
Change-Id: I7b1bc9ea5adb64941979d83901b3566278357e98
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/qml/doc/snippets')
-rw-r--r-- | src/qml/doc/snippets/qml/tablemodel/roleDataProvider.qml | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/qml/doc/snippets/qml/tablemodel/roleDataProvider.qml b/src/qml/doc/snippets/qml/tablemodel/roleDataProvider.qml index 6c8ae3f1fc..63978a370d 100644 --- a/src/qml/doc/snippets/qml/tablemodel/roleDataProvider.qml +++ b/src/qml/doc/snippets/qml/tablemodel/roleDataProvider.qml @@ -59,10 +59,10 @@ TableView { [{ fruitType: "Apple" }, { fruitPrice: 1.50 }], [{ fruitType: "Orange" }, { fruitPrice: 2.50 }] ] - roleDataProvider: function(row, column, role, cellData) { + roleDataProvider: function(index, role, cellData) { if (role === "display") { if (cellData.hasOwnProperty("fruitPrice")) { - console.log("taxing your fruit " + JSON.stringify(cellData)) + console.log("row", index.row, "taxing your fruit", JSON.stringify(cellData)) return (cellData.fruitPrice * (1 + taxPercent / 100)).toFixed(2); } else if (cellData.hasOwnProperty("fruitType")) |