Merge branch 'qml'
[mdictionary] / src / mdictionary / qml / TableWidget.qml
1 import Qt 4.7
2
3 Rectangle {
4     SystemPalette { id: myPalette; colorGroup: SystemPalette.Active }
5     color : myPalette.window;
6
7     id: rectangle1
8     width: 400;
9     height: 400;
10     anchors.fill: parent
11
12     signal dictLink(string link);
13     signal fromChange(string value);
14     signal toChange(string value)
15
16
17     function setFromStartValues(startFrom, startTo, startFromIndex, startToIndex){
18         comboFrom.setStartValue(startFrom, startFromIndex)
19         comboTo.setStartValue(startTo, startToIndex)
20     }
21
22     function setToStartValues(startFrom, startTo, startFromIndex, startToIndex){
23         comboFrom.setStartValue(startFrom, startFromIndex)
24         comboTo.setStartValue(startTo, startToIndex)
25     }
26
27     MouseArea {
28         id: mouse_area1
29         anchors.fill: parent
30         z:-1
31         onClicked: {
32             comboTo.expanded=false;
33             comboFrom.expanded=false;
34         }
35     }
36
37     ComboBox {
38         id: comboFrom
39         model: fromModell
40         anchors.right: comboFromField.right
41         anchors.left: comboFromField.left
42         parentField: comboFromField
43         expanded: false
44         height: 20
45         basicHeight:20
46         index: 1
47         onExpandedChanged: {
48             if(expanded==true){
49                 z=2;
50                 mouse_area1.z=1;
51             }
52             else{
53                 z=0;
54                 mouse_area1.z=-1;
55             }
56        }
57        onValueSelected: rectangle1.fromChange(value)
58     }
59
60     ComboBox {
61         id: comboTo
62         model: fromModell
63         anchors.right: comboToField.right
64         anchors.left: comboToField.left
65         parentField: comboToField
66         expanded: false
67         height: 20
68         basicHeight:20
69         index: 1
70         onExpandedChanged: {
71             if(expanded==true){
72                 z=2;
73                 mouse_area1.z=1;
74             }
75             else{
76                 z=0;
77                 mouse_area1.z=-1;
78             }
79        }
80        onValueSelected: rectangle1.toChange(value)
81     }
82
83     Item {
84         id: comboFromField
85         width: 120
86         anchors.left: fromLabel.right
87         anchors.leftMargin: 5
88         anchors.bottom: parent.bottom
89         anchors.bottomMargin: 10
90         anchors.top: parent.top
91     }
92
93     Item {
94         id: comboToField
95         width: 120
96         anchors.left: toLabel.right
97         anchors.leftMargin: 5
98         anchors.bottom: parent.bottom
99         anchors.bottomMargin: 10
100         anchors.top: parent.top
101     }
102
103     Text {
104         id: fromLabel
105         text: qsTr("From: ");
106         anchors.top: parent.top
107         anchors.topMargin: 3
108         font.pixelSize: 12
109     }
110
111     Text {
112         id: toLabel
113         text: qsTr("To: ");
114         anchors.left: comboFrom.right
115         anchors.leftMargin: 15
116         anchors.verticalCenterOffset: 0
117         anchors.verticalCenter: fromLabel.verticalCenter
118         font.pixelSize: 12
119     }
120
121     Item {
122         id: item1
123         anchors.topMargin: 30
124         anchors.fill: parent
125         ScrollBar2 {
126             id: horizontalScrollBar1
127             z:2;
128             width: parent.width-12;
129             windowHeight: parent.height
130             anchors.left: parent.left
131             orientation: Qt.Horizontal
132             position: 100
133         }
134         ScrollBar2 {
135             id: horizontalScrollBar2
136             z:2;
137             width: parent.width-12;
138             windowHeight: parent.height
139             anchors.left: horizontalScrollBar1.left
140             anchors.leftMargin: horizontalScrollBar1.position
141             orientation: Qt.Horizontal
142             position: 100
143         }
144         ScrollBar2 {
145             id: horizontalScrollBar3
146             z:2;
147             width: parent.width-12;
148             windowHeight: parent.height
149             anchors.left: horizontalScrollBar2.left
150             anchors.leftMargin: horizontalScrollBar2.position
151             orientation: Qt.Horizontal
152             position: 100
153         }
154
155         ElementsListView{
156             id: dictList
157             width: rectangle1.width
158             anchors.topMargin: 0
159             anchors.top: parent.top
160             anchors.bottom: parent.bottom
161             highlightResizeSpeed: 1000
162
163             header: Component{
164                 id: dictListHeader
165                 Item {
166                     width: rectangle1.width
167                     height: 20
168                     Row {
169                         anchors.fill: parent
170                         Rectangle {
171                             id: fromRecHeader
172                             width: horizontalScrollBar1.position
173                             height: parent.height
174                             radius: 1
175                             gradient: Gradient { GradientStop { position: 0.3; color: "#a0cbec" } GradientStop { position: 0.99; color: "#35a0f1" } }
176
177                             Text {
178                                 id: fromTextHeader
179                                 text: qsTr("From");
180                                 elide: Text.ElideRight
181                                 font.pixelSize: 12
182                                 anchors.centerIn: parent
183                             }
184                         }
185                         Rectangle {
186                             id: toRecHeader
187                             width: horizontalScrollBar2.position
188                             height: parent.height
189                             radius: 1
190                             gradient: Gradient { GradientStop { position: 0.3; color: "#a0cbec" } GradientStop { position: 0.99; color: "#35a0f1" } }
191
192                             Text {
193                                 id: toTextHeader
194                                 text: qsTr("To");
195                                 elide: Text.ElideRight
196                                 font.pixelSize: 12
197                                 anchors.centerIn: parent
198                             }
199                         }
200                         Rectangle {
201                             id: nameRecHeader
202                             width: horizontalScrollBar3.position
203                             height: parent.height
204                             radius: 1
205                             gradient: Gradient { GradientStop { position: 0.3; color: "#a0cbec" } GradientStop { position: 0.99; color: "#35a0f1" } }
206
207                             Text {
208                                 id: nameTextHeader
209                                 text: qsTr("Title");
210                                 elide: Text.ElideRight
211                                 font.pixelSize: 12
212                                 anchors.centerIn: parent
213                             }
214                         }
215                         Rectangle {
216                             id: sizeRecHeader
217                             width: 100;
218                             height: parent.height
219                             radius: 1
220                             gradient: Gradient { GradientStop { position: 0.3; color: "#a0cbec" } GradientStop { position: 0.99; color: "#35a0f1" } }
221
222                             Text {
223                                 id: sizeTextHeader
224                                 text: qsTr("Size");
225                                 elide: Text.ElideRight
226                                 font.pixelSize: 12
227                                 anchors.centerIn: parent
228                             }
229                         }
230                     }
231                 }
232             }
233
234             delegate: Component{
235                 id: dictListDelegate
236                 Item {
237                     width: rectangle1.width
238                     height:nameText.height
239                     MouseArea{
240                         anchors.fill: parent
241                         onClicked: {
242                             dictList.currentIndex = index
243                         }
244                         onDoubleClicked: {
245                             rectangle1.dictLink(link)
246                         }
247                     }
248                     Row {
249                         anchors.fill: parent
250                         Text {
251                             id: fromText
252                             text: " "+from+" ";
253                             width:  horizontalScrollBar1.position
254                             elide: Text.ElideRight
255                         }
256
257                         Text {
258                             id: toText
259                             text: " "+to+" ";
260                             width:  horizontalScrollBar2.position
261                             elide: Text.ElideRight
262                         }
263
264                         Text {
265                             id: nameText
266                             text: " "+name+" ";
267                             width:  horizontalScrollBar3.position
268                             elide: Text.ElideRight
269                         }
270                         Text {
271                             id: sizeText
272                             text: " "+size+" ";
273                             width:  100
274                             elide: Text.ElideRight
275                         }
276                     }
277                 }
278             }
279             model: dictModel
280         }
281     }
282 }