diff --git a/.gitignore b/.gitignore index 1478f68..13396ea 100644 --- a/.gitignore +++ b/.gitignore @@ -72,3 +72,8 @@ Thumbs.db *.exe *portable.zip *.qmlc + +# Build and packaging +build +dist +*.egg-info diff --git a/qtodotxt2/qml/TaskLine.qml b/qtodotxt2/qml/TaskLine.qml index fee3e12..e1a06e1 100644 --- a/qtodotxt2/qml/TaskLine.qml +++ b/qtodotxt2/qml/TaskLine.qml @@ -6,35 +6,40 @@ import Theme 1.0 Loader { id: taskLine - property var task - // property string text: (task !== null ? task.text : "") - // property string html: (task !== null ? task.html : "") + property string text: "" + property string html: "" + property string priority: "" property bool current: false property bool hovered: false + onCurrentChanged: { + if (!current) state = "show" + } + signal inputAccepted(string newText) + onInputAccepted: state = "show" + state: "show" -// onStateChanged: console.log("taskline.state", state) sourceComponent: labelComp Component { id: labelComp MouseArea { anchors.fill: parent -// width: taskLine.width -// height: Math.max(label.height, 1) //Theme.minRowHeight) hoverEnabled: true propagateComposedEvents: true acceptedButtons: Qt.NoButton onEntered: taskLine.hovered = true onExited: taskLine.hovered = false + property alias lblHeight: label.height + Label { id: label anchors.verticalCenter: parent.verticalCenter width: taskLine.width - text: (task !== null ? task.html : "") + text: taskLine.html textFormat: Qt.RichText wrapMode: Text.Wrap @@ -48,38 +53,29 @@ Loader { TextArea { property bool runQuitEdit: true property bool discard: false + text: taskLine.text focus: true - height: Math.max(contentHeight, Theme.minRowHeight) - - Keys.onReturnPressed: taskLine.state = "show" - Keys.onEnterPressed: taskLine.state = "show" + Keys.onReturnPressed: taskLine.inputAccepted(text) + Keys.onEnterPressed: taskLine.inputAccepted(text) Keys.onEscapePressed: { - discard = true; - taskLine.state = "show"; - } - - onActiveFocusChanged: { -// console.log("activeFocusChanged", activeFocus, taskLine.state) - if (!activeFocus) { - console.log("lost focus") - taskLine.state = "show" - } + discard = true + taskLine.state = "show" } + CompletionPopup { } Component.onCompleted: { forceActiveFocus() //helps, when searchbar is active - text = task.text cursorPosition = text.length } - Component.onDestruction: { - if (!discard) task.text = text - else if (task.text === "") task.text = "" + onActiveFocusChanged: { + if (!activeFocus) { + console.log("lost focus") + taskLine.state = "show" + } } - - CompletionPopup { } } } @@ -98,7 +94,7 @@ Loader { PropertyChanges { target: taskLine sourceComponent: editorComp -// height: Math.max(taskLine.item.contentHeight, Theme.minRowHeight) + height: Math.max(taskLine.item.contentHeight, Theme.minRowHeight) } } ] diff --git a/qtodotxt2/qml/TaskListTableView.qml b/qtodotxt2/qml/TaskListTableView.qml index ed02cbd..8117e10 100644 --- a/qtodotxt2/qml/TaskListTableView.qml +++ b/qtodotxt2/qml/TaskListTableView.qml @@ -159,18 +159,24 @@ TableView { TableViewColumn { role: "html" delegate: TaskLine { + //width: listView.width - current: (styleData.selected && listView.currentRow === styleData.row) + text: { + if (taskList[styleData.row]) taskList[styleData.row].text; + else "" + } + html: styleData.value //taskList[styleData.row].html + + current: (listView.currentRow === styleData.row) onCurrentChanged: { if (current) listView.currentItem = this } onHeightChanged: { listView.rowHeightChanged(styleData.row, height) } - onHoveredChanged: { - listView.rowHoveredChanged(styleData.row, hovered) + onInputAccepted: { + taskList[styleData.row].text = newText } - Component.onCompleted: task = taskList[styleData.row] } }