Fix bug with app crash on exit. Add keyboard support in wordList, DictTypeSelectDialo...
[mdictionary] / src / mdictionary / qml / WordListWidget.qml
index 145ad89..742cf49 100644 (file)
@@ -27,23 +27,22 @@ import Qt 4.7
 Rectangle {
 
     function changeWordState(nr, state) {
-        console.log("LOOOOOL")
         wordList.currentIndex = nr
         wordModel.setModelProperty(wordList.currentIndex, state, "isBookmarked")
+    }
 
+    function changeWordStateByIndex() {
+        wordModel.setModelPropertyByIndex(wordList.currentIndex, "isBookmarked")
     }
 
     function setEnabled(Boolean) { wordList.enabled = Boolean }
     function setWordListEmpty(Boolean) { wordList.empty = Boolean }
     function setFocus() {
-        console.log("juhu")
         wordList.setFocus()
-//        activeFocus = true
-        console.log(focus + "a " + activeFocus)
-        console.log(wordList.focus + "b " + wordList.activeFocus)
     }
 
     signal wordSelected(string word);
+    signal wordSelectedByIndex(int nr);
 
     SystemPalette { id: myPalette; colorGroup: SystemPalette.Active }
 
@@ -59,8 +58,12 @@ Rectangle {
         highlightResizeSpeed: 1000
         property bool empty: false
 
-        onCurrentIndexChanged: {
-            console.log("111!!!WTF " + currentIndex)
+        Keys.onPressed: {
+            if (event.key == Qt.Key_Space && currentIndex >= 0){
+                rectangle1.changeWordStateByIndex();
+            } else if ((event.key == Qt.Key_Return || event.key == Qt.Key_Enter) && currentIndex >= 0){
+                rectangle1.wordSelectedByIndex(currentIndex)
+            }
         }
 
         delegate: Component{
@@ -77,7 +80,7 @@ Rectangle {
                 MouseArea{
                     anchors.fill: parent
                     onClicked: {
-                        wordList.currentIndex = index// number
+                        wordList.currentIndex = index
                         rectangle1.wordSelected(word)
                     }
                 }