Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import QtQuick 2.9
- import QtQuick.Window 2.2
- import QtQuick.Controls 2.5
- import QtQuick.Dialogs 1.2
- import changer 1.0
- Window {
- visible: true
- width: 640
- height: 480
- title: qsTr("Hello World")
- color: "#ffffff"
- ListModel{
- id: listMod
- ListElement{
- state: "bad"
- textid: "id"
- place: "placeid"
- measure: "2.25"
- }
- }
- ListView {
- property int model_value: 14
- id: mainList
- spacing: -15
- layoutDirection: "LeftToRight"
- orientation:
- "Horizontal"
- delegate:
- Item{
- id: delegatetolistItem
- Rectangle {
- id: roundforgenerator
- height: 25
- width: 25
- radius:25
- // color: "#008000"
- border.width: 1
- state: model.state || "good"
- ToolTip {
- id: rectangleToolTip
- visible: rectangleToolTip.text ? rectangleArea.containsMouse : false
- text: descriptionforgenerator.text
- }
- MouseArea {
- id: rectangleArea
- anchors.fill: parent
- hoverEnabled: true
- }
- Text {
- y: parent.height + 2
- font.pixelSize: 13
- id: textforgenerator
- text: model.textid || qsTr("id")
- }
- Text{
- id: descriptionforgenerator
- text: model.place || qsTr("place")
- visible: false
- }/**Tooltip text*/
- Text {
- id: textformeasuregenerator
- text: model.measure || qsTr("0")
- visible: true
- anchors.centerIn: parent
- }
- states: [
- State {
- name: "good"
- PropertyChanges {
- target: roundforgenerator; color: "green"
- }
- },
- State {
- name: "bad"
- PropertyChanges {
- target: roundforgenerator; color: "red"
- }
- },
- State {
- name: "working"
- PropertyChanges {
- target: roundforgenerator; color: "yellow"
- }
- },
- State {
- name: "available"
- PropertyChanges {
- target: roundforgenerator; color: "blue"
- }
- }
- ]
- }
- }
- model: listMod
- // anchors.bottom: parent
- //anchors.centerIn: parent
- }
- function add_component(idfromapp,data,sig,place){
- // listMod.append({"attributes":[{"state":sig},{"textid":idfromapp},{"place":place},{"measure":data}]})
- listMod.append({"state":sig, "textid":idfromapp,"place":place,"measure":data})
- }
- function update(idbutt,idfromapp,data,sig,place){
- listMod.set(idbutt,{"state":sig,"textid":idfromapp,"place":place,"measure":data})
- }
- function remove(idbutt){
- listMod.remove(idbutt)
- }
- function updateMeasure(idbutt,data,sig){
- listmod.set(idbutt,{"state":sig,"measure":data})
- }
- Changer{
- id: changeit
- onUpdate: {
- update(idbutt,idfromapp,data,sig,place)}
- onUpdateMeasure: {
- updateMeasure(idbutt,data,sig)
- }
- onAdding: {
- console.log("pew-pew it work!")
- add_component(idfromapp,data,sig,place)
- // listMod.insert({"state":sig, "textid":idfromapp,"place":place,"measure":data})
- }
- onDeleteSig: {
- remove(idbutt)
- }
- onComplete: {
- console.log("pew-pew it work!")
- }
- }
- /*signals add remove with listView work*/
- Button{
- /* onClicked: add_component()*/
- x:20
- y:30
- height: 50
- width: 50
- text: qsTr("ñíÿòèå")
- onClicked: changeit.sensors_poll()
- }
- Button{
- x:50
- y:30
- height: 50
- width: 50
- text: qsTr("DB")
- onClicked: changeit.first_load()
- }
- Button{
- x:100
- y:30
- height: 50
- width: 50
- text: qsTr("Start")
- onClicked: add_component("1","1","bad","1")
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement