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

8
ModelView{
9
10
    model: programmPrototypeModel
    id: modelView
11

Leander Schulten's avatar
Leander Schulten committed
12
13
    addButton.text: "Add Prototype"
    removeButton.text: "Remove Prototype"
14
15
    onAddClicked: dialog.visible = true
    onRemoveClicked: ModelManager.removeDmxProgramPrototype(remove);
16
    rows: 5
17
18
19
20
21
22
23
24
25
26
27
28
29
30
    sortModel: ListModel{
        ListElement{
            name: "Creation Date"
            sortPropertyName: ""
        }
        ListElement{
            name: "Name"
            sortPropertyName: "name"
        }
        ListElement{
            name: "Device Prototype"
            sortPropertyName: "devicePrototype.name"
        }
    }
31
32
33
34
35
36
37
    Label{
        Layout.topMargin: 4
        Layout.columnSpan: 2
        text: "Die einzelnen ChannelProgramme :"
        font.underline: true
    }

38
    ListView{
39
        clip: true
40
41
42
        Layout.columnSpan: 2
        Layout.fillHeight: true
        Layout.fillWidth: true
43
44
45
46
47
        id: channelView
        spacing: 32
        model: modelView.currentModelData ? modelView.currentModelData.channelProgramms : null
        ScrollBar.vertical: ScrollBar {
            policy: channelView.contentHeight > channelView.height ? ScrollBar.AlwaysOn : ScrollBar.AlwaysOff
48
        }
49
50
        delegate: ColumnLayout{
            width: channelView.width
51
            RowLayout{
52
53
54
                Layout.preferredHeight: 50
                Layout.fillWidth: true
                spacing: 8
55
                Label{
56
                    text: editor.channelProgramm.channel.name
57
58
59
60
                    font.bold: true
                    Layout.minimumWidth: 60
                }
                Label{
61
                    text: "Time: "
62
63
64
65
                    visible: editor.currentTimePoint.hasCurrent
                }
                TextInputField{
                    Layout.minimumWidth: 30
66
                    text: editor.currentTimePoint.time
67
68
69
70
                    visible: editor.currentTimePoint.hasCurrent
                    onAccepted: editor.currentTimePoint.time = text
                }
                Label{
71
                    text:"Value: "
72
73
74
75
                    visible: editor.currentTimePoint.hasCurrent
                }
                TextInputField{
                    Layout.minimumWidth: 30
76
                    text: editor.currentTimePoint.value
77
78
79
80
81
                    visible: editor.currentTimePoint.hasCurrent
                    onAccepted: editor.currentTimePoint.value = text
                    validator: IntValidator{bottom: 0; top:255}
                }
                Label{
82
83
                    text: "Curve type:"
                    visible: editor.selectedEasingCurve >= 0
84
85
86
                }
                ComboBox{
                    model: easingModel
Leander Schulten's avatar
Leander Schulten committed
87
                    property bool open: false
88
89
90
                    Layout.preferredWidth: 150
                    currentIndex: editor.selectedEasingCurve
                    visible: editor.selectedEasingCurve >= 0
Leander Schulten's avatar
Leander Schulten committed
91
92
93
94
                    onDownChanged: {
                        open|=down;
                    }
                    onHighlighted: {
95
                        if(open)editor.selectedEasingCurve = index
Leander Schulten's avatar
Leander Schulten committed
96
97
                    }
                    onActivated: {
98
                        editor.selectedEasingCurve = index
Leander Schulten's avatar
Leander Schulten committed
99
                        open=false;
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
            } // RowLayout
            ChannelProgrammEditor{
                id: editor
                Layout.preferredHeight: 100
                Layout.fillWidth: true
                clickRadius: 36
                channelProgramm: modelData
                Rectangle{
                    anchors.fill: parent
                    color: "lightgrey"
                    z: -1
                }
                Rectangle{
                    x: editor.hoverSegmentX
                    z: -0.5
                    width: editor.hoverSegmentLength
                    height: 100
                    color: Qt.rgba(.7,.7,.7)
                }
                Rectangle{
                    x: editor.selectedSegmentX
                    z: -0.4
                    width: editor.selectedSegmentLength
                    height: 100
                    color: Qt.rgba(.5,.5,.5)
                }                
                Rectangle{
                    anchors.top: parent.bottom
                    visible: editor.mouseX >= 0
                    x: editor.mouseX
                    width: 1
                    height: 4
                    color: Material.foreground
                    Label{
                        anchors.top: parent.bottom
                        anchors.horizontalCenter: parent.horizontalCenter
                        anchors.horizontalCenterOffset: editor.mouseX < contentWidth/2 ? -(editor.mouseX - contentWidth/2) : 0
                        horizontalAlignment: Text.AlignHCenter
                        text: editor.getValueForVisualX(editor.mouseX) + " at\n" + editor.getTimeForVisualX(editor.mouseX).toFixed(2);
                    }
                }
            } // ChannelProgrammEditor
        } // delegate: ColumnLayout
    } // ListView
146

147
148
149
150
151
152
    Label{
        Layout.columnSpan: 2
        Layout.fillWidth: true
        Layout.margins: 5
        wrapMode: Label.WrapAtWordBoundaryOrAnywhere
        text: "Hold N and click to create a new TimePoint. You can select a TimePoint to change its values. A selected TimePoint can be deleted with d. You can drag a TimePoint. Hold x while scrolling to change the zooming."
153
154
    }

155
156
    Popup{
        modal: true
157
158
        id: dialog
        width: 300
159
160
161
162
163
        x: (parent.width - width) / 2
        y: (parent.height - height) / 2
        contentItem: ColumnLayout{
            spacing: 10
            ComboBox{
164
                Layout.fillWidth: true
165
                id: prototype
166
167
168
169
170
                model: devicePrototypeModel
                textRole: "display"
            }
            RowLayout{
                Label{
171
172
                    id: nameLabel
                    text: "Name :"
173
174
175
                }
                TextInputField{
                    Layout.fillWidth: true
176
                    id: name
177
178
179
180
                }
            }
            RowLayout{
                Label{
181
                    text: "Description :"
182
183
184
                }
                TextInputField{
                    Layout.fillWidth: true
185
                    id: description
186
187
188
189
190
                }
            }
            RowLayout{
                Button{
                    Layout.fillWidth: true
191
                    text: "Abbrechen"
192
193
194
195
                    onClicked: dialog.visible = false
                }
                Button{
                    Layout.fillWidth: true
196
                    text: "Erzeugen"
197
198
199
200
201
202
                    onClicked: {
                        if(name.text===""){
                            name.underlineColor = "red";
                        }else{
                            dialog.visible = false;
                            ModelManager.addProgrammPrototype(prototype.currentIndex,name.text,description.text);
203
204
                        }
                    }
205
206
207
208
                } // Button
            } // RowLayout
        } // contentItem: ColumnLayout
    } // Popup
209
}