DeviceView.qml 6.8 KB
Newer Older
1
2
3
4
5
import QtQuick 2.12
import QtQuick.Controls 2.12
import QtQuick.Controls.Material 2.12
import QtQuick.Layouts 1.12
import QtQuick.Dialogs 1.3
Leander Schulten's avatar
Leander Schulten committed
6
import custom.licht 1.0
Leander Schulten's avatar
Leander Schulten committed
7
import "components"
Leander Schulten's avatar
Leander Schulten committed
8

9
ModelView{
10
    id: deviceModelView
11
    model: deviceModel
12
    nameFunction: function(modelData){return modelData.name + ", Channel: " + modelData.startDMXChannel + (modelData.prototype.numberOfChannels > 1 ? " - " + (modelData.startDMXChannel + modelData.prototype.numberOfChannels - 1) : "");}
13
    rows: 7
14
15
    onAddClicked: dialog.visible = true
    onRemoveClicked: ModelManager.removeDmxDevice(remove);
Leander Schulten's avatar
Leander Schulten committed
16
17
18
19
20
21
    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"
22
    property var placeOnMapCallback
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
    sortModel: ListModel{
        ListElement{
            name: "Creation Date"
            sortPropertyName: ""
        }
        ListElement{
            name: "DMX Channel"
            sortPropertyName: "startDMXChannel"
        }
        ListElement{
            name: "Name"
            sortPropertyName: "name"
        }
        ListElement{
            name: "Prototype Name"
            sortPropertyName: "prototype.name"
        }
    }
Leander Schulten's avatar
Leander Schulten committed
41

42
    Label{
43
44
        Layout.row: 2
        Layout.column: 2
45
        text:"First DMX-Channel:"
46
47
48
49
50
        Layout.rightMargin: 20
    }
    TextInputField{
        Layout.row: 2
        Layout.column: 3
Leander Schulten's avatar
Leander Schulten committed
51
        enabled: UserManagment.currentUser.havePermission(Permission.CHANGE_DEVICE_DMX_CHANNEL);
52
        text: parent.currentModelData ? parent.currentModelData.startDMXChannel : ""
53
54
55
        validator: IntValidator{
            bottom: 0
            top:512
Leander Schulten's avatar
Leander Schulten committed
56
        }
57
        onTextChanged: if(parent.currentModelData) parent.currentModelData.startDMXChannel = text.length?text:0
Leander Schulten's avatar
Leander Schulten committed
58
    }
59
    Label{
60
61
62
63
64
65
66
67
        Layout.row: 3
        Layout.column: 2
        text:"DevicePrototype:"
        Layout.rightMargin: 20
    }
    Text{
        Layout.row: 3
        Layout.column: 3
68
        text: parent.currentModelData ? parent.currentModelData.prototype.name : ""
69
        font.pixelSize: 15
70
        color: Material.secondaryTextColor
71
72
73
74
75
        TextUnderline{
            extendetWidth:1
            color:"lightgrey"
        }
    }
76
    Label{
77
78
79
80
81
82
83
84
85
86
        Layout.row: 4
        Layout.column: 2
        text:"Position:"
        Layout.rightMargin: 20
    }
    RowLayout{
        Layout.row: 4
        Layout.column: 3
        Text{
            text:"x:"
87
            color: Material.foreground
88
89
90
            font.pixelSize: 15
        }
        TextInputField{
Leander Schulten's avatar
Leander Schulten committed
91
            enabled: UserManagment.currentUser.havePermission(Permission.CHANGE_POSITION);
92
            Layout.minimumWidth: 40
93
            text:deviceModelView.currentModelData ? deviceModelView.currentModelData.position.x : ""
94
            validator: IntValidator{}
95
            onTextChanged: if(deviceModelView.currentModelData) deviceModelView.currentModelData.position.x = text.length?text:0
96
97
98
99
        }
        Text{
            Layout.leftMargin: 10
            text:"y:"
100
            color: Material.foreground
101
102
103
            font.pixelSize: 15
        }
        TextInputField{
Leander Schulten's avatar
Leander Schulten committed
104
            enabled: UserManagment.currentUser.havePermission(Permission.CHANGE_POSITION);
105
            Layout.minimumWidth: 40
106
            text: deviceModelView.currentModelData ? deviceModelView.currentModelData.position.y : ""
107
            validator: IntValidator{}
108
            onTextChanged: if(deviceModelView.currentModelData) deviceModelView.currentModelData.position.y = text.length?text:0
109
        }
110
        Button{
111
            enabled: UserManagment.currentUser.havePermission(Permission.CHANGE_POSITION);
112
            visible: deviceModelView.currentModelData ? deviceModelView.placeOnMapCallback && deviceModelView.currentModelData.position.x === -1 || deviceModelView.currentModelData.position.x === -1 : false
113
            text: "Place on map"
114
            onClicked: deviceModelView.placeOnMapCallback(deviceModelView.currentModelData)
115
116
            height: implicitHeight - 15
        }
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192

    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);
                                }
                            }
                        }
                    }
                }
            }
        }
    }

193
}