Skip to content

Commit

Permalink
Issues #121 and #101 (#122)
Browse files Browse the repository at this point in the history
* Bugfix: Revert TableViewColumn and TaskLine to b396eab

* Recovered some harmless functionalities of TaskLine.qml

* Fixes 121 and 101
  • Loading branch information
alvcap authored and Topas committed Mar 11, 2019
1 parent b648837 commit ff62aac
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 32 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,8 @@ Thumbs.db
*.exe
*portable.zip
*.qmlc

# Build and packaging
build
dist
*.egg-info
52 changes: 24 additions & 28 deletions qtodotxt2/qml/TaskLine.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 { }
}
}

Expand All @@ -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)
}
}
]
Expand Down
14 changes: 10 additions & 4 deletions qtodotxt2/qml/TaskListTableView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
}
}

Expand Down

0 comments on commit ff62aac

Please sign in to comment.