File: main.qml

package info (click to toggle)
uranium 5.0.0-9
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,328 kB
  • sloc: python: 31,765; sh: 132; makefile: 12
file content (123 lines) | stat: -rw-r--r-- 2,588 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
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
import QtQuick 2.4
import QtQuick.Controls 2.10
import QtQuick.Dialogs

import Example 1.0 as Example

ApplicationWindow
{
    visible: true
    width: 640 * screenScaleFactor
    height: 480 * screenScaleFactor

    toolBar: ToolBar
    {
        Row
        {
            anchors.fill: parent
            ToolButton { text: "Open"; onClicked: fileDialog.open() }
        }
    }

    SplitView
    {
        anchors.fill: parent
        orientation: Qt.Vertical

        TextArea
        {
            id: metaDataText
            readOnly: true

            textFormat: TextEdit.RichText
        }
        TreeView
        {
            TableViewColumn
            {
                title: "Key"
                role: "key"
            }
            TableViewColumn
            {
                title: "Label"
                role: "label"
            }
            TableViewColumn
            {
                title: "Type"
                role: "type"
            }
            TableViewColumn
            {
                title: "Default Value"
                role: "default_value"
            }

            Layout.fillHeight: true;
            model: Example.DefinitionTreeModel { id: model; }

            onActivated:
            {
                var setting = model.get(index)
                detailsText.text = "<h2>%1</h2><ul>".arg(setting["key"])

                for(var i in setting)
                {
                    detailsText.text += "<li><b>%1:</b> %2".arg(i).arg(setting[i])
                }

                detailsText.text += "</ul>"
            }
        }
        TextArea
        {
            id: detailsText
            readOnly: true
            textFormat: TextEdit.AutoText
        }
    }

    FileDialog
    {
        id: fileDialog

        onAccepted:
        {
            loader.load(fileUrl)
        }
    }

    Example.DefinitionLoader
    {
        id: loader;

        onLoaded:
        {
            detailsText.text = ""
            metaDataText.text = ""

            var text = ""
            for(var i in loader.metaData)
            {
                text += "<li><b>%1:</b> %2</li>".arg(i).arg(loader.metaData[i])
            }

            if(text != "")
            {
                metaDataText.text = "<h2>Metadata</h2><ul>%1</ul>".arg(text)
            }

            model.containerId = loader.definitionId
        }
        onError: detailsText.text = errorText
    }

    Component.onCompleted:
    {
        if(open_file != undefined && open_file != "")
        {
            loader.load(open_file)
        }
    }
}