summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorNatalia Shubina <natalia.shubina@nokia.com>2011-06-14 14:45:47 +1000
committerNatalia Shubina <natalia.shubina@nokia.com>2011-06-14 14:45:47 +1000
commit4324cde365cbb0941fda1c5f6800f8e2287b6fd3 (patch)
treeda3437843f17fb1c4b9cf91c2043b95a5d1e03d8 /examples
parent5014e7a615053b72311ff1e0d0113a89bea669c9 (diff)
downloadqtlocation-4324cde365cbb0941fda1c5f6800f8e2287b6fd3.tar.gz
map types, connectivity, provider
Diffstat (limited to 'examples')
-rw-r--r--examples/declarative/mapviewer/Dialog.qml23
-rw-r--r--examples/declarative/mapviewer/common/Fader.qml27
-rw-r--r--examples/declarative/mapviewer/common/Menu.qml15
-rw-r--r--examples/declarative/mapviewer/common/Slider.qml6
-rw-r--r--examples/declarative/mapviewer/mapviewer.qml240
-rw-r--r--examples/declarative/mapviewer/mapviewer.qrc2
6 files changed, 239 insertions, 74 deletions
diff --git a/examples/declarative/mapviewer/Dialog.qml b/examples/declarative/mapviewer/Dialog.qml
index 095db36d..504ca1d9 100644
--- a/examples/declarative/mapviewer/Dialog.qml
+++ b/examples/declarative/mapviewer/Dialog.qml
@@ -56,21 +56,14 @@ Item {
function setModel(objects)
{
+ dialogModel.clear()
+
for (var i=0; i< objects.length; i++){
dialogModel.append({"label": objects[i][0], "inputText": objects[i][1]})
}
}
- Rectangle {
- id: fader
- anchors.fill: parent
- opacity: 0.7
- color: "darkgrey"
- MouseArea {
- id: mouseArea
- anchors.fill: parent
- }
- }
+ Common.Fader {}
Rectangle {
id: dialogRectangle
@@ -95,7 +88,7 @@ Item {
id: titleBar;
width: parent.width; height: 40;
anchors.top: parent.top; anchors.left: parent.left;
- opacity: 0.9; text: dialog.title;
+ opacity: 0.9
onClicked: { dialog.cancelButtonClicked() }
}
@@ -117,7 +110,6 @@ Item {
radius: 5
TextInput {
id: inputField
- text: inputText
focus: true
width: parent.width - anchors.leftMargin
@@ -126,6 +118,11 @@ Item {
verticalCenter: parent.verticalCenter;
leftMargin: 5
}
+
+ Component.onCompleted: {
+ text = inputText
+ }
+
onTextChanged:
{
dialogModel.set(index, {"inputText": text})
@@ -139,6 +136,8 @@ Item {
}
}
+
+
ListView {
id: listview
anchors {
diff --git a/examples/declarative/mapviewer/common/Fader.qml b/examples/declarative/mapviewer/common/Fader.qml
new file mode 100644
index 00000000..e94b30ba
--- /dev/null
+++ b/examples/declarative/mapviewer/common/Fader.qml
@@ -0,0 +1,27 @@
+import Qt 4.7
+
+Rectangle {
+ id: fader
+ anchors.fill: parent
+ opacity: 0.7
+ color: "darkgrey"
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ }
+
+ Component.onCompleted: {
+ var globalXY
+ var root = parent
+
+ if (root != null) {
+ while (root.parent) root = root.parent
+ width = root.width; height = root.height;
+ globalXY = mapFromItem(root, root.x, root.y);
+ } else {
+ globalXY = mapFromItem(null, 0, 0);
+ }
+ x = globalXY.x;
+ y = globalXY.y;
+ }
+}
diff --git a/examples/declarative/mapviewer/common/Menu.qml b/examples/declarative/mapviewer/common/Menu.qml
index 6273f91a..221765f6 100644
--- a/examples/declarative/mapviewer/common/Menu.qml
+++ b/examples/declarative/mapviewer/common/Menu.qml
@@ -1,24 +1,26 @@
-import QtQuick 1.0
+import Qt 4.7
Item {
id: menu
property int gap: 0
- property int button: 0
+ property int button: -1
property alias orientation: menuView.orientation
property alias count: menuModel.count
- property int itemHeight //to create menu just set menu item height and width, do not set menu's height and width explicitly
+ property int itemHeight //to create menu just set menu item height and width, do not set menu's height and width explicitly
property int itemWidth
-// height: (menuView.orientation == ListView.Horizontal)? itemHeight : itemHeight * count
+ height: (menuView.orientation == ListView.Horizontal)? itemHeight : itemHeight * count
width: (menuView.orientation == ListView.Horizontal)? itemWidth * count : itemWidth
+ property bool keepPreviousValue: false
signal clicked
function setModel(objects)
{
+ menuModel.clear()
for (var i=0; i< objects.length; i++){
menuModel.append({"label": objects[i], "enabledItem" : true})
}
- height = (menuView.orientation == ListView.Horizontal)? itemHeight : itemHeight * count
+ menuView.positionViewAtIndex(0,ListView.Beginning)
}
function disableItem(index){
@@ -52,7 +54,7 @@ Item {
text: label;
elide: Text.ElideLeft
font.bold: true;
- color: "white"
+ color: index == menuView.currentIndex ? "crimson" :"white"
style: Text.Raised;
styleColor: "dimgrey"
anchors.verticalCenter: parent.verticalCenter
@@ -105,5 +107,6 @@ Item {
delegate: menuItemDelegate
spacing: gap
interactive: false
+ currentIndex: (menu.keepPreviousValue == false) ? -1 : menu.button
}
}
diff --git a/examples/declarative/mapviewer/common/Slider.qml b/examples/declarative/mapviewer/common/Slider.qml
index af62f915..129df855 100644
--- a/examples/declarative/mapviewer/common/Slider.qml
+++ b/examples/declarative/mapviewer/common/Slider.qml
@@ -48,7 +48,7 @@ Item {
property real minimum: 0
property real maximum: 1
property int xMin: 2
- property int xMax: slider.width - handle.width-xMin
+ property int xMax: width - handle.width-xMin
Rectangle {
anchors.fill: parent
@@ -61,8 +61,8 @@ Item {
Rectangle {
id: handle; smooth: true
width: 30;
- y: xMin;
- x: xMin + (value - minimum) * slider.xMax / (maximum - minimum)
+ y: slider.xMin;
+ x: slider.xMin + (slider.value - slider.minimum) * slider.xMax / (slider.maximum - slider.minimum)
height: slider.height-4; radius: 6
gradient: normalGradient
diff --git a/examples/declarative/mapviewer/mapviewer.qml b/examples/declarative/mapviewer/mapviewer.qml
index 4e768e87..6e0cfa91 100644
--- a/examples/declarative/mapviewer/mapviewer.qml
+++ b/examples/declarative/mapviewer/mapviewer.qml
@@ -99,74 +99,176 @@ FocusScope {
}
}
}
-
}
- Common.Menu {
- id: optionsMenu
- orientation: ListView.Vertical
- z: mainMenu.z - 1
- Component.onCompleted: {
- setModel(["Reverse geocode", "Geocode","Search", "Route"])
- disableItem(2)
+ Common.Menu {
+ id: optionsMenu
+ orientation: ListView.Vertical
+ z: mainMenu.z - 1
+ Component.onCompleted: {
+ setModel(["Reverse geocode", "Geocode","Search", "Route"])
+ disableItem(2)
+ }
+ itemHeight: 30;
+ itemWidth: mainMenu.itemWidth
+ anchors.left: mainMenu.left
+ y: page.height
+
+ onClicked: {
+ switch (button) {
+ case 0: {
+ page.state = "RevGeocode"
+ break;
+ }
+ case 1: {
+ page.state = "Geocode"
+ break;
+ }
+ case 2: {
+ page.state = "Search"
+ break;
+ }
+ case 3: {
+ page.state = "Route"
+ break;
+ }
}
- itemHeight: 30;
- itemWidth: mainMenu.itemWidth
- anchors.left: mainMenu.left
- y: page.height
-
- onClicked: {
- switch (button) {
- case 0: {
- page.state = "RevGeocode"
- break;
- }
- case 1: {
- page.state = "Geocode"
- break;
- }
- case 2: {
- page.state = "Search"
- break;
- }
- case 3: {
- page.state = "Route"
- break;
- }
+ }
+ }
+
+ Common.Menu {
+ id: settingsMenu
+ orientation: ListView.Vertical
+ z: mainMenu.z - 1
+ Component.onCompleted: {
+ setModel(["Map type", "Connectivity", "Provider"])
+ }
+
+ itemHeight: 30;
+ itemWidth: mainMenu.itemWidth
+ y: page.height
+ anchors.right: mainMenu.right
+
+ onClicked: {
+ switch (button) {
+ case 0: {
+ page.state = "MapType"
+ break;
+ }
+ case 1: {
+ page.state = "Connectivity"
+ break;
+ }
+ case 2: {
+ page.state = "ProviderInfo"
+ break;
}
}
}
+ }
- Common.Menu {
- id: settingsMenu
- orientation: ListView.Vertical
- z: mainMenu.z - 1
- Component.onCompleted: {
- setModel(["Map type", "Provider"])
- disableItem(0)
- disableItem(1)
+ Common.Menu {
+ id: mapTypeMenu
+ orientation: ListView.Vertical
+ z: mainMenu.z - 1
+ keepPreviousValue: true
+ opacity: 0
+
+ itemHeight: 30;
+ itemWidth: mainMenu.itemWidth*2/3
+ anchors.bottom: mainMenu.top
+ anchors.right: settingsMenu.left
+
+ Component.onCompleted: {
+ setModel(["Street", "Satellite", "Satellite Night", "Terrain"])
+ disableItem(2) // Nokia map engine supports only Street, Satellite and Terrain map types
+ button = 0 // Nokia plugin's default map type is Map.StreetMap
+ }
+
+ onClicked: {
+ page.state = ""
+ }
+
+ onButtonChanged: {
+ switch (button) {
+ case 0: {
+ map.mapType = Map.StreetMap
+ break;
+ }
+ case 1: {
+ map.mapType = Map.SatelliteMapDay
+ break;
+ }
+ case 2: {
+ map.mapType = Map.SatelliteMapNight
+ break;
+ }
+ case 3: {
+ map.mapType = Map.TerrainMap
+ break;
+ }
}
+ }
+ }
- itemHeight: 30;
- itemWidth: mainMenu.itemWidth
- y: page.height
- anchors.right: mainMenu.right
+ Common.Menu {
+ id: connectivityModeMenu
+ orientation: ListView.Vertical
+ z: mainMenu.z - 1
+ keepPreviousValue: true
+ opacity: 0
- onClicked: {
- switch (button) {
- case 0: {
- console.log("Map type");
- break;
- }
- case 1: {
- console.log("Provider")
- break;
- }
+ itemHeight: 30;
+ itemWidth: mainMenu.itemWidth/2
+ anchors.bottom: mainMenu.top
+ anchors.right: settingsMenu.left
+
+ Component.onCompleted: {
+ setModel(["Offline", "Online", "Hybrid"])
+ disableItem(0) // Nokia map engine supports online mode
+ disableItem(2)
+ button = 1
+ }
+
+ onClicked: {
+ page.state = ""
+ }
+
+ onButtonChanged: {
+ switch (button) {
+ case 0: {
+ map.connectivityMode = Map.OfflineMode
+ break;
+ }
+ case 1: {
+ map.connectivityMode = Map.OnlineMode
+ break;
+ }
+ case 2: {
+ map.connectivityMode = Map.HybridMode
+ break;
}
}
}
+ }
+
// Dialogs
+
+ Message {
+ id: providerInfoDialog
+ title: "Provider"
+ text: "Nokia OVI <a href=\http://doc.qt.nokia.com/qtmobility-1.2/location-overview.html#the-nokia-plugin\">map plugin</a>."
+ z: 5
+ opacity: 0
+ onOkButtonClicked: {
+ page.state = ""
+ }
+ onCancelButtonClicked: {
+ page.state = ""
+ }
+ }
+
Dialog {
id: routeDialog
title: "Routing from map center to"
@@ -411,18 +513,50 @@ FocusScope {
PropertyChanges { target: titleBar; hoverEnabled: false }
},
State {
+ name: "ProviderInfo"
+ PropertyChanges { target: providerInfoDialog; opacity: 1 }
+ PropertyChanges { target: titleBar; hoverEnabled: false }
+ },
+ State {
name : "Options"
PropertyChanges { target: optionsMenu; y: page.height - optionsMenu.height - mainMenu.height }
},
State {
name : "Settings"
PropertyChanges { target: settingsMenu; y: page.height - settingsMenu.height - mainMenu.height }
+ },
+ State {
+ name : "MapType"
+ PropertyChanges { target: mapTypeMenu; opacity: 1}
+ PropertyChanges { target: settingsMenu; y: page.height - settingsMenu.height - mainMenu.height }
+ },
+ State {
+ name : "Connectivity"
+ PropertyChanges { target: connectivityModeMenu; opacity: 1}
+ PropertyChanges { target: settingsMenu; y: page.height - settingsMenu.height - mainMenu.height }
}
]
// state-transition animations for page
transitions: [
Transition {
+ to: "RevGeocode"
+ NumberAnimation { properties: "opacity" ; duration: 500; easing.type: Easing.Linear }
+ },
+ Transition {
+ to: "Route"
+ NumberAnimation { properties: "opacity" ; duration: 500; easing.type: Easing.Linear }
+ },
+ Transition {
+ to: "Search"
+ NumberAnimation { properties: "opacity" ; duration: 500; easing.type: Easing.Linear }
+ },
+ Transition {
+ to: "Geocode"
+ NumberAnimation { properties: "opacity" ; duration: 500; easing.type: Easing.Linear }
+ },
+ Transition {
+ to: "ProviderInfo"
NumberAnimation { properties: "opacity" ; duration: 500; easing.type: Easing.Linear }
},
Transition {
diff --git a/examples/declarative/mapviewer/mapviewer.qrc b/examples/declarative/mapviewer/mapviewer.qrc
index 653be933..46180e54 100644
--- a/examples/declarative/mapviewer/mapviewer.qrc
+++ b/examples/declarative/mapviewer/mapviewer.qrc
@@ -19,5 +19,7 @@
<file>resources/menuItem_hovered.png</file>
<file>resources/button_pressed.png</file>
<file>resources/button_hovered.png</file>
+ <file>Message.qml</file>
+ <file>common/Fader.qml</file>
</qresource>
</RCC>