first (buggy) version of keyboard usage in qml list
[mdictionary] / src / mdictionary / qml / WordListWidget.qml
index 07cf206..145ad89 100644 (file)
@@ -27,16 +27,24 @@ import Qt 4.7
 Rectangle {
 
     function changeWordState(nr, state) {
+        console.log("LOOOOOL")
         wordList.currentIndex = nr
         wordModel.setModelProperty(wordList.currentIndex, state, "isBookmarked")
 
     }
 
-    function setEnabled(Boolean) { wordList.enabled = Boolean }  // slot
+    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);
 
-
     SystemPalette { id: myPalette; colorGroup: SystemPalette.Active }
 
     id: rectangle1
@@ -49,6 +57,11 @@ Rectangle {
 
         anchors.fill: parent
         highlightResizeSpeed: 1000
+        property bool empty: false
+
+        onCurrentIndexChanged: {
+            console.log("111!!!WTF " + currentIndex)
+        }
 
         delegate: Component{
             id: wordListDelegate
@@ -64,7 +77,7 @@ Rectangle {
                 MouseArea{
                     anchors.fill: parent
                     onClicked: {
-                        wordList.currentIndex = number
+                        wordList.currentIndex = index// number
                         rectangle1.wordSelected(word)
                     }
                 }
@@ -73,14 +86,7 @@ Rectangle {
                 Text {
                     id: wordText
                     anchors.verticalCenter: parent.verticalCenter
-                    text:
-                    {
-                        if (word == "!@#$%"){
-                            qsTr("Can't find any matching words")
-                        } else {
-                            word
-                        }
-                    }
+                    text: word
                 }
 
                 Checkbox{
@@ -94,19 +100,51 @@ Rectangle {
 
                     anchors.verticalCenter: parent.verticalCenter
                     onChanged: rectangle1.changeWordState(number, selected)
-                    visible: {
-                        if (word == "!@#$%"){
-                            false
-                        } else {
-                            true
-                        }
-                    }
                 }
 
             }
 
         }
 
+        Text {
+            id: emptyText
+            anchors.top: parent.top
+            anchors.left: parent.left
+            text: qsTr("Can't find any matching words")
+        }
+
+        Rectangle {
+            id: shadeDisable
+            anchors.centerIn: parent;
+            color: "grey";
+            opacity: 0
+            width:  parent.width;
+            height: parent.height;
+        }
+
         model: wordModel
+
+        states: [
+            State {
+                name: "empty"
+                when: (wordList.empty == true);
+                PropertyChanges { target: emptyText; visible: true}
+            },
+            State {
+                name: "non-empty"
+                when: (wordList.empty == false);
+                PropertyChanges { target: emptyText; visible: false}
+            },
+            State {
+                name: "enabled"
+                when: (wordList.enabled == true);
+                PropertyChanges { target: shadeDisable; z: 30; opacity: 0.5 }
+            },
+            State {
+                name: "disabled"
+                when: (wordList.enabled == false);
+                PropertyChanges { target: shadeDisable; z: 30; opacity: 0.0 }
+            }
+        ]
     }
 }