summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/itemmodel/doc/src/itemmodel.qdoc19
-rw-r--r--examples/itemmodel/main.cpp7
-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
-rw-r--r--examples/qmlcustominput/qml/qmlcustominput/data.qml8
-rw-r--r--examples/qmlcustominput/qml/qmlcustominput/main.qml4
-rw-r--r--examples/qmlscatter/qml/qmlscatter/data.qml10
-rw-r--r--examples/qmlscatter/qml/qmlscatter/main.qml4
-rw-r--r--examples/qmlsurface/qml/qmlsurface/data.qml10
-rw-r--r--examples/qmlsurface/qml/qmlsurface/main.qml4
11 files changed, 37 insertions, 77 deletions
diff --git a/examples/itemmodel/doc/src/itemmodel.qdoc b/examples/itemmodel/doc/src/itemmodel.qdoc
index 6c192f6f..14cc2637 100644
--- a/examples/itemmodel/doc/src/itemmodel.qdoc
+++ b/examples/itemmodel/doc/src/itemmodel.qdoc
@@ -27,7 +27,7 @@
\list
\li How to create an application with Q3DBars and widgets
- \li How to use QItemModelBarDataMapping and QItemModelBarDataProxy to set data to the graph
+ \li How to use QItemModelBarDataProxy to set data to the graph
\li How to use a table widget to modify the data in the graph
\endlist
@@ -52,15 +52,13 @@
The table widget is going to be used to display the numerical data being inserted into the
graph, and to modify it (See \l {Adding data to the graph} and \l {Interacting with the data}).
- We need to instantiate QItemModelBarDataMapping and QItemModelBarDataProxy and give them to the
- graph:
+ We need to instantiate QItemModelBarDataProxy and give it to the graph:
\snippet ../examples/itemmodel/main.cpp 2
- Here we tell the mapping object to directly map the model's rows and columns into the proxy's rows and
+ Here we tell the proxy to directly map the model's rows and columns into the proxy's rows and
columns instead of defining row and column roles to map for them. Then we give the model from
- the table widget and the mapping object to the proxy. Finally we set the proxy as the active
- data proxy for the graph.
+ the table widget to the proxy. Finally we set the proxy to a series and add it to the graph.
Next, let's create another class to handle the data addition and other interaction with the
graph. Let's call it GraphDataGenerator (See \l {Setting up the graph} and
@@ -149,11 +147,10 @@
\snippet ../examples/itemmodel/main.cpp 2
- We created QItemModelBarDataMapping and QItemModelBarDataProxy instances, and gave the proxy
- the model of the table widget and the model mapping we just created. Then we set the proxy as
- the active proxy for the graph. The proxy maps the rows and the columns in the model of the table
- widget into rows and columns for itself using the model mapping, and the graph gets the data
- to be displayed from its active proxy.
+ We created QItemModelBarDataProxy instance, and gave the proxy the model of the table widget
+ we just created. The proxy maps the rows and the columns in the model of the table widget into
+ rows and columns for itself directly, as we set the useModelCategories property to true, and
+ the graph gets the data to be displayed via the series that owns the proxy.
\section1 Interacting with the data
diff --git a/examples/itemmodel/main.cpp b/examples/itemmodel/main.cpp
index 789ff0ff..d6263c7c 100644
--- a/examples/itemmodel/main.cpp
+++ b/examples/itemmodel/main.cpp
@@ -266,10 +266,9 @@ int main(int argc, char **argv)
//! [2]
// Since we are dealing with QTableWidget, the model will already have data sorted properly
- // in rows and columns, so create a mapping to utilize this.
- QItemModelBarDataMapping *mapping = new QItemModelBarDataMapping;
- mapping->setUseModelCategories(true);
- QItemModelBarDataProxy *proxy = new QItemModelBarDataProxy(tableWidget->model(), mapping);
+ // in rows and columns, so we simply set useModelCategories property to true to utilize this.
+ QItemModelBarDataProxy *proxy = new QItemModelBarDataProxy(tableWidget->model());
+ proxy->setUseModelCategories(true);
QBar3DSeries *series = new QBar3DSeries(proxy);
graph->addSeries(series);
//! [2]
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)
diff --git a/examples/qmlcustominput/qml/qmlcustominput/data.qml b/examples/qmlcustominput/qml/qmlcustominput/data.qml
index bd81becd..71c544a4 100644
--- a/examples/qmlcustominput/qml/qmlcustominput/data.qml
+++ b/examples/qmlcustominput/qml/qmlcustominput/data.qml
@@ -21,16 +21,8 @@ import QtDataVisualization 1.0
import QtQuick.XmlListModel 2.0
Item {
- property alias mapping: scatterMapping
property alias model: dataModel
- ScatterDataMapping {
- id: scatterMapping
- xPosRole: "xPos"
- yPosRole: "yPos"
- zPosRole: "zPos"
- }
-
ListModel {
id: dataModel
ListElement{ xPos: -10.0; yPos: 5.0; zPos: -5.0 }
diff --git a/examples/qmlcustominput/qml/qmlcustominput/main.qml b/examples/qmlcustominput/qml/qmlcustominput/main.qml
index 83fa0980..2ab39ca8 100644
--- a/examples/qmlcustominput/qml/qmlcustominput/main.qml
+++ b/examples/qmlcustominput/qml/qmlcustominput/main.qml
@@ -51,8 +51,10 @@ Item {
itemLabelFormat: "X:@xLabel Y:@yLabel Z:@zLabel"
ItemModelScatterDataProxy {
- activeMapping: graphData.mapping
itemModel: graphData.model
+ xPosRole: "xPos"
+ yPosRole: "yPos"
+ zPosRole: "zPos"
}
}
}
diff --git a/examples/qmlscatter/qml/qmlscatter/data.qml b/examples/qmlscatter/qml/qmlscatter/data.qml
index 523aceb0..b8b2a77b 100644
--- a/examples/qmlscatter/qml/qmlscatter/data.qml
+++ b/examples/qmlscatter/qml/qmlscatter/data.qml
@@ -21,19 +21,9 @@ import QtDataVisualization 1.0
Item {
//! [3]
- property alias mapping: scatterMapping
property alias model: dataModel
//! [3]
- //! [1]
- ScatterDataMapping {
- id: scatterMapping
- xPosRole: "xPos"
- yPosRole: "yPos"
- zPosRole: "zPos"
- }
- //! [1]
-
//! [0]
ListModel {
id: dataModel
diff --git a/examples/qmlscatter/qml/qmlscatter/main.qml b/examples/qmlscatter/qml/qmlscatter/main.qml
index 8ca73628..92809297 100644
--- a/examples/qmlscatter/qml/qmlscatter/main.qml
+++ b/examples/qmlscatter/qml/qmlscatter/main.qml
@@ -73,8 +73,10 @@ Item {
itemLabelFormat: "X:@xLabel Y:@yLabel Z:@zLabel"
ItemModelScatterDataProxy {
- activeMapping: graphData.mapping
itemModel: graphData.model
+ xPosRole: "xPos"
+ yPosRole: "yPos"
+ zPosRole: "zPos"
}
}
diff --git a/examples/qmlsurface/qml/qmlsurface/data.qml b/examples/qmlsurface/qml/qmlsurface/data.qml
index f9b008df..3ecc899f 100644
--- a/examples/qmlsurface/qml/qmlsurface/data.qml
+++ b/examples/qmlsurface/qml/qmlsurface/data.qml
@@ -20,18 +20,8 @@ import QtQuick 2.1
import QtDataVisualization 1.0
Item {
- property alias mapping: surfaceMapping
property alias model: dataModel
- //! [2]
- SurfaceDataMapping {
- id: surfaceMapping
- rowRole: "longitude"
- columnRole: "latitude"
- valueRole: "height"
- }
- //! [2]
-
//! [1]
ListModel {
id: dataModel
diff --git a/examples/qmlsurface/qml/qmlsurface/main.qml b/examples/qmlsurface/qml/qmlsurface/main.qml
index a78ac796..f83dc9a9 100644
--- a/examples/qmlsurface/qml/qmlsurface/main.qml
+++ b/examples/qmlsurface/qml/qmlsurface/main.qml
@@ -74,8 +74,10 @@ Item {
id: surfaceSeries
ItemModelSurfaceDataProxy {
- activeMapping: surfaceData.mapping
itemModel: surfaceData.model
+ rowRole: "longitude"
+ columnRole: "latitude"
+ valueRole: "height"
}
}