DeviceView.qml 5.98 KB
Newer Older
Leander Schulten's avatar
Leander Schulten committed
1
2
3
import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.0
4
import QtQuick.Dialogs 1.2
Leander Schulten's avatar
Leander Schulten committed
5
import custom.licht 1.0
Leander Schulten's avatar
Leander Schulten committed
6
import "components"
Leander Schulten's avatar
Leander Schulten committed
7

8
ModelView{
9
    id: deviceModelView
10
    model: deviceModel
11
    nameFunction: function(modelData){return modelData.name + ", Channel: " + modelData.startDMXChannel + (modelData.prototype.numberOfChannels > 1 ? " - " + (modelData.startDMXChannel + modelData.prototype.numberOfChannels - 1) : "");}
12
    rows: 7
13
14
    onAddClicked: dialog.visible = true
    onRemoveClicked: ModelManager.removeDmxDevice(remove);
Leander Schulten's avatar
Leander Schulten committed
15
16
17
18
19
20
    addButtonEnabled: UserManagment.currentUser.havePermission(Permission.ADD_DEVICE)
    removeButtonEnabled: UserManagment.currentUser.havePermission(Permission.REMOVE_DEVICE)
    nameInputEnabled: UserManagment.currentUser.havePermission(Permission.CHANGE_NAME)
    descriptionInputEnabled: UserManagment.currentUser.havePermission(Permission.CHANGE_NAME)
    addButton.text: "Add Device"
    removeButton.text: "Remove Device"
21
    property var placeOnMapCallback
Leander Schulten's avatar
Leander Schulten committed
22

23
24
25
26
27
28
29
30
31
32
    Text{
        Layout.row: 2
        Layout.column: 2
        text:"startDMXChannel:"
        Layout.rightMargin: 20
        font.pixelSize: 15
    }
    TextInputField{
        Layout.row: 2
        Layout.column: 3
Leander Schulten's avatar
Leander Schulten committed
33
        enabled: UserManagment.currentUser.havePermission(Permission.CHANGE_DEVICE_DMX_CHANNEL);
34
        text: parent.currentModelData.startDMXChannel
35
36
37
        validator: IntValidator{
            bottom: 0
            top:512
Leander Schulten's avatar
Leander Schulten committed
38
        }
39
        onTextChanged: parent.currentModelData.startDMXChannel = text.length?text:0
Leander Schulten's avatar
Leander Schulten committed
40
    }
41
42
43
44
45
46
47
48
49
50
    Text{
        Layout.row: 3
        Layout.column: 2
        text:"DevicePrototype:"
        Layout.rightMargin: 20
        font.pixelSize: 15
    }
    Text{
        Layout.row: 3
        Layout.column: 3
51
        text:parent.currentModelData.prototype.name
52
        font.pixelSize: 15
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
        TextUnderline{
            extendetWidth:1
            color:"lightgrey"
        }
    }
    Text{
        Layout.row: 4
        Layout.column: 2
        text:"Position:"
        Layout.rightMargin: 20
        font.pixelSize: 15
    }
    RowLayout{
        Layout.row: 4
        Layout.column: 3
        Text{
            text:"x:"
            font.pixelSize: 15
        }
        TextInputField{
Leander Schulten's avatar
Leander Schulten committed
73
            enabled: UserManagment.currentUser.havePermission(Permission.CHANGE_POSITION);
74
            Layout.minimumWidth: 40
75
            text:deviceModelView.currentModelData.position.x
76
            validator: IntValidator{}
77
            onTextChanged: deviceModelView.currentModelData.position.x = text.length?text:0
78
79
80
81
82
83
84
        }
        Text{
            Layout.leftMargin: 10
            text:"y:"
            font.pixelSize: 15
        }
        TextInputField{
Leander Schulten's avatar
Leander Schulten committed
85
            enabled: UserManagment.currentUser.havePermission(Permission.CHANGE_POSITION);
86
            Layout.minimumWidth: 40
87
            text: deviceModelView.currentItem ? deviceModelView.currentModelData.position.y : ""
88
            validator: IntValidator{}
89
            onTextChanged: deviceModelView.currentModelData.position.y = text.length?text:0
90
        }
91
        Button{
92
            visible: deviceModelView.currentItem ? deviceModelView.placeOnMapCallback && deviceModelView.currentModelData.position.x === -1 || deviceModelView.currentModelData.position.x === -1 : false
93
            text: "Place on map"
94
            onClicked: deviceModelView.placeOnMapCallback(deviceModelView.currentModelData)
95
96
            height: implicitHeight - 15
        }
97
    }
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172

    Dialog{
        modality: Qt.WindowModal
        id:dialog
        title: "Hallo"
        width:300
        contentItem: RowLayout {
            Pane{
                Layout.fillWidth: true
                ColumnLayout{
                    anchors.left: parent.left
                    anchors.right: parent.right
                    spacing: 10
                    ComboBox{
                        Layout.fillWidth: true
                        id:prototype
                        model: devicePrototypeModel
                        textRole: "display"
                    }
                    RowLayout{
                        Label{
                            id:nameLabel
                            text:"Name :"
                        }
                        TextInputField{
                            Layout.fillWidth: true
                            id:name
                        }
                    }
                    RowLayout{
                        Label{
                            text:"Description :"
                        }
                        TextInputField{
                            Layout.fillWidth: true
                            id:description
                        }
                    }
                    RowLayout{
                        Label{
                            text:"Start DMX Channel :"
                        }
                        TextInputField{
                            Layout.fillWidth: true
                            id:dmx
                            validator: IntValidator{
                            bottom: 0
                            top:1024
                            }
                        }
                    }
                    RowLayout{
                        Button{
                            Layout.fillWidth: true
                            text:"Abbrechen"
                            onClicked: dialog.visible = false
                        }
                        Button{
                            Layout.fillWidth: true
                            text:"Erzeugen"
                            onClicked: {
                                if(name.text===""){
                                    name.underlineColor = "red";
                                }else{
                                    dialog.visible = false;
                                    ModelManager.addDevice(prototype.currentIndex,dmx.text,name.text,description.text);
                                }
                            }
                        }
                    }
                }
            }
        }
    }

173
}