diff options
author | Miikka Heikkinen <miikka.heikkinen@digia.com> | 2013-08-30 11:57:40 +0300 |
---|---|---|
committer | Miikka Heikkinen <miikka.heikkinen@digia.com> | 2013-09-02 08:23:27 +0300 |
commit | 15f8c86385a055d35b07519e4bf8c8f1aa915ea3 (patch) | |
tree | 4b8b91bbd00a15d5b76793f0851f30e8fd196de3 /examples | |
parent | 6ef39dff1064f60c3f8794c2483c0ef16afaed78 (diff) |
Refactor item model mapping and proxies
- Introduced new handler for item models. Instance of this is
owned by item model proxies.
- Introduced abstract mapping class to enable moving a lot of
duplicate code to the new handler.
- Changed ownership handling of mapping objects to be in line
with proxies and axes, though there is no default mapping
at this time. Need to reconsider the default case more.
- Made item model const so it is clear that we do not own it.
The documentation is not yet up to date.
Change-Id: Ie961da29340743fdaa9293d7d4ace9577def9102
Reviewed-by: Tomi Korpipää <tomi.korpipaa@digia.com>
Diffstat (limited to 'examples')
-rw-r--r-- | examples/barchart/main.cpp | 3 | ||||
-rw-r--r-- | examples/qmlbarchart/qml/qmlbarchart/main.qml | 6 |
2 files changed, 6 insertions, 3 deletions
diff --git a/examples/barchart/main.cpp b/examples/barchart/main.cpp index 0f1a8252..ca9c3260 100644 --- a/examples/barchart/main.cpp +++ b/examples/barchart/main.cpp @@ -296,8 +296,7 @@ int main(int argc, char **argv) // We don't need to initialize the mapping object in any way, as it defaults // to row/column support and uses the Qt::DisplayRole role for value role by default. - QItemModelBarDataMapping mapping; - QItemModelBarDataProxy *proxy = new QItemModelBarDataProxy(tableWidget->model(), &mapping); + QItemModelBarDataProxy *proxy = new QItemModelBarDataProxy(tableWidget->model(), new QItemModelBarDataMapping); chart->setActiveDataProxy(proxy); ChartDataGenerator *generator = new ChartDataGenerator(chart, tableWidget); diff --git a/examples/qmlbarchart/qml/qmlbarchart/main.qml b/examples/qmlbarchart/qml/qmlbarchart/main.qml index 44ad36ca..781e7517 100644 --- a/examples/qmlbarchart/qml/qmlbarchart/main.qml +++ b/examples/qmlbarchart/qml/qmlbarchart/main.qml @@ -27,12 +27,15 @@ Item { height: 600 visible: true + Item { id: dataView width: parent.width - tableView.width height: parent.height anchors.right: parent.right; + property point storedSelection: Qt.point(-1, -1) + BarDataMapping { id: valueMapping rowRole: "year" @@ -138,7 +141,7 @@ Item { onDataResolved: { // Can't select a bar until data has been resolved from model to proxy - //selectedBarPos = Qt.point(0, 5) + selectedBarPos = dataView.storedSelection } } @@ -177,6 +180,7 @@ Item { text = "Show Income" testchart.valueAxis = expensesAxis } + dataView.storedSelection = testchart.selectedBarPos } } |