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