-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcomponentCreation.js
87 lines (62 loc) · 2.31 KB
/
componentCreation.js
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
var component;
var seriesInfo;
function updateItemPosition( startIndex ){
var size = chartRect.children.length
for( var i = startIndex; i < size; i++ ){
chartRect.children[i].y -= 30
}
}
function listAllChildren(){
console.log( " in listAllChildren" )
var size = chartRect.children.length
for( var i=0; i<size; i++ ){
console.log( chartRect.children[i].objectName + " index is " + chartRect.children[i].index )
}
}
function updateIndex( deletedIndex ){
var size = chartRect.children.length
for( var i=deletedIndex; i < size; i++ ){
chartRect.children[i].index -= 1
}
listAllChildren()
}
function deleteLineSeries( seriesName, index ){
console.log( seriesName + " is deleted. Index = " + index )
chartRect.deletedIndex = index
}
function createLineSerisInfos( activeLineSeries, name, color ) {
component = Qt.createComponent("LineSeriesInfo.qml");
if( component.status === Component.Ready ){
//console.log("here1");
finishCreation( activeLineSeries, name, color );
}else{
console.log(component.status);
console.log("Error loading component: ", component.errorString() );
component.statusChanged.connect( finishCreation( activeLineSeries, name, color ) );
}
}
function finishCreation( activeLineSeries, name, color ){
var topMargin = 38
var itemHeight = 25
var gap = 5
if( component.status === Component.Ready ){
seriesInfo = component.createObject( chartRect, { "x" : 0, "y": topMargin + itemHeight * (activeLineSeries-1) + gap*( activeLineSeries-1 ) } );
if( seriesInfo === null ){
console.log("Error creating object");
}else{
seriesInfo.objectName = name;
seriesInfo.seriesColor.color = color
seriesInfo.index = activeLineSeries;
seriesInfo.deleteLineSeries.connect( deleteLineSeries );
console.log("Create " + name + " with index " + activeLineSeries );
}
}else if( component.status === Component.Error ){
console.log("Error loading component: ", component.errorString() );
}
}
function deleteAllLineSeries(){
var size = chartRect.children.length
for( var i=1; i<size; i++ ){
chartRect.children[i].destroy()
}
}