fixed wordListWidget acting when word list is empty
[mdictionary] / src / mdictionary / qml / WordListWidget.qml
index 9670a14..cb972fa 100644 (file)
@@ -33,6 +33,7 @@ Rectangle {
     }
 
     function setEnabled(Boolean) { wordList.enabled = Boolean }
+    function setWordListEmpty(Boolean) { wordList.empty = Boolean }
 
     signal wordSelected(string word);
 
@@ -48,6 +49,7 @@ Rectangle {
 
         anchors.fill: parent
         highlightResizeSpeed: 1000
+        property bool empty: false
 
         delegate: Component{
             id: wordListDelegate
@@ -106,6 +108,26 @@ Rectangle {
 
         }
 
+        Text {
+            id: emptyText
+            anchors.top: parent.top
+            anchors.left: parent.left
+            text: qsTr("Can't find any matching words")
+        }
+
         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}
+            }
+        ]
     }
 }