1 import Qt 4.6 |
|
2 import QtSFW 1.0 |
|
3 |
|
4 //Layout of the ServiceList control |
|
5 //--------------------------------- |
|
6 //|ServiceList | |
|
7 //| ----------------------------- | |
|
8 //| |title | | |
|
9 //| ----------------------------- | |
|
10 //| ----------------------------- | |
|
11 //| |listFrame | | |
|
12 //| |-------------------------- | | |
|
13 //| ||serviceListView | | | |
|
14 //| ||- listItem | | | |
|
15 //| ||- listItem | | | |
|
16 //| ||- listItem | | | |
|
17 //| |---------------------------| | |
|
18 //| ----------------------------- | |
|
19 //--------------------------------- |
|
20 |
|
21 Rectangle { |
|
22 property variant dialService: 0 |
|
23 signal serviceSelected |
|
24 |
|
25 Text { |
|
26 id: title |
|
27 height: 20 |
|
28 width: 200 |
|
29 anchors.top: parent.top |
|
30 anchors.left: parent.left |
|
31 anchors.topMargin: 5 |
|
32 anchors.leftMargin: 5 |
|
33 text: "<b>Select dial service:</b>" |
|
34 } |
|
35 |
|
36 Rectangle { |
|
37 id : listFrame |
|
38 width: childrenRect.width |
|
39 height: childrenRect.height |
|
40 anchors.top: title.bottom |
|
41 anchors.left: parent.left; |
|
42 anchors.topMargin: 5 |
|
43 anchors.leftMargin: 5 |
|
44 anchors.rightMargin: 5 |
|
45 border.color: "black" |
|
46 border.width: 3 |
|
47 property bool nohighlightlistitem : true |
|
48 //! [1] |
|
49 Component { |
|
50 id: delegate |
|
51 //! [1] |
|
52 //Rectangle item to draw a list view item |
|
53 //This includes 2 line of text: |
|
54 // ------------------------------------------ |
|
55 // |Service: LandDialer (1.0) | |
|
56 // |Interface: com.nokia.qt.examples Dialer | |
|
57 // ------------------------------------------ |
|
58 Rectangle { |
|
59 id: listItem |
|
60 width: serviceListView.width |
|
61 height: 40 |
|
62 border.color: "black" |
|
63 border.width: 1 |
|
64 opacity: 0.6 |
|
65 |
|
66 //! [2] |
|
67 MouseRegion { |
|
68 id: listItemMouseRegion |
|
69 anchors.fill: parent |
|
70 onClicked: { |
|
71 if(listFrame.nohighlightlistitem){ |
|
72 serviceListView.highlight = highlight |
|
73 listFrame.nohighlightlistitem = false; |
|
74 } |
|
75 serviceListView.currentIndex = index; |
|
76 dialService = model.modelData; |
|
77 console.log("HELLO: " + dialService + " " + model.modelData); |
|
78 serviceSelected() |
|
79 } |
|
80 } |
|
81 |
|
82 Text { |
|
83 id: serviceItemInfo |
|
84 anchors.top: parent.top |
|
85 anchors.left: parent.left |
|
86 anchors.topMargin: 5 |
|
87 anchors.leftMargin: 3 |
|
88 text: " <b>Service:</b> " + serviceName + " (" + version + ")" |
|
89 } |
|
90 |
|
91 Text { |
|
92 id: serviceItemInterfaceName |
|
93 anchors.top: serviceItemInfo.bottom |
|
94 anchors.left: parent.left |
|
95 anchors.topMargin: 2 |
|
96 anchors.leftMargin: 3 |
|
97 text: " <b>Interface:</b> " + interfaceName; |
|
98 } |
|
99 //! [2] |
|
100 } |
|
101 } |
|
102 |
|
103 //! [3] |
|
104 Component { |
|
105 id: highlight |
|
106 |
|
107 Rectangle { |
|
108 width: childrenRect.width |
|
109 border.color: "black"; border.width: 2 |
|
110 height: 30 |
|
111 color : "lightsteelblue" |
|
112 gradient: Gradient { |
|
113 GradientStop {position: 0.0; color: "steelblue"} |
|
114 GradientStop {position: 0.5; color: "lightsteelblue"} |
|
115 GradientStop {position: 1.0; color: "steelblue"} |
|
116 } |
|
117 } |
|
118 } |
|
119 //! [3] |
|
120 |
|
121 //! [0] |
|
122 ListView { |
|
123 id: serviceListView |
|
124 height: 100 |
|
125 width: 260 |
|
126 anchors.topMargin: 5 |
|
127 anchors.leftMargin: 5 |
|
128 anchors.rightMargin: 5 |
|
129 model: services.registeredservices |
|
130 //! [0] |
|
131 opacity: 1 |
|
132 delegate: delegate |
|
133 currentIndex: -1 |
|
134 clip: true |
|
135 } |
|
136 } |
|
137 |
|
138 Services { |
|
139 id: services |
|
140 } |
|
141 } |
|