table view
[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
14     ScrollBar2 {
15         id: horizontalScrollBar1
16         z:2;
17         width: parent.width-12;
18         windowHeight: parent.height
19         anchors.left: parent.left
20         orientation: Qt.Horizontal
21         position: 100
22     }
23     ScrollBar2 {
24         id: horizontalScrollBar2
25         z:2;
26         width: parent.width-12;
27         windowHeight: parent.height
28         anchors.left: horizontalScrollBar1.left
29         anchors.leftMargin: horizontalScrollBar1.position
30         orientation: Qt.Horizontal
31         position: 100
32     }
33     ScrollBar2 {
34         id: horizontalScrollBar3
35         z:2;
36         width: parent.width-12;
37         windowHeight: parent.height
38         anchors.left: horizontalScrollBar2.left
39         anchors.leftMargin: horizontalScrollBar2.position
40         orientation: Qt.Horizontal
41         position: 100
42     }
43
44     ElementsListView{
45         id: dictList
46         width: rectangle1.width
47         anchors.top: parent.top
48         anchors.bottom: parent.bottom
49         highlightResizeSpeed: 1000
50
51         header: Component{
52             id: dictListHeader
53             Item {
54                 width: rectangle1.width
55                 height: 20
56                 Row {
57                     anchors.fill: parent
58                     Rectangle {
59                         id: fromRecHeader
60                         width: horizontalScrollBar1.position
61                         height: parent.height
62                         radius: 1
63                         gradient: Gradient { GradientStop { position: 0.3; color: "#a0cbec" } GradientStop { position: 0.99; color: "#35a0f1" } }
64
65                         Text {
66                             id: fromTextHeader
67                             text: qsTr("From");
68                             elide: Text.ElideRight
69                             font.pixelSize: 12
70                             anchors.centerIn: parent
71                         }
72                     }
73                     Rectangle {
74                         id: toRecHeader
75                         width: horizontalScrollBar2.position
76                         height: parent.height
77                         radius: 1
78                         gradient: Gradient { GradientStop { position: 0.3; color: "#a0cbec" } GradientStop { position: 0.99; color: "#35a0f1" } }
79
80                         Text {
81                             id: toTextHeader
82                             text: qsTr("To");
83                             elide: Text.ElideRight
84                             font.pixelSize: 12
85                             anchors.centerIn: parent
86                         }
87                     }
88                     Rectangle {
89                         id: nameRecHeader
90                         width: horizontalScrollBar3.position
91                         height: parent.height
92                         radius: 1
93                         gradient: Gradient { GradientStop { position: 0.3; color: "#a0cbec" } GradientStop { position: 0.99; color: "#35a0f1" } }
94
95                         Text {
96                             id: nameTextHeader
97                             text: qsTr("Title");
98                             elide: Text.ElideRight
99                             font.pixelSize: 12
100                             anchors.centerIn: parent
101                         }
102                     }
103                     Rectangle {
104                         id: sizeRecHeader
105                         width: 100;
106                         height: parent.height
107                         radius: 1
108                         gradient: Gradient { GradientStop { position: 0.3; color: "#a0cbec" } GradientStop { position: 0.99; color: "#35a0f1" } }
109
110                         Text {
111                             id: sizeTextHeader
112                             text: qsTr("Size");
113                             elide: Text.ElideRight
114                             font.pixelSize: 12
115                             anchors.centerIn: parent
116                         }
117                     }
118                 }
119             }
120         }
121
122         delegate: Component{
123             id: dictListDelegate
124             Item {
125                 width: rectangle1.width
126                 height:nameText.height
127                 MouseArea{
128                     anchors.fill: parent
129                     onClicked: {
130                         dictList.currentIndex = index
131                     }
132                     onDoubleClicked: {
133                         rectangle1.dictLink(link)
134                     }
135                 }
136                 Row {
137                     anchors.fill: parent
138                     Text {
139                         id: fromText
140                         text: " "+from+" ";
141                         width:  horizontalScrollBar1.position
142                         elide: Text.ElideRight
143                     }
144
145                     Text {
146                         id: toText
147                         text: " "+to+" ";
148                         width:  horizontalScrollBar2.position
149                         elide: Text.ElideRight
150                     }
151
152                     Text {
153                         id: nameText
154                         text: " "+name+" ";
155                         width:  horizontalScrollBar3.position
156                         elide: Text.ElideRight
157                     }
158                     Text {
159                         id: sizeText
160                         text: " "+size+" ";
161                         width:  100
162                         elide: Text.ElideRight
163                     }
164                 }
165             }
166         }
167         model: dictModel
168     }
169 }