aboutsummaryrefslogtreecommitdiffstats
path: root/mobility/servicebrowser/qml/ServiceImplementations.qml
blob: 28791cc270ff18e9db28af485b4aad68e2e2228e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93

import QtQuick 1.1
import com.nokia.meego 1.0
import com.nokia.extras 1.1

Page {

    property string serviceName: ""
    property int serviceIndex: -1

    id: serviceImplementations
    anchors.margins: UiConstants.DefaultMargin
    //orientationLock: PageOrientation.LockPortrait

    Label {
        id: titleLabel
        anchors.top: parent.top
        anchors.horizontalCenter: parent.horizontalCenter
        text: "Service: " + serviceName
    }

    Flickable {
        anchors.top: titleLabel.bottom
        anchors.horizontalCenter: parent.horizontalCenter
        width: parent.width
        contentHeight: servicesButtons.height

        ButtonColumn {
            id: servicesButtons
            width: parent.width
            anchors.horizontalCenter: parent.horizontalCenter
            Repeater {
                id: buttonRepeater
                model: manager.serviceImplementations(serviceName, serviceIndex)

                HoldButton {
                    text: modelData
                    // TODO Getting some "Unable to assing undefined value" at this line when
                    // setting model to a different list (line 73), but the example is working
                    // so far.
                    width: parent.width

                    onHeld: {
                        setDefaultDialog.titleText = "Change default implementation";
                        setDefaultDialog.message = "Set " + modelData + " as default?";
                        setDefaultDialog.index = index;
                        setDefaultDialog.open();
                    }

                    onClickedWithoutHold: {
                        pageStack.push(Qt.createComponent("ImplementationDetails.qml"),
                                    { implementationSpec: modelData,
                                        implementationIndex: index,
                                        serviceName: serviceName,
                                        serviceIndex: serviceIndex
                                    });

                    }
                }
            }
        }
    }

    QueryDialog {
        property int index: -1

        id: setDefaultDialog
        acceptButtonText: "Yes"
        rejectButtonText: "No"

        onAccepted: {
            console.log("Accepted");
            manager.setDefault(index);
            buttonRepeater.model = manager.serviceImplementations(serviceName, serviceIndex)
        }

        onRejected: {
            console.log("Rejected");
        }

    }

    tools: ToolBarLayout {
        id: implementationPageTools
        ToolButton {
            text: "Back"
            onClicked: {
                pageStack.pop();
            }
        }
    }

}