Implemented auto prepend for list elements.

This commit is contained in:
Scharel Clemens 2018-12-04 00:46:04 +01:00
parent a8d1b64251
commit d2449f7591
4 changed files with 25 additions and 10 deletions

View file

@ -15,6 +15,7 @@ Dialog {
onStatusChanged: {
if (status === PageStatus.Active) {
note = account.getNote(note.id, false)
favoriteButton.selected = note.favorite
}
}
@ -29,9 +30,6 @@ Dialog {
onClicked: {
note = account.getNote(note.id, false)
favoriteButton.selected = note.favorite
//categoryField.text = note.category
//contentArea.text = note.content
//favoriteButton.selected = note.favorite
}
}
MenuItem {
@ -53,12 +51,26 @@ Dialog {
width: parent.width
focus: true
text: note.content
property int preTextLength: 0
property var listPrefixes: ["- ", "* ", "+ ", "- [ ] ", "- [x] ", "- [X] "]
onTextChanged: {
// TODO Autocomplete list symbols
/*var preText = text.substring(0, cursorPosition)
preText = preText.substring(preText.lastIndexOf('\n'))
console.log(preText)
console.log(text.substring(cursorPosition))*/
if (page.status === PageStatus.Active &&
text.length > preTextLength &&
text.charAt(cursorPosition-1) === "\n") {
var clipboard = ""
var preLine = text.substring(text.lastIndexOf("\n", cursorPosition-2), text.indexOf("\n", cursorPosition-1))
listPrefixes.forEach(function(currentValue) {
if (preLine.indexOf(currentValue) === 1)
clipboard = currentValue
})
if (clipboard !== "") {
var tmpClipboard = Clipboard.text
Clipboard.text = clipboard
contentArea.paste()
Clipboard.text = tmpClipboard
}
}
preTextLength = text.length
}
}

View file

@ -12,6 +12,9 @@
# * date Author's Name <author's email> version-release
# - Summary of changes
* Tue Dec 04 2018 Scharel Clemens <harbour-nextcloudnotes@scharel.name> 0.1-5
- Implemented auto prepend for list elements
* Mon Dec 03 2018 Scharel Clemens <harbour-nextcloudnotes@scharel.name> 0.1-4
- Implemented searching
- Larger checkboxes

View file

@ -14,7 +14,7 @@ Name: harbour-nextcloudnotes
%{?qtc_builddir:%define _builddir %qtc_builddir}
Summary: Nextcloud Notes
Version: 0.1
Release: 4
Release: 5
Group: Qt/Qt
License: LICENSE
URL: http://example.org/

View file

@ -1,7 +1,7 @@
Name: harbour-nextcloudnotes
Summary: Nextcloud Notes
Version: 0.1
Release: 4
Release: 5
# The contents of the Group field should be one of the groups listed here:
# https://github.com/mer-tools/spectacle/blob/master/data/GROUPS
Group: Qt/Qt