summaryrefslogtreecommitdiffstats
path: root/examples/qmlbars
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@digia.com>2013-11-26 14:53:50 +0200
committerMiikka Heikkinen <miikka.heikkinen@digia.com>2013-11-27 11:29:30 +0200
commit7c942cc0f497fe7e61ce6a10fce45771c0858e09 (patch)
treeaab5d2285b8e583f3565e305e0818a49503cf95c /examples/qmlbars
parente029d0ea1d486dd3dbbfa4519a2125da202f22e4 (diff)
Integrated item model mappings to item model proxies
Separate mapping object was redundant. Task-number: QTRD-2564 Change-Id: I6b1a23ba52dbb184f46df0fdd64184eeb145c0c3 Reviewed-by: Mika Salmela <mika.salmela@digia.com>
Diffstat (limited to 'examples/qmlbars')
-rw-r--r--examples/qmlbars/doc/src/qmlbars.qdoc6
-rw-r--r--examples/qmlbars/qml/qmlbars/data.qml18
-rw-r--r--examples/qmlbars/qml/qmlbars/main.qml24
3 files changed, 17 insertions, 31 deletions
diff --git a/examples/qmlbars/doc/src/qmlbars.qdoc b/examples/qmlbars/doc/src/qmlbars.qdoc
index 79b6c4fd..bb76d398 100644
--- a/examples/qmlbars/doc/src/qmlbars.qdoc
+++ b/examples/qmlbars/doc/src/qmlbars.qdoc
@@ -63,7 +63,7 @@
In the \c main.qml, we set up the graph and various UI elements. There are three interesting
mapping related code blocks we want to highlight here. The first one shows how to change the
visualized data from expenses to income, and vice versa, by simply changing the value role on the
- BarDataMapping item:
+ ItemModelBarDataProxy item:
\snippet ../examples/qmlbars/qml/qmlbars/main.qml 0
@@ -74,11 +74,11 @@
\snippet ../examples/qmlbars/qml/qmlbars/main.qml 1
- The filtering is done by setting \c autoRowCategories to false on the BarDataMapping item and defining
+ The filtering is done by setting \c autoRowCategories to false on the ItemModelBarDataProxy item and defining
the row categories explicitly. This way, only the items in specified rows are visualized.
The third interesting block shows how to get the row and column index of an item if you know the
- row and column values by using BarDataMapping methods \c rowCategoryIndex() and \c columnCategoryIndex():
+ row and column values by using ItemModelBarDataProxy methods \c rowCategoryIndex() and \c columnCategoryIndex():
\snippet ../examples/qmlbars/qml/qmlbars/main.qml 2
*/
diff --git a/examples/qmlbars/qml/qmlbars/data.qml b/examples/qmlbars/qml/qmlbars/data.qml
index 12ba171c..5a17bcd1 100644
--- a/examples/qmlbars/qml/qmlbars/data.qml
+++ b/examples/qmlbars/qml/qmlbars/data.qml
@@ -21,24 +21,6 @@ import QtDataVisualization 1.0
Item {
property alias model: dataModel
- property alias mapping: valueMapping
- property alias secondaryMapping: secondaryMapping
-
- //! [1]
- BarDataMapping {
- id: valueMapping
- rowRole: "year"
- columnRole: "month"
- valueRole: "income"
- }
- //! [1]
-
- BarDataMapping {
- id: secondaryMapping
- rowRole: "year"
- columnRole: "month"
- valueRole: "expenses"
- }
//! [0]
ListModel {
diff --git a/examples/qmlbars/qml/qmlbars/main.qml b/examples/qmlbars/qml/qmlbars/main.qml
index 753859e5..c7ec4f71 100644
--- a/examples/qmlbars/qml/qmlbars/main.qml
+++ b/examples/qmlbars/qml/qmlbars/main.qml
@@ -94,8 +94,10 @@ Item {
ItemModelBarDataProxy {
id: modelProxy
- activeMapping: graphData.mapping
itemModel: graphData.model
+ rowRole: "year"
+ columnRole: "month"
+ valueRole: "income"
}
onSelectedBarChanged: handleSelectionChange(barSeries, position)
@@ -108,8 +110,10 @@ Item {
ItemModelBarDataProxy {
id: secondaryProxy
- activeMapping: graphData.secondaryMapping
itemModel: graphData.model
+ rowRole: "year"
+ columnRole: "month"
+ valueRole: "expenses"
}
onSelectedBarChanged: handleSelectionChange(secondarySeries, position)
@@ -170,16 +174,16 @@ Item {
onClicked: {
if (testGraph.rowAxis.max !== 6) {
text = "Show 2010 - 2012"
- graphData.mapping.autoRowCategories = true
- graphData.secondaryMapping.autoRowCategories = true
+ modelProxy.autoRowCategories = true
+ secondaryProxy.autoRowCategories = true
} else {
text = "Show all years"
// Explicitly defining row categories, since we do not want to show data for
// all years in the model, just for the selected ones.
- graphData.mapping.autoRowCategories = false
- graphData.secondaryMapping.autoRowCategories = false
- graphData.mapping.rowCategories = ["2010", "2011", "2012"]
- graphData.secondaryMapping.rowCategories = ["2010", "2011", "2012"]
+ modelProxy.autoRowCategories = false
+ secondaryProxy.autoRowCategories = false
+ modelProxy.rowCategories = ["2010", "2011", "2012"]
+ secondaryProxy.rowCategories = ["2010", "2011", "2012"]
}
}
//! [1]
@@ -199,8 +203,8 @@ Item {
//! [2]
onCurrentRowChanged: {
- var rowIndex = modelProxy.activeMapping.rowCategoryIndex(graphData.model.get(currentRow).year)
- var colIndex = modelProxy.activeMapping.columnCategoryIndex(graphData.model.get(currentRow).month)
+ var rowIndex = modelProxy.rowCategoryIndex(graphData.model.get(currentRow).year)
+ var colIndex = modelProxy.columnCategoryIndex(graphData.model.get(currentRow).month)
if (selectedSeries.visible)
mainview.selectedSeries.selectedBar = Qt.point(rowIndex, colIndex)
else if (barSeries.visible)