connect(this, SIGNAL(setWordListState(QVariant)), rootObject, SLOT(setEnabled(QVariant)));
connect(this, SIGNAL(setWordListEmpty(QVariant)), rootObject, SLOT(setWordListEmpty(QVariant)));
+ connect(this, SIGNAL(setFocusOnQML()), rootObject, SLOT(setFocus()));
#endif
delete proxyStyle;
}
+void WordListWidget::setFocusOnElement(){
+ setFocus();
+ qmlView->setFocus();
+ Q_EMIT setFocusOnQML();
+ qDebug()<<hasFocus()<<" "<<qmlView->hasFocus();
+}
+
void WordListWidget::addWord(QString word, int row) {
QStandardItem* item = new QStandardItem(word);
currentIndex: 0
highlight: Rectangle { color: "lightsteelblue"; radius: 5; width: parent.parent.width }
highlightMoveSpeed: 1000
+
+ function setFocus() {
+ console.log("juhu2")
+ forceActiveFocus()
+// console.log(focus + " " + activeFocus)
+ }
+
+ Keys.onPressed: {
+ console.log("woooo")
+ if (event.key == Qt.Key_Up && currentIndex < count){
+ currentIndex = currentIndex + 1
+ console.log("woooo222 " + currentIndex)
+ } else if (event.key == Qt.Key_Down && currentIndex > 0){
+ currentIndex = currentIndex - 1
+ console.log("woooo333 " + currentIndex)
+ }
+ }
+
}
Rectangle {
function changeWordState(nr, state) {
+ console.log("LOOOOOL")
wordList.currentIndex = nr
wordModel.setModelProperty(wordList.currentIndex, state, "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);
highlightResizeSpeed: 1000
property bool empty: false
+ onCurrentIndexChanged: {
+ console.log("111!!!WTF " + currentIndex)
+ }
+
delegate: Component{
id: wordListDelegate
Item {
MouseArea{
anchors.fill: parent
onClicked: {
- wordList.currentIndex = number
+ wordList.currentIndex = index// number
rectangle1.wordSelected(word)
}
}
Text {
id: wordText
anchors.verticalCenter: parent.verticalCenter
- text:
- {
- if (word == "!@#$%"){
- qsTr("Can't find any matching words")
- } else {
- word
- }
- }
+ text: word
}
Checkbox{
anchors.verticalCenter: parent.verticalCenter
onChanged: rectangle1.changeWordState(number, selected)
- visible: {
- if (word == "!@#$%"){
- false
- } else {
- true
- }
- }
}
}
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: [
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 }
}
]
}