import QtQml

import QtQuick
import QtQuick.Controls

import QtQuick.Layouts


Item {
    id: mainWindow
    anchors.fill: parent

    SplitView {
        id: splitView
        orientation: Qt.Horizontal

        anchors.fill: parent
        anchors.margins: 2

        handle: Rectangle {
            implicitWidth: 6
            color: "darkgray"
        }

        Rectangle {
              SplitView.preferredWidth: parent.width/2
              SplitView.maximumWidth: parent.width/100*75
              SplitView.minimumWidth: parent.width/100*25
              color: "gray"

              ColumnLayout {
                  Text {
                      renderType: Text.NativeRendering
                      text: "gtld.node.name = " + gtld.node.name
                      font.pointSize: 18
                      color: "white"
                  }

                  Text {
                      renderType: Text.NativeRendering
                      text: "gtld.node.uuid = " + gtld.node.uuid.toString()
                      font.pointSize: 18
                      color: "white"
                  }

                  Text {
                      renderType: Text.NativeRendering
                      text: "gtld.node.parent.uuid = " + gtld.node.parent.uuid.toString()
                      font.pointSize: 18
                      color: "white"
                  }

                  Text {
                      renderType: Text.NativeRendering
                      text: "gtld.node.lastResult[\"tag\"] = " + gtld.node.lastResult?.[0]?.["tag"] || "undefined";
                      font.pointSize: 18
                      color: "white"
                  }

                  Text {
                      renderType: Text.NativeRendering
                      text: "gtld.storage.selectLastResults({args}).length = "
                      + gtld.node.selectLastResults(
                          {
                              count: 5,
                              tag: gtld.node.lastResult?.[0]?.["tag"] || "undefined"
                          }
                      ).length || "undefined";

                      font.pointSize: 18
                      color: "white"
                  }

              }
        }

        Rectangle {
            SplitView.preferredWidth: parent.width/2
            color: "lightGray"
            ListView{
                id: listView
                anchors.fill: parent

                spacing: 5
                model: gtld.node.selectLastResults(
                                {
                                   count: 5,
                                   tag: "tag",
                                }
                           )

                delegate: Rectangle {
                    height: 60
                    width: ListView.view.width
                    color: "darkblue"
                    Text {
                        renderType: Text.NativeRendering
                        anchors.centerIn: parent
                        color: "white"
                        text: "record fileName = " + modelData?.["recordOptions"]?.["recordFileName"] + 
                        "; skz = " + modelData["masterValues"]?.["skz"] + 
                        "; speed = " + modelData["masterValues"]?.["speed"]
                        font.pointSize: 12
                    }
                }
            }
        }
    }
}

