-
Notifications
You must be signed in to change notification settings - Fork 11
/
DataColumn.qml
39 lines (35 loc) · 1.01 KB
/
DataColumn.qml
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
import QtQuick 2.0
QtObject {
property var field
property string label
property string type: "string"
property string namespace
property bool visible: true
property var format: function (value) { return value; }
property bool invertColorRating: false
property Component cell
function getValue(field, row) {
if (typeof field == "function") return field(row)
var tmp = row;
var from = 0;
for (var i = 0; i < field.length; i++) {
if (field[i] === '.') {
if (field[i - 1] == ')') {
from = i + 1;
continue;
}
tmp = tmp[field.substring(from, i)];
from = i + 1;
}
if (field[i] === '(') {
tmp = tmp[field.substring(from, i)]();
i++;
from = i + 1;
}
}
if (from < i) {
tmp = tmp[field.substring(from, i)];
}
return tmp;
}
}