Ability to add and delete notes.

This commit is contained in:
Scharel Clemens 2018-11-18 13:11:22 +01:00
parent ad45fb0a91
commit b2284de2e1
5 changed files with 28 additions and 24 deletions

View file

@ -12,6 +12,8 @@ You can preview some screenshots [here](https://www.scharel.name/harbour/nextclo
- Show the content of the notes
- Basic [Markdown](https://en.wikipedia.org/wiki/Markdown) rendering
- Edit the notes content
- Create new notes
- Delete notes
- Edit favorite property
- Edit category property
@ -19,8 +21,6 @@ You can preview some screenshots [here](https://www.scharel.name/harbour/nextclo
(The ordering represents the priority for the implementation)
- Login screen for the nextcloud account (using the [Login Flow](https://docs.nextcloud.com/server/14/developer_manual/client_apis/LoginFlow/index.html) if possible)
- Create new notes
- Delete notes
- Automatically push changes to the server while editing a note
- Better [Markdown](https://en.wikipedia.org/wiki/Markdown) rendering
- Search in notes

View file

@ -5,7 +5,7 @@ Dialog {
id: page
onAccepted: {
account.updateNote(account.model.get(noteIndex).id, { 'category': categoryField.text, 'content': contentArea.text, 'favorite': favoriteButton.down } )
account.updateNote(account.model.get(noteIndex).id, { 'category': categoryField.text, 'content': contentArea.text, 'favorite': favoriteButton.selected } )
}
property var account
@ -17,10 +17,17 @@ Dialog {
contentHeight: column.height
PullDownMenu {
quickSelect: true
MenuItem {
/*MenuItem {
text: qsTr("Markdown Cheatsheet")
onClicked: pageStack.push(Qt.resolvedUrl("MarkdownPage.qml"))
}*/
MenuItem {
text: qsTr("Reset")
onClicked: {
categoryField.text = account.model.get(noteIndex).category
contentArea.text = account.model.get(noteIndex).content
favoriteButton.selected = account.model.get(noteIndex).favorite
}
}
}
@ -43,10 +50,11 @@ Dialog {
width: parent.width - x
IconButton {
id: favoriteButton
property bool selected: account.model.get(noteIndex).favorite
width: Theme.iconSizeMedium
icon.source: (account.model.get(noteIndex).favorite ? "image://theme/icon-m-favorite-selected?" : "image://theme/icon-m-favorite?") +
icon.source: (selected ? "image://theme/icon-m-favorite-selected?" : "image://theme/icon-m-favorite?") +
(favoriteButton.highlighted ? Theme.secondaryHighlightColor : Theme.secondaryColor)
onClicked: account.model.get(noteIndex).favorite = !account.model.get(noteIndex).favorite
onClicked: selected = !selected
}
TextField {
id: categoryField

View file

@ -6,11 +6,6 @@ Dialog {
acceptDestination: Qt.resolvedUrl("EditPage.qml")
acceptDestinationProperties: { account: account; noteIndex: noteIndex }
/*onAcceptPendingChanged: {
if (acceptPending) {
acceptDestinationInstance.note = note
}
}*/
Component.onCompleted: acceptDestinationProperties = { account: account, noteIndex: noteIndex }//acceptDestinationInstance.note = note
property var account
@ -31,14 +26,6 @@ Dialog {
anchors.fill: parent
contentHeight: column.height
/*PullDownMenu {
quickSelect: true
MenuItem {
text: qsTr("Edit")
onClicked: pageStack.push(Qt.resolvedUrl("EditPage.qml"), { note: note } )
}
}*/
Column {
id: column
width: parent.width
@ -60,7 +47,6 @@ Dialog {
for (var i=0; i < markdown.length; i++) {
text = text.replace(markdown[i].regex, markdown[i].replace)
}
console.log(text)
}
}
}

View file

@ -105,6 +105,12 @@ Item {
break;
case "DELETE":
console.log("Deleted a note")
for (var i = 0; i < model.count; i++) {
var listItem = model.get(i)
if (listItem.id === data.id){
model.remove(i)
}
}
break;
default:
console.log("Unsupported method: " + method)

View file

@ -31,7 +31,7 @@ Page {
text: qsTr("Add note")
enabled: nextcloudAccounts.itemAt(appSettings.currentAccount) ? !nextcloudAccounts.itemAt(appSettings.currentAccount).busy : false
visible: appSettings.currentAccount >= 0
onClicked: console.log("Add note")
onClicked: nextcloudAccounts.itemAt(appSettings.currentAccount).createNote()
}
MenuItem {
text: qsTr("Reload")
@ -50,7 +50,7 @@ Page {
}
header: PageHeader {
title: qsTr("Nextclound Notes")
title: nextcloudAccounts.itemAt(appSettings.currentAccount).name //qsTr("Nextclound Notes")
description: nextcloudAccounts.itemAt(appSettings.currentAccount).username + "@" + nextcloudAccounts.itemAt(appSettings.currentAccount).server
/*SearchField {
width: parent.width
@ -130,7 +130,11 @@ Page {
}
MenuItem {
text: qsTr("Delete")
onClicked: console.log("Delete note")
onClicked: {
note.remorseAction(qsTr("Deleting note"), function() {
nextcloudAccounts.itemAt(appSettings.currentAccount).deleteNote(id)
})
}
}
}
}