Fix bug with app crash on exit. Add keyboard support in wordList, DictTypeSelectDialo...
[mdictionary] / src / mdictionary / qml / DictTypeSelectDialog.qml
1 /*******************************************************************************
2
3     This file is part of mDictionary.
4
5     mDictionary is free software: you can redistribute it and/or modify
6     it under the terms of the GNU General Public License as published by
7     the Free Software Foundation, either version 3 of the License, or
8     (at your option) any later version.
9
10     mDictionary is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     GNU General Public License for more details.
14
15     You should have received a copy of the GNU General Public License
16     along with mDictionary.  If not, see <http://www.gnu.org/licenses/>.
17
18     Copyright 2010 Comarch S.A.
19
20 *******************************************************************************/
21 /*!
22     author: Marcin Kaźmierczak <marcin.kazmierczak@comarch.pl>
23 */
24
25 import Qt 4.7
26
27 Rectangle {
28     SystemPalette { id: myPalette; colorGroup: SystemPalette.Active }
29     signal selectedRow(int nr)
30     function setFocus() {
31         dictTypeList.setFocus()
32     }
33
34     id: rectangle1
35     color: myPalette.base
36     anchors.fill: parent
37
38     ElementsListView{
39         Keys.onPressed: {
40             if ((event.key == Qt.Key_Return || event.key == Qt.Key_Enter) && currentIndex >= 0){
41                 selectedRow(currentIndex)
42             }
43         }
44
45         id: dictTypeList
46         width: rectangle1.width
47         height: rectangle1.height
48         highlightResizeSpeed: 1000
49         delegate: Component{
50             id: dictTypeListDelegate
51             Item {
52                 width: rectangle1.width
53                 height: typeText.height
54                 MouseArea{
55                     anchors.fill: parent
56                     onClicked: {
57                         dictTypeList.currentIndex = number
58                     }
59                     onDoubleClicked: {
60                         selectedRow(number)
61                     }
62                 }
63                 Row {
64                     Text {
65                         id: typeText
66                         text: type
67                         width: rectangle1.width
68                     }
69                 }
70             }
71
72         }
73         model: dictTypeModel
74     }
75 }