2018-11-27 12:21:50 +03:00
|
|
|
import "../js/showdown-1.9.0/dist/showdown.js" as ShowDown
|
2018-10-16 18:50:58 +03:00
|
|
|
import QtQuick 2.0
|
|
|
|
import Sailfish.Silica 1.0
|
|
|
|
|
2018-11-18 13:25:28 +03:00
|
|
|
Dialog {
|
|
|
|
id: noteDialog
|
2018-11-27 11:58:21 +03:00
|
|
|
property var showdown: ShowDown.showdown
|
|
|
|
property var converter: new showdown.Converter( { noHeaderId: true, simplifiedAutoLink: true, tables: true, tasklists: false, simpleLineBreaks: true, emoji: true } )
|
2018-11-18 13:25:28 +03:00
|
|
|
|
2018-11-24 21:34:01 +03:00
|
|
|
function reloadContent() {
|
2018-11-27 11:58:21 +03:00
|
|
|
contentLabel.text = converter.makeHtml(account.model.get(noteIndex).content)
|
|
|
|
//console.log(contentLabel.text)
|
2018-11-24 21:34:01 +03:00
|
|
|
}
|
|
|
|
|
2018-11-18 13:25:28 +03:00
|
|
|
acceptDestination: Qt.resolvedUrl("EditPage.qml")
|
|
|
|
acceptDestinationProperties: { account: account; noteIndex: noteIndex }
|
2018-11-18 17:01:32 +03:00
|
|
|
Component.onCompleted: acceptDestinationProperties = { account: account, noteIndex: noteIndex }
|
|
|
|
onStatusChanged: {
|
|
|
|
if (status === PageStatus.Active) {
|
2018-11-24 21:34:01 +03:00
|
|
|
account.getNote(account.model.get(noteIndex).id)
|
|
|
|
reloadContent()
|
2018-11-18 17:01:32 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
Connections {
|
2018-11-24 21:34:01 +03:00
|
|
|
target: account/*.model.get(noteIndex)
|
|
|
|
onTitleChanged: {
|
|
|
|
console.log("Title changed")
|
|
|
|
dialogHeader.title = account.model.get(noteIndex).title
|
|
|
|
}
|
2018-11-18 17:01:32 +03:00
|
|
|
onContentChanged: {
|
2018-11-24 21:34:01 +03:00
|
|
|
console.log("Content changed")
|
2018-11-18 17:01:32 +03:00
|
|
|
contentLabel.plainText = account.model.get(noteIndex).content
|
|
|
|
contentLabel.parse()
|
2018-11-24 21:34:01 +03:00
|
|
|
}*/
|
|
|
|
onBusyChanged: {
|
|
|
|
if (account.busy === false) {
|
|
|
|
reloadContent()
|
|
|
|
}
|
2018-11-18 17:01:32 +03:00
|
|
|
}
|
|
|
|
}
|
2018-11-18 13:25:28 +03:00
|
|
|
|
|
|
|
property var account
|
|
|
|
property int noteIndex
|
2018-10-16 18:50:58 +03:00
|
|
|
|
|
|
|
SilicaFlickable {
|
|
|
|
anchors.fill: parent
|
2018-11-26 19:21:33 +03:00
|
|
|
contentHeight: mainColumn.height
|
2018-10-16 18:50:58 +03:00
|
|
|
|
|
|
|
Column {
|
2018-11-26 19:21:33 +03:00
|
|
|
id: mainColumn
|
2018-10-21 02:44:23 +03:00
|
|
|
width: parent.width
|
2018-11-26 19:21:33 +03:00
|
|
|
|
2018-11-24 21:34:01 +03:00
|
|
|
RemorsePopup {
|
|
|
|
id: remorse
|
|
|
|
onTriggered: pageStack.pop()
|
|
|
|
}
|
|
|
|
PullDownMenu {
|
|
|
|
busy: account ? account.busy : false
|
|
|
|
|
|
|
|
MenuItem {
|
|
|
|
text: qsTr("Delete")
|
|
|
|
enabled: account ? true : false
|
|
|
|
//visible: appSettings.currentAccount >= 0
|
|
|
|
onClicked: remorse.execute("Deleting", function() { account.deleteNote(account.model.get(noteIndex).id) } )
|
|
|
|
}
|
|
|
|
MenuItem {
|
|
|
|
text: enabled ? qsTr("Reload") : qsTr("Updating...")
|
|
|
|
enabled: account ? !account.busy : false
|
|
|
|
//visible: appSettings.currentAccount >= 0
|
|
|
|
onClicked: account.getNote(account.model.get(noteIndex).id)
|
|
|
|
}
|
|
|
|
MenuLabel {
|
|
|
|
visible: appSettings.currentAccount >= 0
|
|
|
|
text: account ? (
|
|
|
|
qsTr("Last update") + ": " + (
|
|
|
|
new Date(account.update).valueOf() !== 0 ?
|
|
|
|
new Date(account.update).toLocaleString(Qt.locale(), Locale.ShortFormat) :
|
|
|
|
qsTr("never"))) : ""
|
|
|
|
}
|
|
|
|
}
|
2018-10-16 18:50:58 +03:00
|
|
|
|
2018-11-18 13:25:28 +03:00
|
|
|
DialogHeader {
|
2018-11-18 17:01:32 +03:00
|
|
|
id: dialogHeader
|
2018-11-18 13:25:28 +03:00
|
|
|
acceptText: qsTr("Edit")
|
|
|
|
cancelText: qsTr("Notes")
|
2018-10-16 18:50:58 +03:00
|
|
|
}
|
|
|
|
|
2018-11-26 19:21:33 +03:00
|
|
|
Column {
|
|
|
|
width: parent.width
|
|
|
|
spacing: Theme.paddingLarge
|
|
|
|
|
|
|
|
LinkedLabel {
|
|
|
|
id: contentLabel
|
|
|
|
x: Theme.horizontalPageMargin
|
|
|
|
width: parent.width - 2*x
|
|
|
|
textFormat: Text.StyledText
|
2018-11-27 11:58:21 +03:00
|
|
|
defaultLinkActions: true
|
2018-11-26 19:21:33 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
Separator {
|
|
|
|
id: separator
|
|
|
|
width: parent.width
|
|
|
|
color: Theme.primaryColor
|
|
|
|
horizontalAlignment: Qt.AlignHCenter
|
|
|
|
}
|
|
|
|
|
|
|
|
Column {
|
|
|
|
width: parent.width
|
|
|
|
|
|
|
|
DetailItem {
|
|
|
|
label: qsTr("Modified")
|
|
|
|
value: new Date(account.model.get(noteIndex).modified * 1000).toLocaleString(Qt.locale(), Locale.ShortFormat)
|
|
|
|
}
|
|
|
|
DetailItem {
|
|
|
|
label: qsTr("Favorite")
|
|
|
|
value: account.model.get(noteIndex).favorite ? qsTr("yes") : qsTr("no")
|
|
|
|
}
|
|
|
|
DetailItem {
|
|
|
|
label: qsTr("Category")
|
|
|
|
value: account.model.get(noteIndex).category
|
|
|
|
visible: value.length > 0
|
2018-10-21 02:44:23 +03:00
|
|
|
}
|
|
|
|
}
|
2018-10-16 18:50:58 +03:00
|
|
|
}
|
|
|
|
}
|
2018-10-21 02:44:23 +03:00
|
|
|
|
2018-10-16 18:50:58 +03:00
|
|
|
VerticalScrollDecorator {}
|
|
|
|
}
|
|
|
|
}
|