|
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 MouseArea { |
|
68 id: listItemMouseArea |
|
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 serviceSelected() |
|
78 } |
|
79 } |
|
80 |
|
81 Text { |
|
82 id: serviceItemInfo |
|
83 anchors.top: parent.top |
|
84 anchors.left: parent.left |
|
85 anchors.topMargin: 5 |
|
86 anchors.leftMargin: 3 |
|
87 text: " <b>Service:</b> " + serviceName + " (" + version + ")" |
|
88 } |
|
89 |
|
90 Text { |
|
91 id: serviceItemInterfaceName |
|
92 anchors.top: serviceItemInfo.bottom |
|
93 anchors.left: parent.left |
|
94 anchors.topMargin: 2 |
|
95 anchors.leftMargin: 3 |
|
96 text: " <b>Interface:</b> " + interfaceName; |
|
97 } |
|
98 //! [2] |
|
99 } |
|
100 } |
|
101 |
|
102 //! [3] |
|
103 Component { |
|
104 id: highlight |
|
105 |
|
106 Rectangle { |
|
107 width: childrenRect.width |
|
108 border.color: "black"; border.width: 2 |
|
109 height: 30 |
|
110 color : "lightsteelblue" |
|
111 gradient: Gradient { |
|
112 GradientStop {position: 0.0; color: "steelblue"} |
|
113 GradientStop {position: 0.5; color: "lightsteelblue"} |
|
114 GradientStop {position: 1.0; color: "steelblue"} |
|
115 } |
|
116 } |
|
117 } |
|
118 //! [3] |
|
119 |
|
120 //! [0] |
|
121 ListView { |
|
122 id: serviceListView |
|
123 height: 100 |
|
124 width: 260 |
|
125 anchors.topMargin: 5 |
|
126 anchors.leftMargin: 5 |
|
127 anchors.rightMargin: 5 |
|
128 model: services.registeredservices |
|
129 //! [0] |
|
130 opacity: 1 |
|
131 delegate: delegate |
|
132 currentIndex: -1 |
|
133 clip: true |
|
134 } |
|
135 } |
|
136 |
|
137 Services { |
|
138 id: services |
|
139 } |
|
140 } |