Add keyboard support to comboBox, HistoryList. Fix some issues with keyboard support.
[mdictionary] / src / mdictionary / qml / HistoryListDialog.qml
1 import Qt 4.7
2
3 Rectangle {
4     SystemPalette { id: myPalette; colorGroup: SystemPalette.Active }
5     color : myPalette.window;
6     function setFocus() {
7         historyList.setFocus()
8     }
9
10     signal selectedRow(int nr)
11
12     id: rectangle1
13     width: 100
14     height: 300
15
16
17     Rectangle {
18         id: rectangle2
19         color: "#ffffff"
20         anchors.topMargin: 20
21         anchors.fill: parent
22     }
23
24     ElementsListView{
25
26         id: historyList
27         width: rectangle1.width
28         anchors.topMargin: 20
29         anchors.bottom: parent.bottom
30         anchors.top: parent.top
31         highlightResizeSpeed: 1000
32
33         Keys.onPressed: {
34             if ((currentIndex < 0 || currentIndex >= count) && (event.key == Qt.Key_Up || event.key == Qt.Key_Down)){
35                 currentIndex = 0
36             }
37
38             if ((event.key == Qt.Key_Return || event.key == Qt.Key_Enter) && currentIndex >= 0){
39                 selectedRow(currentIndex)
40             }
41         }
42
43         delegate: Component{
44             id: historyListDelegate
45             Item {
46                 width: rectangle1.width
47                 height: typeText.height
48                 MouseArea{
49                     anchors.fill: parent
50                     onClicked: {
51                         historyList.currentIndex = number
52                     }
53                     onDoubleClicked: {
54                         selectedRow(number)
55                     }
56                 }
57                 Row {
58                     Text {
59                         id: typeText
60                         text: (number+1) +". "+word
61                         width: rectangle1.width
62                     }
63                 }
64             }
65         }
66         model: historyTypeModel
67     }
68
69     Text {
70         id: text1
71         x: 29
72         y: 0
73         width: 80
74         height: 20
75         text: qsTr("History");
76         anchors.horizontalCenterOffset: 19
77         anchors.topMargin: 0
78         anchors.top: parent.top
79         anchors.horizontalCenter: parent.horizontalCenter
80         font.pixelSize: 12
81     }
82
83 }